Documentation Index

Fetch the complete documentation index at: https://help.movingimage.com/llms.txt

Use this file to discover all available pages before exploring further.

Click here to access the documentation homepage.

Controlling the player

Prev Next

JavaScript API for Movingimage Video Player

Basic player functions

  • Play: player.play(time) (optional: start playing at a specific time in seconds)

  • Pause: player.pause()

  • Stop: player.stop()

  • Forward: player.forward(millis) (fast forward by a number of milliseconds)

  • Rewind: player.rewind(millis) (rewind by a number of milliseconds)

  • Set volume: player.setVolume(volume) (set the volume to a level between 0.0 and 1.0)

  • Toggle mute: player.toggleMute()

  • Get current time: player.getCurrentTime() (returns the current video time in seconds)

  • Get duration: player.getDuration() (returns the duration of the current video in seconds)

  • Get buffered time: player.getBufferedTime() (returns the total time of the video that has been buffered in seconds)

Subtitle functions

  • Get text track: player.getTextTracks() (returns a list of all available subtitles)

  • Set text track: player.setTextTrack(trackId) (sets the standard subtitle track by specifying the track ID)

  • Disable text track: player.disableTextTrack()

Example

HTML

<div mi24-video-player id="user-defined-id" video-id="video-id" player-id="player-id" channel-id="channel-id" config-type="vmpro" flash-path="//e.video-cdn.net/v2/" api-url="//d.video-cdn.net/play"></div>

JavaScript

window.addEventListener("load", (event) => {
  setTimeout(function () {
    const player = VideoPlayer.Collection.getPlayerById("user-defined-id");
    const tracks = player.getTextTracks() || [];
    if (tracks[0] && tracks[0].id) {
      player.setTextTrack(tracks[0].id);
    }
  }, 2000);
});

This code will automatically enable the first subtitle track when the video loads.

Chapter functions

  • Add chapter: player.addChapter({start, title, description, thumbnail}) (adds a chapter to the player dynamically)

  • Update chapter: player.updateChapter(millis, {start, title, description, thumbnail}) (updates an existing chapter)

  • Delete chapter: player.deleteChapter(millis) (deletes a chapter by its start time)

Example

JavaScript

// Add a new chapter at 3 seconds with the given title, description, and thumbnail
VideoPlayer.Collection.getPlayerById("player_container_id").addChapter({
  start: 3000,
  title: "Chapter 1",
  description: "description for chapter 1",
  thumbnail: "//www.movingimage.com/wp-content/uploads/2019/08/movingimage-Enterprise-Video-Platform.jpg",
});

// Update the chapter that starts at 3 seconds
VideoPlayer.Collection.getPlayerById("player_container_id").updateChapter(3000, {
  title: "Chapter 3",
});

// Delete the chapter that starts at 3 seconds
VideoPlayer.Collection.getPlayerById("player_container_id").deleteChapter(3000);

Conclusion

The Player JavaScript API provides a comprehensive set of functions for controlling basic player functions, subtitles, and chapters. This documentation provides a brief overview of the API, but for more detailed information, please consult this article.