Skip to content

Loading and playing content

Once you have an initialised player instance, you load content by passing a source configuration object to player.load(). This page covers loading a source, controlling playback, and tearing down the player when you are done.

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);
});

It is recommended to pass only one stream type — either hls or dash — in the source config. 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(). Do not call any player API methods after destroy() — you will receive 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();
© 2026 MediaKind. All rights reserved.