OpenTV Browser Plugins to SDK Migration Guide

Video Agent

Events

The OpenTV Player Browser SDK supports all the VideoAgent events present in the PPAPI/NPAPI plugins, these are now registered directly against the player instance using a listener e.g. player.on("event", () =>{}).

VideoAgent events support:

  • abort
  • canplay
  • canplaythrough
  • durationchange
  • emptied
  • ended
  • error
  • loadedmetadata
  • loadstart
  • pause
  • play
  • playing
  • progress
  • seeked
  • seeking
  • stalled
  • timeupdate
  • volumechange
  • waiting

Properties

All VideoAgent properties are now functions against the player instance object.

Property Function Notes
autoplay autoplay()
controls controls()
currentSrc currentSrc()
currentTime currentTime()
disableSeek Not implemented
duration duration()
ended ended()
error error()
maximumSeekBack seekable() Deprecated, see seekable()
muted muted()
networkState networkState()
onerror
onload
paused paused()
readyState readyState()
seekable seekable() Returns a TimeRange object
seeking seeking()
src src()
videoHeight videoHeight()
videoWidth videoWidth()
volume volume()

Playback Agent

Track selection

The activateTrack and deactivateTrack methods do not have direct mappings in the Browser SDK. Track selection and deselection is now handled by iterating over a TextTrackList or AudioTrackList returned by the textTracks() and audioTracks() methods.

This is an example of selecting English subtitles:

let tracks = player.textTracks();

for (let i = 0; i < tracks.length; i++) {
  let track = tracks[i];

  // Show the English subtitle track, disable all others
  if (track.kind === "subtitles" && track.language === "en") {
    track.mode = "showing";
  } else {
    track.mode = "disabled";
  }
}

Properties

Property Mapping Notes
audioTracks audioTracks() The track list returned is not compatible
subtitlingTracks textTracks() The track list returned is not compatible

Events

Plugin event Browser event Notes
errorChanged Not implemented
ID3TagChanged Not implemented
streamBitrateChanged
tracksChanged addtrack / removetrack These events are implemented in TextTrackList and AudioTrackList

Network Agent

Support for the mappings below will be available in the forthcoming OpenTV Player SDK for Browser 1.3.0 release

Events

Event Object Event
selectedBitrateChanged networkStatistics selectedBitrateChanged

Example:

player.otvtoolkit().networkStatistics.setNetworkListener({
    selectedBitrateChanged: () => {
        console.log("Selected bitrate changed");
    }
});