Skip to main content

WebMAF Player

FLPlayer for WebMAF/PS4 has exact same API surface as the Web player, with some minor differences.

Create the Player

A Player could be built by providing content url, license url and or by providing all the options as below

const contentUrl =
'https://storage.googleapis.com/shaka-demo-assets/angel-one-widevine/dash.mpd';
const licenseUrl = 'https://cwip-shaka-proxy.appspot.com/no_auth';
const playerBuilder = flPlayer.createWebMafPlayerBuilder();
const player = playerBuilder
.mediaUrl(contentUrl)
.drmLicenseUrl(licenseUrl)
.drmScheme(flPlayer.DrmScheme.PLAYREADY)
.mediaType(flPlayer.MediaType.DASH)
.build();
note

WebMAF uses native player internally and hence does not require videoElement for video rendering. The player builder does not accept the .mediaElement() unlike a regular web player.

Access Function

The host WebMAF application must forward all the messages received via the global accessfunction to the player.

function accessfunction(message) {
player.accessFunctionHandler(message);
...
// application code
}

Subscribe for events

The application can listen to events such as changes in player state, buffering state, seek state and playback errors by registering a listener/delegate.

player.subscribe('error', function (error) {
console.log('error', error);
});

player.subscribe('contentloaded', function () {
console.log('contentloaded');
});

player.subscribe('playbackstatechanged', function (state) {
console.log('playbackstatechanged', state);
});

Key differences

Playback Configuration

The following playback configuration options are not supported on WebMAF

  • Bitrate
  • Network configuration
  • Buffer configuration
  • Trickplay

End of Play

When a video is played to end of stream, the player moves into idle state since the underlying WebMAF player is unloaded. So, to enable replay, a new player instance must be created.

note

FLPlayer for Web moves into loaded state and allow re-playing the content or scrubbing back after playing through end of stream.

Subtitles

  • WebMAF does not auto-render subtitle/closed captions. Subtitle rendering must be handled on the application by subscribing to the timedmetadata event on the player.
player.subscribe('timedmetadata', function (metadata) {
switch (metadata.type) {
case 'text':
// render text
break;
case 'cea-708':
// render caption
break;
}
});