@movingimage-evp/player-sdk
    Preparing search index...

    Class Player

    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!');
    });
    Index

    Events

    Methods

    • Attempts to autoplay the video.

      By default, the player uses the 'any' mode. The video starts playing if the browser allows it. If not, the video is muted and autoplay is retried.

      Parameters

      Returns Promise<void>

      A promise that resolves when the video is playing.

    • 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 channel id of the channel this video belongs to.

      Returns undefined | string

      The channel id.

    • 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.

    • Gets the player id of the player configuration being used.

      Returns string

      The player id.

    • Gets the video id of the video being played.

      Returns string

      The video id.

    • Gets the volume level between 0 and 1 of the video.

      Returns Promise<number>

      A promise that resolves with the volume level.

    • Gets the muted state of the video.

      Returns Promise<boolean>

      A promise that resolves with the muted state.

    • Mutes the video.

      Returns Promise<void>

      A promise that resolves when the video is muted.

    • 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.

    • Sets the volume of the video.

      Parameters

      • volume: number

        The volume level between 0 and 1.

      Returns Promise<void>

      A promise that resolves when the volume is set.

    • Unmutes the video.

      Returns Promise<void>

      A promise that resolves when the video is unmuted.

    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 | Element

        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

    • Finds all the players in the entire page and connects the SDK to them.

      Returns Player[]

      An array of all the players found in the page.