Radiant Media Player

API Documentation


Documentation sections


Introduction

Radiant Media Player provides a complete JavaScript API to programmatically control the player, allowing for custom applications to be built on top of the player.

As a start point you may review our implementation example here:

Player API demo

For our ads API please visit this link.


Set up

A basic example of player API usage will look like:

<!-- Include Radiant Media Player JavaScript file in your <body> or <head> -->
<script src="https://cdn.radiantmediatechs.com/rmp/5.0.8/js/rmp.min.js"></script>
<!-- Player container element -->
<div id="rmpPlayer"></div>
<!-- Set up player configuration options -->
<script>
// Your streaming source - in this example HLS
var src = {
  hls: 'https://your-hls-url.m3u8'
};
// Your player settings
var settings = {
  licenseKey: 'your-license-key',
  src: src,
  width: 640,
  height: 360,
  poster: 'https://your-poster-url.jpg'
};
// Reference to player container
var elementID = 'rmpPlayer';
// Object creation
var rmp = new RadiantMP(elementID);
// Player container which will receive API events
var rmpContainer = document.getElementById(elementID);
rmpContainer.addEventListener('ready', function() {
  console.log('player ready');
  // Invoke API methods
  console.log(rmp.getStreamType());
});
rmpContainer.addEventListener('playing', function() {
  console.log('player has received playing event');
  rmp.setBitrate(0);
});
// Player initialisation - only after API events are registered
rmp.init(settings);
</script>
<!-- Add a player container with a unique id -->
<div id="rmpPlayer"></div>
<!-- Set up async player configuration options -->
<script>
  // Your streaming source - in this example HLS
  var src = {
    hls: 'https://your-hls-url.m3u8'
  };
  // Your player settings
  var settings = {
    licenseKey: 'your-license-key',
    src: src,
    width: 640,
    height: 360, 
    poster: 'https://your-poster-url.jpg',
    asyncElementID: 'rmpPlayer'
  };
  // We push player settings to a global rmpAsyncPlayers variable
  if (typeof window.rmpAsyncPlayers === 'undefined') {
    window.rmpAsyncPlayers = [];
  }
  window.rmpAsyncPlayers.push(settings);
  // we wire our events on player container
  var rmpContainer = document.getElementById(settings.asyncElementID);
  var rmp = null;
  // To get access to the player instance we need to wait for rmpasyncplayerinstanceavailable event (first event to fire in the API)
  rmpContainer.addEventListener('rmpasyncplayerinstanceavailable', function () {
    // player instance is stored in a global array variable rmpAsyncPlayerInstances
    rmp = window.rmpAsyncPlayerInstances[0];
  });
  rmpContainer.addEventListener('ready', function () {
    console.log('player ready');
      // Invoke API methods
    console.log(rmp.getStreamType());
  });
  rmpContainer.addEventListener('playing', function () {
    console.log('player has received playing event');
    rmp.setBitrate(0);
  });
</script>
<script async src="https://cdn.radiantmediatechs.com/rmp/5.0.8/js/rmp.min.js"></script>

Player API events

Below is a list of events that are dispatched by Radiant Media Player.

You must attach your listener to the player container before calling the player init method - otherwise you may miss some!

Events are registered with the native JavaScript addEventListener method applied to the player container: rmpContainer as shown above. They are unregistered with the removeEventListener method. You must use named function to use the removeEventListener method, anonymous functions will not be removed.

All events fired by the player API are non-bubbling events.

General player events

