Skip to content

Loading and playing content

Pass a source configuration object to player.load() to load content into an initialised player. You can then control playback or destroy the player instance when it is no longer needed.

You have an initialised MKPlayer instance. See Installation and setup.

Build a MKSourceConfig object that describes your content, then call player.load():

const sourceConfig = {
title: "My Stream",
description: "A brief description of the content",
poster: "https://my-cdn.com/mysource/poster.png",
hls: "https://my-cdn.com/mysource/hls/index.m3u8",
dash: "https://my-cdn.com/mysource/dash/manifest.mpd"
};
player.load(sourceConfig)
.then(() => {
console.log("Source loaded successfully");
})
.catch((error) => {
console.error("Source load failed: ", error);
});

Pass only one stream type in the source configuration: either hls or dash. When both are present, the player selects based on platform support.

For DRM-protected content, you also need to pass a drm property. See DRM protection.

PropertyTypeDescription
titlestringDisplay title for the source.
descriptionstringBrief description of the source.
posterstringURL to a poster image shown before playback starts.
hlsstringURL to an HLS master playlist.
dashstringURL to a DASH manifest.
drmMKDrmConfigDRM configuration for protected content. See DRM protection.
subtitleTracksMKSubtitleTrack[]External subtitle tracks to register with the player.
enableLowLatencybooleanEnables low-latency mode for live streams.
assetTypeMKAssetTypeRequired for registered sources. Values: live, event, catchup, dvr, vod.

After a source is loaded, use the player API to control playback:

// Start or resume playback
player.play();
// Pause
player.pause();
// Seek to a position (seconds)
player.seek(30);
// Set volume (0–100)
player.setVolume(80);
// Mute and unmute
player.mute();
player.unmute();
// Set playback speed (HTML5 player only)
// Values between 0 and 1 are slow motion; values above 1 are fast forward
player.setPlaybackSpeed(1.5);

To stop playback and clear the current source without destroying the player instance:

player.unload()
.then(() => {
console.log("Source unloaded");
})
.catch((error) => {
console.error("Unload failed: ", error);
});

You can call player.load() again after unload() to play a different source.

To tear down the player entirely and release all held resources:

player.destroy();

You must create a new MKPlayer instance after calling destroy(). Calling a player API method after destroy() returns a PLAYER_API_NOT_AVAILABLE error.

It is recommended to wait for the Destroy event before discarding your player reference:

player.on(mkplayer.MKPlayerEvent.Destroy, () => {
console.log("Player destroyed and resources released");
player = null;
});
player.destroy();
© 2025–2026 MediaKind. All rights reserved.