Adds a subtitle track.
isFragmented type of subtitle tracks are not supported when added via this method.
Returns the currently used audio track, or null if no track is active.
Returns the currently selected audio quality.
One of the elements of getAvailableAudioQualities.
Returns an array of all available audio tracks.
Returns an array of all available audio qualities the player can adapt between.
Get list of all available subtitle tracks.
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 the current and target buffer level for the given buffer type and media type.
the buffer type for which to get the buffer level for.
the media type for which to get the buffer level for.
the buffer level object or null in case of error.
Returns the currently buffered time ranges of the video element.
Returns the current latency sync configuration for catchup.
the catchup sync configuration.
Returns the current playback time in seconds of the video.
Optional mode: MKTimeModeThe mode to decide if the returned time should be absolute or relative, see MKTimeMode.
For Live and Events the default mode is AbsoluteTime. For VOD, Catchup and DVR its RelativeTime.
Returns data about the last downloaded audio segment.
Returns data about the last downloaded video segment.
Returns the current latency sync configuration for fallback.
the fallback sync configuration.
Returns data about the currently playing audio segment.
Returns data about the currently playing video segment.
Returns the time range that is currently valid for seeking.
Note For VOD default mode is RelativeTime and for Live it is AbsoluteTime.
Optional mode: MKTimeModeThe mode to decide if the returned time should be absolute or relative, see MKTimeMode.
the current seekable range when available or null otherwise.
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.
the media time for which the thumbnail should be returned.
A thumbnail if a thumbnails track is configured and a thumbnail exists for the specified time, else null.
Returns the currently selected video quality, if the user manually selected one.
In this case it returns one of the elements of getAvailableVideoQualities.
Gets the active MKViewMode.
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.
Tests if a particular ViewMode is available for selection with setViewMode.
the view mode to test.
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.
the source configuration object.
Optional disableSeeking: booleanIf set, seeking will be disabled.
Promise which resolves when the source is loaded and rejects when load fails.
Removes a handler for a player event.
The event to remove the handler from.
The callback handler to remove.
Subscribes an event handler to a player event.
The type of event to subscribe to.
The event callback handler that will be called when the event fires.
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.
Optional issuer: stringthe issuer of the API call that will be passed to events triggered by this call.
a promise which resolves as soon as playback starts. The promise can reject if the play is blocked by the browser.
Reload the currently playing source.
Note:
start parameter is only supported for Live or Event asset types.startOffset must be positive value bewtween 0 and duration of the VOD asset and no startOffsetTimelineReference must be set.startOffset for bookmark offset must always be an UNIX Epoch absolute timestamp and no startOffsetTimelineReference must be set.For more details, please refer to notes for startOffset.
Examples
To reload the same source
reload()
To reload same source and start at bookmark offset
reload(undefined, {startOffset: 120});
To reload same source and start 5 minutes behind live edge for live
reload(undefined, {startOffset: -300, startOffsetTimelineReference: "end"});
To reload the same source and start at a specified bookmark offset (absolute timestamp) for live
reload(undefined, {startOffset: 1692268911.789})
To reload with a new start time for live and start at the live edge
reload("2023-06-28T10:00:00Z");
// OR
reload("2023-06-28T10:00:00Z", {"startOffset": 0, "startOffsetTimelineReference": "end"});
To reload with a new start time for live and start at the beginning
reload("2023-06-28T10:00:00Z", {"startOffset": 0, "startOffsetTimelineReference": "start"});
To reload with a new start time for live and start at the specified startOffset
const currentTime = player.getCurrentTime(); // current time used for example
reload("2023-06-28T10:00:00Z", {"startOffset": currentTime});
Optional start: stringISO Date string in the format 2023-06-27T10:00:00Z
Optional sourceOptions: MKSourceOptionssource options specifying start offset and timeline reference.
Seeks to the given playback time specified by the parameter time in seconds.
The time offset specified must always be a positive value and within the current getSeekableRange.
For Live and Events the specified time either be relative or absolute offset.
seek(0) will take you to the start of the live windowseek(getSeekableRange().end) will take you near the current live edge. You can also call () to jump to current live edge easily.The time to seek to in seconds.
Optional issuer: stringThe issuer of the API call that will be passed to events triggered by this call.
true when successful.
Sets the audio track to the ID specified by trackID.
Available tracks can be retrieved with getAvailableAudio.
The ID of the audio track to activate.
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.
The ID of the desired audio quality or 'auto' for dynamic switching.
Sets the configuration specifying parameters for latency catchup.
the sync configuration for latency catchup.
Sets the configuration specifying parameters for latency fallback.
the sync configuration for latency fallback.
Set HTTP headers.
Header keys are case sensitive, chaning cases may result in duplicate entires in the headers.
Note: To update STS authToken for the registered source, you must call updateAuthToken. You should only set other custom headers required from here.
HTTP headers to be used with requests and when null is passed the set headers will be cleared.
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.
the new inhome status value.
Set/Remove 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. Also if needed to remove the old location detail, pass null or empty string.
the new location details as base64 encoded string or null / '' to remove old one.
Sets the level of player log outputs.
Log level, allowed values are "debug", "log", "warn", "error" and "off"
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.
A playback speed factor greater than 0.
Sets a poster image. Will be displayed immediately, even if a video stream is playing.
The URL to the poster image.
Flag to set the poster image persistent so it is also displayed during playback (useful for audio-only playback).
Sets the target buffer level for the chosen buffer and media type.
the buffer type to change the target buffer level for.
the value to set.
the media type to change the target buffer level for.
Sets the target latency to be maintained during playback.
Causes firing a TargetLatencyChanged event.
the target latency in seconds.
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);
the video element to set.
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.
ID defined in the Manifest/MPD or 'auto'.
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.
the view mode to switch the player into.
Optional options: MKViewModeOptionsadditional optional parameters for view modes.
Sets the player’s volume in the range of 0 (silent) to 100 (max volume). Unmutes a muted player.
The volume to set between 0 and 100.
Optional issuer: stringThe issuer of the API call that will be passed to events triggered by this call.
Update STS authToken.
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.
the new authorization token.
MKPlayer API.
Defines the API's supported by MKPlayer.