In this section the element refers to HTML5 media element and user agent to the browser or WebView rendering the media.

  • ready the player is ready to receive calls from the API and is appended to DOM
  • play the element is no longer paused. Fired after the play() method has returned, or when the autoplay attribute has caused playback to begin
  • pause the element has been paused
  • timeupdate the current playback position changed as part of normal playback or in an especially interesting way, for example discontinuously
  • ended playback has stopped because the end of the media resource was reached
  • loadstart the user agent begins looking for media data, as part of the resource selection algorithm
  • loadedmetadata the user agent has just determined the duration and dimensions of the media resource and the text tracks are ready
  • durationchange the media duration has just been updated
  • loadeddata the user agent can render the media data at the current playback position for the first time
  • progress the user agent is fetching media data
  • canplay the user agent can resume playback of the media data, but estimates that if playback were to be started now, the media resource could not be rendered at the current playback rate up to its end without having to stop for further buffering of content.
  • canplaythrough the user agent estimates that if playback were to be started now, the media resource could be rendered at the current playback rate all the way to its end without having to stop for further buffering
  • bufferstalled current buffer is empty - media playback is stopped until enough buffer has been downloaded to resume playback
  • buffernotstalledanymore player has resumed playback after a bufferstalled event (e.g. it exits buffering state)
  • waiting playback has stopped because the next frame is not available, but the user agent expects that frame to become available in due course. For buffer information use bufferstalled event instead.
  • playing playback is ready to start after having been paused or delayed due to lack of media data. For buffer information use buffernotstalledanymore event instead.
  • seeking fires when the player starts seeking to a new position in the media
  • seeked fires when the player is finished seeking to a new position in the media
  • volumechange fires when the player changes its volume
  • enterfullscreen fires when the player enters fullscreen mode
  • exitfullscreen fires when the player enters exitfullscreen mode
  • stopcompleted fires when stop API method has completed
  • firstframe fires when first frame of content or pre-roll ad (whichever comes first) is shown in the player
  • startuptimeavailable fires when startup time analytics data is available
  • resize fires when player is resizing
  • htmlmediaelementappendedtodom fires when the HTML5 media element (video or audio tag) has been appended to DOM after init has been called on player. This event fires before ready event. The HTML5 media element can be accessed through the getHtmlMediaElement API method.
  • rmpasyncplayerinstanceavailable fires when the Radiant Media Player instance is created when the player core library is async loaded. See usage example here.

Native HLS specific events

This applies to using native HLS streaming to HTML5 video on iOS and macOS Safari

  • hlslevelswitching fires when a level switch is requested (auto mode only)

hls.js specific events

  • hlsinstancecreated fires when the hls.js instance has been created
  • hlsmanifestloaded fires when the player has finished loading the main HLS manifest
  • hlsmanifestparsed fires when the player has finished parsing the main HLS manifest
  • hlslevelloaded fires when the player has finished loading a level
  • hlsfragmentloaded fires when the player has finished loading a fragment
  • hlsfragmentbeingplayedchanged fires when the fragment being rendered within the player changes
  • hlslevelswitching fires when a level switch is requested (manual or auto mode)
  • hlslevelswitched fired when a level switch is effective (manual or auto mode)
  • hlsaudiotrackswitching fires when an audio track switch is requested
  • hlsaudiotrackswitched fires when an audio track switch actually occurs
  • hlssubtitletrackswitch fires when a subtitle track switch occurs
  • hlsid3tagparsingcompleted fires when parsing id3 metadata has completed. You can get id3 metadata with the getHlsId3TagSamples method. See our HLS with ID3 frames documentation page for more information.
  • hlsprogramdatetimeavailable data from the #EXT-X-PROGRAM-DATE-TIME tag has been updated and is available - use getHlsEpochProgramDateTime and getHlsRawProgramDateTime methods to access the program-date-time value

The above events will not fire when native HLS is used by the player (e.g. on iOS & macOS Safari)

Shaka Player (DASH or HLS) specific events

  • shakainstancecreated fires when the Shaka player instance has been created
  • shakatrackschanged fires when the list of tracks changes - for example, this will happen when changing periods or when track restrictions change
  • shakalevelswitching fires when a level switch is requested (manual or auto mode)
  • shakaaudiotrackswitching fires when an audio track switch is requested

Player API read-only methods

Unless stated otherwise the following API read-only methods must be queried after the ready event has fired.

General player API read-only methods

getReady()
rmp.getReady();

This method returns a Boolean indicating if the player is ready or not.

getPlayerVersion()
rmp.getPlayerVersion();

This method returns a String representing the current player version (MAJOR.MINOR.PATCH as in Semantic Versioning). null is returned if version is not available.

getHtmlMediaElement()
rmp.getHtmlMediaElement();

This method returns a HTMLMediaElement, the HTML5 video or audio tag used by Radiant Media Player. This method can be queried when the htmlmediaelementappendedtodom event fires. null is returned if the HTMLMediaElement is not available.

getPaused()
rmp.getPaused();

This method returns a Boolean representing the state of the media content either paused or playing. true means the content on stage is currently paused.

