Skip to content

Root: ui|v2.5|src|components|ScenePlayer: util.ts

Serechops edited this page Apr 10, 2024 · 1 revision

util.ts

This file provides utility functions related to the Video.js player.

Structure and Functionality:

  1. Constants:

    • VIDEO_PLAYER_ID: Defines the ID of the Video.js player, which is set to "VideoJsPlayer".
  2. Functions:

    • getPlayerPosition: Retrieves the current playback position (in seconds) of the Video.js player with the ID specified by VIDEO_PLAYER_ID. If the player exists, it returns the current playback time; otherwise, it returns undefined.

Example Modification:

You can modify the util.ts file to enhance utility functions or add new ones. For instance, you may want to extend the functionality to retrieve additional player properties or perform custom actions based on player state.

// Modify the getPlayerPosition function to include more player properties
export const getPlayerInfo = () => {
  const player = videojs.getPlayer(VIDEO_PLAYER_ID);
  if (player) {
    return {
      currentTime: player.currentTime(),
      duration: player.duration(),
      volume: player.volume(),
      isPaused: player.paused(),
      // Add more player properties as needed
    };
  }
  return null;
};

Explanation:

The modification extends the util.ts file by adding a new utility function getPlayerInfo, which retrieves various properties of the Video.js player such as current time, duration, volume, and playback state. This enhancement provides more comprehensive information about the player's status and allows for better monitoring and control of the player's behavior.

Clone this wiki locally