Radiant Media Player

HLS streaming



Documentation sections


HLS support in Radiant Media Player

Radiant Media Player provides a comprehensive and cross-device solution to display HLS streams for on-demand, live or DVR content. Our HLS to HTML5 video & audio implementation relies on media source extensions (MSE) and is based on hls.js. Where media source extensions are not available (e.g. iOS, older Android) we fallback to native HLS to HTML5 video.

A standard-compliant HLS streaming URL is all you need - the player will take care of opting for the best way to render it based on device capabilities.


Supported HLS features

  • Playback of H.264 + AAC in .ts fragments
  • Playback of H.264 + AAC in fmp4 fragments (CMAF / fragmented MP4 container)
  • Playback of H.265 (HEVC) + AAC in fmp4 fragments (CMAF / fragmented MP4 container) where supported
  • Playback of H.264 + MP3 content in .ts fragments (with the limitation of no Internet Explorer 11 support)
  • Live, DVR and on-demand video streaming
  • Optimized adaptive bitrate streaming with automatic or manual bitrate selection
  • Multiple-audio tracks
  • AES-128/SAMPLE-AES decryption
  • ID3 tags
  • WebVTT & CEA 608/708 captions
  • Program-date-time
  • Discontinuities
  • Resilience to errors
  • Redundant/Failover Playlists
  • Audio-only: AAC container or MPEG Audio container (MPEG-1/2 Audio Layer III)
  • App-store compliant HLS streams playback (see hlsJSAppleAppStoreCompliance setting below for compliance notes)

Supported M3U8 tags

  • #EXTM3U
  • #EXTINF
  • #EXT-X-STREAM-INF (adaptive streaming)
  • #EXT-X-ENDLIST (Live playlist)
  • #EXT-X-MEDIA-SEQUENCE
  • #EXT-X-TARGETDURATION
  • #EXT-X-DISCONTINUITY
  • #EXT-X-DISCONTINUITY-SEQUENCE
  • #EXT-X-BYTERANGE
  • #EXT-X-MAP
  • #EXT-X-KEY
  • #EXT-X-PROGRAM-DATE-TIME

Supported environments

See our compatibility table for a list of environments where HLS streaming is supported with Radiant Media Player.


CORS requirements

You must set up your streaming server to return proper CORS settings permitting GET requests for HLS streaming to Radiant Media Player to work as expected.


Player code example

<!-- Include Radiant Media Player - here we use the optimised build for hls.js -->
<script src="https://cdn.radiantmediatechs.com/rmp/5.9.2/js/rmp-hlsjs.min.js"></script>
<!-- Player container element -->
<div id="rmpPlayer"></div>
<!-- Set up player configuration options -->
<script>
// Here we set our HLS streaming source
var src = {
  hls: 'https://your-hls-url.m3u8'
};
var settings = {
  licenseKey: 'your-license-key',
  src: src,
  width: 640,
  height: 360,
  contentMetadata: {
    poster: [
      'https://your-poster-url.jpg'
    ]
  }
};
var elementID = 'rmpPlayer';
var rmp = new RadiantMP(elementID);
rmp.init(settings);
</script>

HLS player settings


General

hlsJSCapLevelToPlayerSize: Boolean

This setting limits bitrates usable in auto-quality depending on player size (width & height). Default: true. If set to true, width and height (defined in m3u8 playlist) will be compared with the actual player width and height and only the best match will be used as the maximum available bitrate, hence helping to preserve bandwidth usage while maintaining streaming quality. This setting is ignored in manual mode so all levels can be selected manually. For 360 video this setting is always set to false.

hlsJSCapLevelOnFPSDrop: Boolean

This setting limits bitrates usable in auto-quality depending on framerate. Default: false. This feature is currently in beta and should only be used when dealing with HFR content (high frame rate > 30 fps) when addressing specific frame rate issues.

hlsJSStopDownloadWhilePaused: Boolean