getCurrentTime()
rmp.getCurrentTime();

This method returns a Number expressed in milliseconds representing the current playback position in the media content. -1 is returned in case the value is not available.

getDuration()
rmp.getDuration();

This method returns a Number expressed in milliseconds representing the total duration of the media content. -1 is returned in case the value is not available. Note that on some mobile devices the duration may only be available after a successful play event.

getPlayerMode()
rmp.getPlayerMode();

This method returns a String representing the mode in which the player is rendered: 'html5', 'nosupport' or '' if not available.

getStreamType()
rmp.getStreamType();

This method returns a String representing the currently loaded streaming protocol: 'hls', 'hlsHevc', 'dash', 'mp4', 'mp4Hevc', 'webm', 'm4a', 'mp3', 'ogg', 'outstream' or '' if not available.

getBufferLength(type)
rmp.getBufferLength('ahead');
rmp.getBufferLength('behind');

This method returns a Number expressed in milliseconds representing the current player buffer. It takes an input String parameter which must either be 'ahead' (this would return the buffer ahead value) or 'behind' (this would return the buffer behind value, also known as back-buffer). -1 is returned in case this value is not available. This works for HLS, DASH or progressive download.
An example of implementation of the buffer API can be viewed here.

getLoop()
rmp.getLoop();

This method returns a Boolean stating if the player is in loop mode or not. true means the player automatically jumps back to start and continue playback when content completes.

getControls()
rmp.getControls();

This method returns a Boolean stating if the default player controls are available or not. true means the default player controls are available.

getControlsVisible()
rmp.getControlsVisible();

This method returns a Boolean stating if the default player controls are currently visible or not. true means the default player controls are visible.

getAdUI()
rmp.getAdUI();

This method returns a Boolean stating if the player advertisement UI is currenlty shown or hidden. true means the advertisement UI is visible.

getWaitingUI()
rmp.getWaitingUI();

This method returns a Boolean stating if the player is in waiting mode while displaying its waiting UI. true means the player is in waiting mode. null is returned in case this value is not available.

getFullscreen()
rmp.getFullscreen();

This method returns a Boolean representing the current state of the player. true means the player is in fullscreen mode.

getVolume()
rmp.getVolume();

This method returns a Number representing the current player volume (between 0 and 1). -1 is returned if this value is not available.

getMute()
rmp.getMute();

This method returns a Boolean stating if the player is currently muted or not. true means player is muted. null is returned in case this value is not available.

getContentTitle()
rmp.getContentTitle();

This method returns a String representing the content title. An empty string is returned if this value is not available.

getVideoTitle()
rmp.getVideoTitle();

This method returns a String representing the current HTML5 media element title attribute (applies only to iOS). (see videoTitle setting). An empty string is returned if this value is not available

getContentDescription()
rmp.getContentDescription();

This method returns a String representing the content description. An empty string is returned if this value is not available.

getContentID()
rmp.getContentID();

This method returns a String with the current contentID set for the player (or the content displayed). An empty string is returned if this value is not available.

getAppName()
rmp.getAppName();

This method returns a String with the current appName set for the player. An empty string is returned if this value is not available.

getPoster()
rmp.getPoster();

This method returns a String representing the path or URL to the player poster frame.

getPlayerWidth()
rmp.getPlayerWidth();

This method returns a Number representing the current width in pixels of the player.

getPlayerHeight()
rmp.getPlayerHeight();

This method returns a Number representing the current height in pixels of the player.

getEnvironment()
rmp.getEnvironment();

This method returns an Object representing the current environment (e.g. feature detection & type of device) in which Radiant Media Player is rendered. Example to detect a mobile device:

var env = rmp.getEnvironment();
var isMobile = env.isMobile;
var isAndroid = env.isAndroid[0];
var isIos = env.isIos[0];
var isWebView = env.isWebView;
var isMacosSafari = env.isMacosSafari[0];

See a full example of output here. This is an advanced method which is mainly used by the player internally and provided as indication as you may see it in some of our code examples. Note that this method can be used before calling init on player.

getFramework()
rmp.getFramework();

This method returns an Object representing the internal player framework. This framework is written with native JavaScript (e.g. it does not depend on a third party library like jQuery or Lodash). Example to add a class to an HTML element:

var rmpFW = rmp.getFramework();
rmpFW.addClass(element, 'custom-class');;

This is an advanced method which is mainly used by the player internally and provided as indication as you may see it in some of our code examples. Note that this method can be used before calling init on player.

getPlayerSettings()
rmp.getPlayerSettings();

This method returns an Object representing all available player settings and respective default values. The output of this method can be viewed online here.

getPreload()
rmp.getPreload();

This method returns a String representing the preload mode used for player start up. This method is only available after ready event has fired, '' is returned otherwise.

getBitrates()
rmp.getBitrates();

This method returns an Array representing available renditions for the current streaming source. This method is available for HLS, DASH and progressive download. null is returned if this value is not available. Each element of the returned Array is an Object holding information about the current rendition. The Object is as follows:

{
  active: true, // Boolean: if the current audio track active or not
  audioCodec: "mp4a.40.2", // String: the audio codec name when available
  bitrate: 727221, // Number: the bandwidth in bps required to the play the current rendition
  height: 360, // Number: the height in px of the rendition (not available for audio-only feed)
  id: 0, // Number: the bitrate id
  videoCodec: "avc1.4d401e", // String: the video codec name when available (not available for audio-only feed)
  width: 640 // Number: the width in px of the rendition (not available for audio-only feed)
}

The active property of each rendition can be queried in order to know which rendition is currently played in the player.

For progressive download only the active and id properties of a rendition object will be available.

For native HLS (default on iOS and macOS Safari) this method will return null as rendition details are not made available by the browser.

For audio-only streams this method should be used to get the different renditions of a stream with the same language information. The getAudioTracks method should only be used to get information about audio tracks that have different language data.

getCurrentBitrateIndex()
rmp.getCurrentBitrateIndex();

This method returns a Number representing the index of the rendition currently being played within the player. -2 is returned if this information is not available. This method works for MSE-based HLS, DASH and progressive download. For HLS or DASH -1 is returned if the player is in ABR auto-mode.

getAbrAutoMode()
rmp.getAbrAutoMode();

This method returns a Boolean stating if the player is in ABR auto mode (true) or not (false).

getAudioTracks()
rmp.getAudioTracks();

This method returns an Array representing the loaded audio tracks for the current HLS or DASH stream. For HLS only independent audio tracks (e.g. with a dedicated .m3u8 rendition) will be returned. null is returned if this information is not available. Each element of the returned Array is an Object holding details about the related audio track. The Object is as follows:

{
  active: true, // Boolean: if the current audio track active or not
  id: 0, // Number: the audio track id
  language: "en" // String: language code for the audio track
}

The id property from the Object of each Array item can be used with the setAudioTrack method to select a specific audio track.

With HLS the audio track API is not available on iOS or macOS Safari as Apple does not currently provide the required MSE API to enable this feature. With HLS on iOS or macOS Safari audio tracks can be selected when the player is in fullscreen mode (using the Apple provided tracks menu).


Player API methods

The following methods must be called after the ready event has fired.

play() asynchronous
rmp.play();

When invoked, this method will cause the player to start playback or resume it if it was paused. playing event will fire when playback starts/resumes.
On mobile devices this method must be called within a user interaction callback (touchend event generally) to start initial playback.
Do not use play method to force or emulate autoplay - instead use autoplay setting as described here.

pause()
rmp.pause();

When invoked, this method will cause the player to pause playback.

stop() asynchronous
rmp.stop();

When invoked, this method will cause the player to pause playback returning its playhead to 0 (for on-demand content) and show the current poster. If a video ad is on stage the player will first discard the ad and then reach the stop state. stopcompleted event will fire when stop method has completed.

seekTo(ms) asynchronous
rmp.seekTo(5000);

When invoked, this method will cause the player to seek to the value indicated as parameter. Parameter value is a Number expressed in milliseconds. Note that milliseconds accurate seeking is not guaranteed as it depends on the browser implementation of the HTML5 media currentTime property. Most of the time you can expect a 100 ms precision with modern browsers. This method will have no effect if an ad is playing on stage or with a live stream. seeked event will fire when seekTo method has completed.

setVolume(volume)
rmp.setVolume(0.8);

