To use the SDK, create a new instance of the Player class.

This class contains all the methods and events to interact with the embedded movingimage player.

Given the following embedded movingimage player iframe in your page:

<iframe id='mi-embedded-video' src="//e.video-cdn.net/watch?video-id=123&player-id=123&channel-id=123" allowfullscreen frameborder="0"></iframe>

You can initialize the player SDK like this:

const player = new Player('mi-embedded-video');

Then you can use the player object to interact with the embedded video player. For example:

// Add event handler to know when video is playing
player.on('play', () => {
console.log('Video play requested!');
})

// Play the video
player.play().then(() => {
console.log('Video is now playing!');
});

Events

Methods

  • Disposes this player instance and removes the player iframe from the DOM.

    Returns Promise<void>

    After calling this method, the player instance is no longer usable, and a new one must be created.

  • Gets the current playback position in seconds.

    Returns Promise<number>

    A promise that resolves with the current time in seconds.

  • Get the duration of the video in seconds.

    Returns Promise<number>

    A promise that resolves with the video duration in seconds.

  • Pauses the video if it's playing.

    Returns Promise<void>

    A promise that resolves when the video is paused.

  • Plays the video if it’s paused.

    Returns Promise<void>

    A promise that resolves when the video is playing.

    In some scenarios, playing unmuted video is not allowed. See Autoplay guide for media and Web Audio APIs for more info.

  • Sets the analytics mode. By default, the player uses the 'minimal' mode.

    Parameters

    Returns Promise<void>

  • Sets the player's colors.

    Parameters

    • colors: ColorSettings

      The color settings to override. If a color is not provided, the player will use the color defined in the Player Configuration (in VideoManager Pro).

    Returns Promise<void>

    A promise that resolves when the color settings are applied.

  • Sets the current playback position in seconds.

    Parameters

    • time: number

      The time in seconds to seek to.

    Returns Promise<void>

    A promise that resolves when the media is seeked.

  • Sets the player's language.

    Parameters

    • language: string

      The language code (ex: 'en' or 'de').

    Returns Promise<void>

    A promise that resolves when the language is set.

Other

  • Create a new Player SDK instance, and connect it to the movingimage embedded player. If options are provided, it will create a new embedded player inside the element.

    Parameters

    • element: string | HTMLElement

      The id or iframe HTML element, to bind the SDK to. If options are provided, this should be the parent element instead.

    • Optionaloptions: PlayerParameters

      Optional parameters to create the embedded player.

    Returns Player