When set to true this setting will cause the player to stop downloading HLS fragments while it is in a paused or stopped state. This can help to preserve bandwidth. Default: false.

hlsJSAppleAppStoreCompliance: Boolean
For App-store compliant HLS video streams which include an audio-only rendition this setting should be set to true to insure proper playback across devices. Default: false.
hlsJSMaxAudioFramesDrift: Number
See here for full details on this setting. You generally do not need to tweak this setting unless trying to solve specific audio issues with some exotic HLS streams. Default: 1.
hlsJSDefaultAudioCodec: String
If audio codec is not signaled in variant manifest, or if only a stream manifest is provided, the player will try to guess audio codec by parsing audio sampling rate in ADTS header. If sampling rate is less or equal than 22050 Hz, then the player assumes it is HE-AAC, otherwise it assumes it is AAC-LC. This could result in bad guess, leading to audio decode error, ending up in media error. It is possible to hint default audio codec to the player by setting hlsJSDefaultAudioCodec to:
  • 'mp4a.40.2': AAC-LC
  • 'mp4a.40.5': HE-AAC
  • 'auto': the player auto-guesses. This is the default.
hlsJSUseManifestRenditionName: Boolean
By default the player present renditions in the quality menu as "resolution · bitrate" pattern. Example: 400p · 1728 kbps. However a HLS manifest is also required to have a NAME attribute for each rendition. When set to true this setting will cause the player to display the NAME of the rendition in place of the "resolution · bitrate" default pattern. This also applies to audio tracks when multi-language audio tracks are available in a HLS manifest. Default: false.
forceHlsJSOnMacOSIpadOSSafari: Boolean

When set to true the player will force use hls.js on macOS and iPadOS Safari (where native HLS would be used generally). The main use case is to enable DVR controls, quality and multi-audio modules on macOS and iPadOS Safari. Note that setting forceHlsJSOnMacOSIpadOSSafari to true disables AirPlay casting support from macOS and iPadOS Safari as it requires native HLS or MP4 progressive download. Default: false. When forceHlsJSOnMacOSIpadOSSafari is set to true the only option to display video ads is the IMA SDK.

forceNativeHlsOverHlsJS: Boolean

When set to true the player will use native HLS support on the targeted device over Media Source Extensions HLS (provided both are detected as available). This can be useful in OTT environments where Media Source Extensions are known to be less efficient than native HLS (Fire TV, lower-end Android TV). Default: false.

manualSwitchingMode: String

Select what mode for manual bitrate switching should be used by the player (works for HLS and DASH). Available values are 'instant', 'smooth', 'conservative'. Default: 'smooth' which provides an intermediary setting between 'instant' (immediate) and 'conservative' (slow) bitrate switching.


Captions

hlsJSEnableCaptions: Boolean
This setting indicates to the player whether or not to parse and display CEA 608/708 or WebVTT captions when detected in an HLS stream. Default: true.
hlsJSCaptionsTextTrack1Label: String
Label for the text track generated for CEA-6/708 captions track 1. This is how it will appear in the player captions menu. Default: 'CC1'.
hlsJSCaptionsTextTrack2Label: String
Label for the text track generated for CEA-6/708 captions track 2. This is how it will appear in the player captions menu. Default: 'CC2'.

Live