When invoked, this method will change the volume level of the player audio track. Parameter value is a Number ranging from 0 to 1.
An example of implementation of the mute/volume API can be viewed here.
Do not use the setVolume API method to set initial player volume when ready event fires - instead use initialVolume player setting.

setMute(muted)
rmp.setMute(true);

When invoked, this method will cause the player to enter or exit mute mode based on the input parameter. Parameter should be a Boolean with true meaning the mute mode should be engaged and false the mute mode should be disengaged.
An example of implementation of the mute/volume API can be viewed here.

setLoop(loop)
rmp.setLoop(true);

When invoked, this method will change the player loop mode. Parameter value is a Boolean. When set to true it will enabled loop mode. When set to false it will disable it.

resize() asynchronous
rmp.resize();

When invoked, this method will force the player to resize itself based on its new context dimension. resize event will fire when this method has completed.

setPlayerSize(width, height) asynchronous
rmp.setPlayerSize(960, 540);

When invoked, this method will dynamically resize the player to the provided width and height parameters. The width and height parameters must be Number representing pixels. This method will have no effect with autoHeightMode and iframeMode player settings or when player is in fullscreen. resize event will fire when this method has completed.

setContentTitle(title)
rmp.setContentTitle('Hello RMP!');

When invoked, this method updates the current content title. Input must be a String.

setVideoTitle(title)
rmp.setVideoTitle('Hello RMP!');

When invoked, this method updates the HTML5 media element title attribute (applies only to iOS - see videoTitle setting). Input must be a String.

setContentDescription(description)
rmp.setContentDescription('This is a good day today.');

When invoked, this method updates the current content description. Input must be a String.

setPoster(posterUrl)
rmp.setPoster('https://your-poster-url.jpg');

This methods takes a URL String parameter and updates the player with this new poster.

showPoster()
rmp.showPoster();

This methods causes the current player poster to be displayed on stage.

hidePoster()
rmp.hidePoster();

This methods causes the current player poster to be hidden from the stage.

setControls(controls)
rmp.setControls(false);

This method permanently hide player controls (input setting set to false) or enable player controls (input setting set to true). Input parameter must be a boolean.

setControlsVisible(controls)
rmp.setControlsVisible(false);

This method fades in (input setting set to true) or fades out (input setting set to false) player controls. Input parameter must be a boolean.

setAdUI(adUI)
rmp.setAdUI(false);

This method hides (input parameter set to false) or shows (input parameter set to true) the advertisement UI - overriding the default player controls. Input parameter must be a boolean.

setWaitingUI(adUI)
rmp.setWaitingUI(true);

This method hides (input parameter set to false) or shows (input parameter set to true) the player waiting UI. Note that the player may internally still decides to hide or show the waiting UI. Input parameter must be a boolean.

setFullscreen(fs) asynchronous
rmp.setFullscreen(true);

When invoked, this method will order the player to enter or exit fullscreen based on input parameter. Input parameter must be a Boolean. enterfullscreen, or exitfullscreen or warning (with code 1003) event will fire when this method has completed.
The player may only enter fullscreen through the setFullscreen API method as a result of a valid user interaction. Modern browsers generally block entering full screen programmatically.

setBitrate(index)
rmp.setBitrate(0);

This method allows to set the current rendition for the player based on an index value. Input parameter must be a Number. For HLS and DASH streaming, index at 0 will cause the player to play the lowest rendition available. This method has no effect if called when a linear ad is playing on stage or if input index is out of bound. See getBitrates method to get information about available renditions and to determine which rendition is currently active.

This method is available HLS, DASH and progressive download.

For HLS and DASH streaming, rmp.setBitrate(-1) will restore the player to its 'auto' ABR mode.

For native HLS (default on iOS and macOS Safari) this method will have no effect.

An example of implementation of the bitrate API can be viewed here.

setAudioTrack(id)
rmp.setAudioTrack(1);

This method set the current HLS or DASH audio track being read by the player. The id (Number) parameter represents the id of the audio track within the available audio tracks (see getAudioTracks method).

isWebView()
rmp.isWebView();

This method returns a boolean stating if the player is currently used in an Android or iOS WebView or not, null if not available.

isStandalone()
rmp.isStandalone();

This method returns a boolean stating if the player is currently used in an Android or iOS standalone web-application or not, or null if not available.

hasHevcSupport()
rmp.hasHevcSupport();

