Interface MKPlayerAPI

MKPlayer API.

Hierarchy

  • MKPlayerAPI

Methods

  • Sends custom metadata to a remote receiver app (e.g. Chromecast).

    Parameters

    • metadata: any

      the custom metadata to send to the receiver.

    Returns boolean

    true if it was successful.

  • Adds a subtitle track.

    isFragmented type of subtitle tracks are not supported when added via this method.

    Parameters

    Returns void

  • Stops a running Cast session (i.e. isCasting returns true).

    Has no effect if isCasting returns false.

    Returns void

  • Initiates casting the current video to a Cast-compatible device.

    The user has to choose the target device.

    Returns void

  • Unloads the player and removes all inserted HTML elements and event handlers.

    Returns Promise<void>

    Promise resolves when the player has cleaned up all its event handlers & resources.

  • Disables an already enabled subtitle track.

    Parameters

    • subtitleID: string

      the subtitle track identifier.

    Returns void

  • Enables a subtitle track.

    Parameters

    • subtitleID: string

      the subtitle track identifier.

    Returns void

  • Returns the current aspect ratio of the player, or 0 if there is no style module.

    Note: the default player aspect ratio is 16:9.

    Returns number

    A number indicating the player aspect ratio (e.g. 1.6 for 16:10) or 0 in case of error.

  • Returns the currently used audio track, or null if no track is active.

    Returns null | MKAudioTrack

  • Returns an array of all available audio qualities the player can adapt between.

    Returns MKAudioQuality[]

  • Get list of all available subtitle tracks.

    Returns MKSubtitleTrack[]

    list of available subtitle tracks when available or an empty array when not available.

  • Returns an array containing all available video qualities the player can adapt between.

    Returns MKVideoQuality[]

  • Returns the current and target buffer level for the given buffer type and media type.

    Parameters

    • type: MKBufferType

      the buffer type for which to get the buffer level for.

    • media: MKMediaType

      the media type for which to get the buffer level for.

    Returns null | MKBufferLevel

    the buffer level object or null in case of error.

  • Returns the currently buffered time ranges of the video element.

    Returns MKTimeRange[]

  • Returns the current playback time in seconds of the video.

    Parameters

    Returns number

  • Returns the total number of dropped video frames since playback started.

    Returns number

  • Returns the total duration in seconds of the current video.

    Returns number

  • Returns the current latency in seconds.

    Returns number

    the current latency in seconds.

  • Returns the limit in seconds for time shift.

    Is either negative or 0 and applicable to live streams only.

    Returns number

  • Returns the current playback speed of the player.

    1 is the default playback speed, values between 0 and 1 refer to slow motion and values greater than 1 refer to fast forward.

    Values less or equal zero are ignored.

    Returns number

  • Returns the time range that is currently valid for seeking.

    Note For VOD default mode is RelativeTime and for Live it is AbsoluteTime.

    Parameters

    • Optional mode: MKTimeMode

      The mode to decide if the returned time should be absolute or relative, see MKTimeMode.

    Returns null | MKTimeRange

    the current seekable range when available or null otherwise.

  • Returns the current target latency in seconds.

    Returns number

    target latency in seconds.

  • Returns a thumbnail image for a certain time or null if there is no thumbnail available.

    Requires a configured thumbnails track in thumbnailTrack if sideloaded thumbnails are configured.

    Requires enableHlsImageMediaPlaylistSupport to be true if thumbnail images from the HLS manifest are needed.

    When thumbnailTrack are configured, this will have preference over the thumbnails found in the HLS manifest.

    Parameters

    • time: number

      the media time for which the thumbnail should be returned.

    Returns null | MKThumbnail

    A thumbnail if a thumbnails track is configured and a thumbnail exists for the specified time, else null.

  • Returns the current time shift offset to the live edge in seconds.

    Is either negative or 0 and applicable to live streams only.

    Offset 0 indicates the current live edge.

    Returns number

  • Returns the stalled time in seconds since playback started.

    Returns number

  • Returns current MKPlayer SDK version.

    Returns string

  • Returns the html element that the player is embedded in, which has been provided in the player constructor.

    Returns HTMLElement

  • Returns the used HTML5 video element.

    Returns undefined | HTMLVideoElement

  • Returns the player’s volume between 0 (silent) and 100 (max volume).

    Returns number

  • Returns true if the video has ended.

    Returns boolean

  • Checks if Apple Airplay is enabled.

    Returns boolean

  • Checks if Apple AirPlay support is available.

    Returns boolean

  • Returns true if casting to another device (such as a ChromeCast) is available, otherwise false.

    Please note that this function only returns true after the CastAvailable event has fired.

    Returns boolean

  • Returns true if the video is currently casted to a device and not played in the browser, or false if the video is played locally.

    Returns boolean

  • Return true if the displayed video is a live stream.

    Returns boolean

  • Returns true if the player has been muted.

    Returns boolean

  • Returns true if the player has started playback but is currently paused.

    Returns boolean

  • Returns true if the player is currently playing, i.e. has started and is not paused.

    Returns boolean

  • Returns true if the player is currently stalling due to an empty buffer.

    Returns boolean

  • Tests if a particular ViewMode is available for selection with setViewMode.

    Parameters

    Returns boolean

    true if the tested view mode is available, else false.

  • Sets a new video source and returns a promise which resolves when the source has loaded successfully.

    Parameters

    • sourceConfig: MKSourceConfig

      the source configuration object.

    • Optional disableSeeking: boolean

      If set, seeking will be disabled.

    Returns Promise<void>

    Promise which resolves when the source is loaded and rejects when load fails.

  • Mutes the player if an audio track is available. Has no effect if the player is already muted.

    Parameters

    • Optional issuer: string

      The issuer of the API call that will be passed to events triggered by this call.

    Returns void

  • Removes a handler for a player event.

    Parameters

    Returns void

  • Subscribes an event handler to a player event.

    Parameters

    Returns void

  • Pauses the video if it is playing. Has no effect if the player is already paused.

    Parameters

    • Optional issuer: string

      The issuer of the API call that will be passed to events triggered by this call.

    Returns void

  • Starts playback or resumes after being paused.

    No need to call it if the player is stup with autoplay.

    Calling play has no effect when player is already playing.

    Parameters

    • Optional issuer: string

      the issuer of the API call that will be passed to events triggered by this call.

    Returns Promise<void>

    a promise which resolves as soon as playback starts. The promise can reject if the play is blocked by the browser.

  • Starts preloading the content of the currently loaded source.

    Returns void

  • Removes a subtitle track.

    Disables it in case it's enabled before removal.

    Parameters

    • subtitleID: string

      the identifier of the subtitle track to remove.

    Returns void

  • Seeks to the given playback time specified by the parameter time in seconds.

    The time offset specified must always be a positive value.

    For VOD, Catchup or DVR specified time must not be greater than the total duration of the video.

    For Live and Events the specified time either be relative or absolute offset.

    • Calling seek(0) will take you to the start of the live window
    • Calling seek(getSeekableRange().end) will take you near the current live edge. You can also call () to jump to current live edge easily.

    Parameters

    • time: number

      The time to seek to in seconds.

    • Optional issuer: string

      The issuer of the API call that will be passed to events triggered by this call.

    Returns boolean

    true when successful.

  • Seeks to the current live edge.

    Applicable only for live sources.

    Parameters

    • Optional issuer: string

      The issuer of the API call that will be passed to events triggered by this call.

    Returns void

  • Modifies the current aspect ratio of the player.

    Parameters

    • aspectratio: string | number

      The desired aspect ratio for the player. It can be a string (e.g. '16:9' or '16/9'), or a number (e.g 1.6 for 16:10).

    Returns void

  • Sets the audio track to the ID specified by trackID.

    Available tracks can be retrieved with getAvailableAudio.

    Parameters

    • trackID: string

      The ID of the audio track to activate.

    Returns void

  • Manually sets the audio stream to a fixed quality, identified by ID.

    Has to be an ID defined in the MPD or the keyword 'auto'.

    Auto resets to dynamic switching.

    A list with valid IDs can be retrieved by calling getAvailableAudioQualities.

    Parameters

    • audioQualityID: string

      The ID of the desired audio quality or 'auto' for dynamic switching.

    Returns void

  • Set authorization token.

    Note: this is applicable only for registered source streams and during an ongoing playback session to update an authorization token that is about to expire (token refresh). Setting this before calling load will have no effect and it is expected to have the updated authorization token as part of the azuki config in the registered source config object passed to start playback of a next source.

    Parameters

    • authorizationToken: string

      the new authorization token.

    Returns void

  • Sets the configuration specifying parameters for latency catchup.

    Parameters

    Returns void

  • Sets the configuration specifying parameters for latency fallback.

    Parameters

    Returns void

  • Set inhome status.

    Note: this is applicable only for registered source streams. This setting will only be applied when the next playback session starts. So it is expected to call this before calling load.

    Parameters

    • inhomeStatus: boolean

      the new inhome status value.

    Returns void

  • Set location detail information.

    Note: this is applicable only for registered source streams. This setting will only be applied when the next playback session starts. So it is expected to call this before calling load.

    Parameters

    • locationDetail: string

      the new location details as base64 encoded string.

    Returns void

  • Sets the level of player log outputs.

    Parameters

    • level: MKLogLevel

      Log level, allowed values are "debug", "log", "warn", "error" and "off"

    Returns void

  • Sets the playback speed of the player.

    Available only for HTML5 player.

    Fast forward as well as slow motion is supported.

    Slow motion is used by values between 0 and 1, fast forward by values greater than 1.

    Parameters

    • speed: number

      A playback speed factor greater than 0.

    Returns void

  • Sets a poster image. Will be displayed immediately, even if a video stream is playing.

    Parameters

    • url: string

      The URL to the poster image.

    • keepPersistent: boolean

      Flag to set the poster image persistent so it is also displayed during playback (useful for audio-only playback).

    Returns void

  • Sets the target buffer level for the chosen buffer and media type.

    Parameters

    • type: MKBufferType

      the buffer type to change the target buffer level for.

    • value: number

      the value to set.

    • media: MKMediaType

      the media type to change the target buffer level for.

    Returns void

  • Sets the target latency to be maintained during playback.

    Causes firing a TargetLatencyChanged event.

    Parameters

    • latency: number

      the target latency in seconds.

    Returns void

  • Passes an HTML video element to the player, which should be used in case of Html5 or Native playback.

    For this to take effect you must call this function before calling load.

    When no video element is set on the player, the player will create one for use internally. You may call getVideoElement to get hold of the video element in use by the player.

    Also the video element should be contained within the video container element that was passed as part of player creation.

    Example:

    ' In the HTML body
    <div id="videoContainer">
    <video id="videoElement"></video>
    </div>

    ' In the script
    let videoContainer = document.getElementById("videoContainer");
    let videoElement = document.getElementById("videoElement");
    let playerConfig = {
    key: "<license_key>",
    playback: {
    autoplay: true,
    muted: true
    }
    };

    let player = new mkplayer.MKPlayer(playerConfig, videoContainer);
    player.setVideoElement(videoElement);
    player.load(sourceConfig);

    Parameters

    • videoElement: HTMLVideoElement

      the video element to set.

    Returns void

  • Manually sets the video stream to a fixed quality, identified by ID.

    Has to be an ID defined in the Manifest/MPD or the keyword 'auto'.

    Auto resets to dynamic switching.

    A list with valid IDs can be retrieved by calling getAvailableVideoQualities.

    Parameters

    • videoQualityID: string

      ID defined in the Manifest/MPD or 'auto'.

    Returns void

  • Sets the player to a particular ViewMode.

    Will only work if the selected view mode is available and isViewModeAvailable returns true, else this call will be ignored.

    If successful, a ViewModeChanged will be fired.

    Parameters

    • viewMode: MKViewMode

      the view mode to switch the player into.

    • Optional options: MKViewModeOptions

      additional optional parameters for view modes.

    Returns void

  • Sets the player’s volume in the range of 0 (silent) to 100 (max volume). Unmutes a muted player.

    Parameters

    • volume: number

      The volume to set between 0 and 100.

    • Optional issuer: string

      The issuer of the API call that will be passed to events triggered by this call.

    Returns void

  • Shows the airplay playback target picker.

    Returns void

  • Unloads the current video source.

    Returns Promise<void>

  • Unmutes the player if muted.

    Parameters

    • Optional issuer: string

      The issuer of the API call that will be passed to events triggered by this call.

    Returns void