hlsJSLiveSyncDurationCount: Number
Edge of live delay, expressed in multiple of EXT-X-TARGETDURATION. If set to 3, playback will start from fragment N-3, N being the last fragment of the live playlist. Decreasing this value is likely to cause playback stalls. Default: 3.
hlsJSLiveMaxLatencyDurationCount: Number
Maximum delay allowed from edge of live, expressed in multiple of EXT-X-TARGETDURATION. If set to 10, the player will seek back to hlsJSLiveSyncDurationCount whenever the next fragment to be loaded is older than N-10, N being the last fragment of the live playlist. If set, this value must be stricly superior to hlsJSLiveSyncDurationCount a value too close from hlsJSLiveSyncDurationCount is likely to cause playback stalls. Default: Infinity.
hlsJSLiveSyncDuration: Number
Alternative parameter to hlsJSLiveSyncDurationCount, expressed in seconds vs number of segments. If defined in the configuration object, hlsJSLiveSyncDuration will take precedence over the default hlsJSLiveSyncDurationCount. Default: undefined.
hlsJSLiveMaxLatencyDuration: Number
Alternative parameter to hlsJSLiveMaxLatencyDurationCount, expressed in seconds vs number of segments. If defined in the configuration object, hlsJSLiveMaxLatencyDuration will take precedence over the default hlsJSLiveMaxLatencyDurationCount. Default: undefined.
hlsJSInitialLiveManifestSize: Number
Number of segments needed to start a playback of a HLS live stream. Default: 1.
hlsJSLiveBackBufferLength: Number
Sets the maximum length of the buffer, in seconds, to keep during a live stream. Any video buffered past this time will be evicted. Infinity means no restriction on back buffer length; 0 keeps the minimum amount. The minimum amount is equal to the target duration of a segment to ensure that current playback is not interrupted. Default: Infinity.

XMLHttpRequest tuning

hlsJSFetchXhrWithCredentials: Boolean
This setting indicates to the player whether or not cross-site Access-Control requests should be made using credentials such as cookies, authorization headers or TLS client certificates. This applies to all requests (Fetch or XHR) made in the context of HLS streaming. Setting hlsJSFetchXhrWithCredentials has no effect on same-site requests. Default: false.

Retry parameters

retryParameters: Object

This represents an Object to pass to the player to specify specific retry parameters when attempting to load HLS content. The following example shows the default player parameters:

retryParameters: {
  manifest: {
    timeout: 10000, // timeout in ms, after which we abort a request
    maxTimeout: 64000, // maximum timeout in ms for all attempts before we fail
    maxAttempts: 2, // the maximum number of requests before we fail
    delay: 1000 // the base delay in ms between retries
  },
  levels: {
    timeout: 10000,
    maxTimeout: 64000,
    maxAttempts: 5,
    delay: 1000
  },
  segment: {
    timeout: 20000,
    maxTimeout: 64000,
    maxAttempts: 7,
    delay: 1000
  }
};

Custom config

You may pass to the player any parameter available with hls.js using the hlsJSCustomConfig setting:

hlsJSCustomConfig: Object

Allow passing a custom config object to hls.js. As such any hls.js internal setting can be tuned. Note that this may override any setting previously documented on this page. Default: {}. Example:

var hlsJSCustomConfig = {
  fragLoadingTimeOut: 20000,
  fragLoadingMaxRetry: 6,
  fragLoadingRetryDelay: 500,
  fragLoadingMaxRetryTimeout: 64000
};
var settings = {
  licenseKey: 'your-license-key',
  src: {
    hls: 'https://your-hls-url.m3u8'
  },
  width: 640,
  height: 360,
  hlsJSCustomConfig: hlsJSCustomConfig
};

See this page for a list of all hls.js options.


HLS ABR & buffer player settings

HLS is an adaptive bitrate streaming technology. Hence having a well-tuned ABR logic is important to insure a good user experience and reduce bandwidth cost. Radiant Media Player default ABR logic is tuned to work well in most common use-cases seen now-days. The following settings will let you tune the ABR/buffer logic to your environment. Only use those settings if you are trying to address a specific issue and fully understand what they do. Ill-configured ABR/buffer settings may cause a deteriorated user experience. Those settings are only applicable when streaming HLS through hls.js in Radiant Media Player, they do not apply when using native HLS.

hlsJSMaxBufferLength: Number

Maximum buffer length in seconds. The player will try to reach and never exceed this value for its internal buffer. Default: 30.

hlsJSStartLevel: Number
Defines the preferred initial bitrate when playback starts. Default: -1.
  • -1: automatic start level selection, playback will start from level matching download bandwidth (determined from download of first segment based on first level appearing in manifest) and information provided by rmp-connection when available.
  • n: where n is an integer will cause the player to select the n th level at startup (where 0 is the lowest quality).