This method returns a boolean stating if the player supports HEVC (H.265 video) with HTML5 video and media source extensions, or null if not available.


Changing player source

An example of implementation of the src API can be viewed here.

src API events

  • srcchanged: fires when the player has finished changing its source media URI
  • srcchanging: fires when the player starts changing its source media URI
  • error: fires when the player was not able to change source due to a fatal error when trying to load the new source - see error management page to get details about the error - upon an error event, the setSrc method can still be invoked with a new source to attempt recovery from the error

src API methods

getSrc()
rmp.getSrc();

This method returns a String representing the URI for the current player media source.

setSrc(newSourceObject) asynchronous
var newSourceObject = {
  hls: 'https://your-hls-url.m3u8',
  mp4: [
    'https://your-mp4-sd-url.mp4',
    'https://your-mp4-hd-url.mp4'
  ]
};
rmp.setSrc(newSourceObject);

This method updates the current player media source with the provided Object input parameter. The input Object properties must match the initial settings.src properties provided to the player when initialised. For example if you initialised the player with HLS you must pass an object with HLS information (e.g. you cannot pass a MP4-only URI if the player was initialised with HLS-only URI). Failure to do so could result in unwanted errors. If you need to change the source type for the player you need to destroy the current player instance and re-create a new one, however it should be noted that using the setSrc method and other methods described in this page are preferred over using the destroy method, which should only be used when you are done using the player on your page. When setSrc is called with a valid input Object parameter, the player will clear its current buffer, load the new media source and updates its UI (including bitrate informations, audio-tracks and in-manifest text tracks). When source change has completed the srcchanged event fires. Also see the srcChangeAutoplay player setting.

The setSrc method is not supported with 360 video or DASH/HLS DRM setup.

isChangingSrc()
rmp.isChangingSrc();

Since setSrc runs asynchronously you may want to check if it is running before usage. This method returns a Boolean stating if setSrc is currently running or not. If setSrc is running, invoking setSrc will have no effect and a 1005 warning event will fire.


Destroying player instance

An example of implementation of the destroy API can be viewed here.

When you are done using the player on your page and want to release memory/CPU resources you can call the destroy API method.

While it is technically possible to use destroy to update an existing player instance with a new one, we generally do not recommend using this approach. Consider using the setSrc or other API methods described in our documentation to update your player instance.

destroy API events

  • destroycompleted fires when the player has finished destroying its instance (using the destroy method)

destroy API methods

destroy() asynchronous
rmp.destroy();

This method destroys the current player instance, removing listeners and emptying player buffer. The player container is thus ready for removal from DOM when destroycompleted event fires. If destroy is running, invoking destroy will have no effect and a 1004 warning event will fire.


hls.js specific methods

The following API methods are only available when streaming HLS through hls.js in Radiant Media Player, they do not apply when using native HLS or HLS through Shaka player.

getHlsJSInstance()
rmp.getHlsJSInstance();

This method returns an Object representing the hls.js instance created by the player. This instance is available when the hlsinstancecreated event fires. null is returned if this value is not available.

getHlsId3TagSamples()
rmp.getHlsId3TagSamples();

This method returns an Object representing the latest parsed ID3 metadata in an HLS stream. It is updated when the hlsid3tagparsingcompleted event fires. null is returned if this value is not available. See our HLS with ID3 frames documentation page for more information and a usage example.

getHlsManifestData()
rmp.getHlsManifestData();

This method returns an Array representing the HLS manifest data. It can be queried when the hlsmanifestloaded event fires. null is returned if this value is not available. It holds information about each level found in the manifest. Each item of this Array is made of an Object with information about a specific level as follows:

{
  url: [ 'http://levelURL.com', 'http://levelURLfailover.com' ], // level URL
  bitrate: 246440, // level bitrate
  name: "240", // level name
  codecs: "mp4a.40.5,avc1.42000d", // used codecs
  width: 320, // video width
  height: 136 // video height
}
getHlsLevelData()
rmp.getHlsLevelData();

This method returns an Object representing the currently loaded level. It can be queried when the hlslevelloaded event fires. null is returned if this value is not available. The returned Object is as follows:

{
  version: 3, // HLS version
  type: 'VOD', // playlist type
  startSN: 0, // start sequence number
  endSN: 50, // end sequence number
  totalduration: 510, // level total duration
  targetduration: 10, // level fragment target duration
  fragments: Array(51), // array of fragments info
  live: false // is this level a live playlist or not
}
getHlsFragmentData()
rmp.getHlsFragmentData();

This method returns an Object representing the currently loaded fragment. It can be queried when the hlsfragmentloaded event fires. null is returned if this value is not available. The returned Object is as follows:

{
  duration: 10, // fragment duration
  level: 3, // level identifier
  sn: 35, // fragment sequence number
  start: 30, // fragment start offset
  url: 'http://fragURL.com' // fragment URL
}
getHlsFragmentBeingPlayedData()
rmp.getHlsFragmentBeingPlayedData();

This method returns an Object representing the fragment currently being rendered by the player. This is generally used in conjunction with the hlsfragmentbeingplayedchanged event. null is returned if this value is not available. The returned Object is of the same format as with the getHlsFragmentData method.

getHlsEpochProgramDateTime()
rmp.getHlsEpochProgramDateTime();

This method returns a Number representing the #EXT-X-PROGRAM-DATE-TIME in universal (epoch) milliseconds time. It can be queried when the hlsprogramdatetimeavailable event fires. -1 is returned if this information is not available.

getHlsRawProgramDateTime()
rmp.getHlsRawProgramDateTime();

This method returns a Date representing the #EXT-X-PROGRAM-DATE-TIME as a Date object. It can be queried when the hlsprogramdatetimeavailable event fires. null is returned if this information is not available.

getHlsBwEstimate()
rmp.getHlsBwEstimate();

This method returns a Number representing the real-time available device bandwidth captured by the player in bps. -1 is returned if this information is not available.

hlsStartLoad()
rmp.hlsStartLoad();

This method allows to start/restart the playlist/fragment loading process. This method should only be queried after the hlsmanifestparsed event has fired.

hlsStopLoad()
rmp.hlsStopLoad();

This method allows to stop the playlist/fragment loading process. This can be useful to better manage the HLS loading mechanism and to save bandwidth when the loading of new fragments is not needed anymore. When the playlist/fragment loading process has been stopped it can be resumed with the hlsStartLoad method. When hlsStopLoad is requested be mindful to always call hlsStartLoad when the viewer requests playback again so as to resume the fragment loading process - otherwise the player may stop working as expected due to the lack of new fragments for rendering.


Shaka player specific methods

The following API methods are only available when streaming DASH or HLS through Shaka player in Radiant Media Player.

getShakaPlayerInstance()
rmp.getShakaPlayerInstance();

This method returns an Object representing the Shaka player instance created by the player. This instance is available when the shakainstancecreated event fires. null is returned if this value is not available.


Accessing the HTMLMediaElement, hls.js or Shaka Player instances

Some advanced use-cases may require access to the HTMLMediaElement, hls.js or Shaka Player instances that Radiant Media Player dynamically creates when needed. The example below show how this can be achieved through our player API:

var elementID = 'rmpPlayer';
var rmp = new RadiantMP(elementID);
var container = document.getElementById(elementID);
// We wire our events before calling init
container.addEventListener('hlsinstancecreated', function() {
  var hlsJSInstance = rmp.getHlsJSInstance();
  console.log(hlsJSInstance);
});
container.addEventListener('shakainstancecreated', function() {
  var shakaPlayerInstance = rmp.getShakaPlayerInstance();
  console.log(shakaPlayerInstance);
});
// this is the recommended method to access the HTML5 media element 
// dynamically created by Radiant Media Player
container.addEventListener('htmlmediaelementappendedtodom', function() {
  var videoTag = rmp.getHtmlMediaElement()
  console.log(videoTag);
});
// as an alternative you may use the following to access the HTML5 media element
var videoTagInterval = setInterval(function() {
  var rmpVideoTags = document.getElementsByClassName('rmp-video');
  if (rmpVideoTags.length > 0) {
    clearInterval(videoTagInterval);
    var videoTag = rmpVideoTags[0];
    console.log(videoTag);
  }
}, 100);
rmp.init(settings);
  • The hls.js instance corresponds to var hls = new Hls(config); as described here.
  • The Shaka Player instance corresponds to var player = new shaka.Player(video); as described here.

API usage examples

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 3.0 License.