Best practice: when hlsJSStartLevel is set to -1, your HLS manifest should include a lower-end rendition (generally this should not exceed 500 kbps audio & video included) and this rendition should be the first listed in your HLS manifest. This should provide optimal performance.
hlsJSMinAutoBitrate: Number
Set the minimum value (in bps) that should be used by the ABR algorithm. Default: 0. For example setting hlsJSMinAutoBitrate to 500000 means that the player - while in auto mode - will pick the best matching level that has a bitrate above or equal to 500000 bps (500 kbps).
hlsJSAbrBandWidthFactor: Number
Scale factor to be applied against measured bandwidth average, to determine whether we can stay on current or lower quality level. If hlsJSAbrBandWidthFactor * bandwidth average < level.bitrate then ABR can switch to that level providing that it is equal or less than current level. Default: 0.95.
hlsJSAbrBandWidthUpFactor: Number
Scale factor to be applied against measured bandwidth average, to determine whether we can switch up to a higher quality level. If hlsJSAbrBandWidthUpFactor * bandwidth average < level.bitrate then ABR can switch up to that quality level. Default: 0.75.

Native HLS support notes

On iOS & macOS Safari and older Android devices, we display HLS to HTML5 video using native device support (this is where media source extensions are not available or not reliable enough). On those devices limitations may apply:

  • DVR controls may not be supported, in which case DVR streams will be treated as simple live streams - on iOS 11+ DVR controls are only available in fullscreen mode. You may use forceHlsJSOnMacOSIpadOSSafari setting to force support of DVR controls on macOS and iPadOS Safari.
  • Manual bitrate switching is not supported - the player uses adaptive bitrate streaming in auto mode and the adaptation logic is left to the device.

HLS with Shaka Player

HLS streaming with Shaka player is only reserved to specific use-cases: HLS with DRM, offline HLS, HLS with embedded TTML captions. For all other use-cases please use the default hls.js engine.

As an alternative to hls.js for streaming HLS content to Radiant Media Player, it is also possible to use Shaka player to support specific use-cases.


Supported HLS features with Shaka Player

  • Playback of H.264 or H.265 video in fmp4 fragments (CMAF / fragmented MP4 container)
  • Live, DVR and on-demand media content
  • Optimized adaptive bitrate streaming with automatic or manual bitrate selection
  • Multiple-audio tracks
  • Multiple WebVTT or TTML tracks (subtitles/captions)
  • DRM (Widevine) - requires fmp4 HLS
  • Resilience to errors

Player settings for HLS with Shaka Player

hlsEngine: String

Selects the HLS rendering engine. Default: 'hlsjs'. Other possible value is 'shakaplayer'.

All other player settings that apply to Shaka player can all be used even if they are not explicitly marked as compatible with HLS streaming.


Player code examples for HLS with Shaka Player

fmp4-HLS with Shaka Player

<!-- Include Radiant Media Player - here we use the optimised build for Shaka player -->
<script src="https://cdn.radiantmediatechs.com/rmp/5.9.2/js/rmp-shaka.min.js"></script>
<!-- Player container element -->
<div id="rmpPlayer"></div>
<!-- Set up player configuration options -->
<script>
// Here we pass our HLS streaming source
  var src = {
    hls: 'https://your-fmp4-hls-url.m3u8'
  };
  var settings = {
    licenseKey: 'your-license-key',
    src: src,
    width: 640,
    height: 360,
    // Here we tell the player to use Shaka Player for HLS streaming
    hlsEngine: 'shakaplayer',
    contentMetadata: {
      poster: [
        'https://your-poster-url.jpg'
      ]
    }
  };
  var elementID = 'rmpPlayer';
  var rmp = new RadiantMP(elementID);
  rmp.init(settings);
</script>
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 3.0 License.