Skip to content

OnAdaptationEvent not firing when selectTrack changes tracks #447

Closed
@ajbeach2

Description

@ajbeach2

This JS fiddle demonstrates the issue. When you select a different resolution, there is no event fired when selectTrack is called with a new track. In the js fiddle, click the 1080p and 144p buttons to change resolution. OnAdaptationEvent is only fired once, but it doesn't appear to be triggered when the track is changing via the 1080p and 144p buttons. Is this the expected behavior? I need to trigger events when a new track is selected.

https://jsfiddle.net/yh95LL4o/15/

var manifestUri = 'https://yt-dash-mse-test.commondatastorage.googleapis.com/media/car-20120827-manifest.mpd';

function jump(to){
    var video = document.getElementById('video');
  video.currentTime = to;
}

function resolution(height){
    var player = window.player
  var tracks = player.getTracks()
  track = tracks.find(function(x){if(x.height === height){return x}});
    player.selectTrack(track, true)
}

window.resolution = resolution;
window.jump = jump;

function initApp() {
  shaka.polyfill.installAll();
  shaka.Player.support().then(function(support) {
    if (support.supported) {
      initPlayer();
    } else {
      console.error('Browser not supported!');
    }
  });
}

function initPlayer() {
  var video = document.getElementById('video');
  var player = new shaka.Player(video);
  window.player = player;
  player.addEventListener('error', onErrorEvent);
  player.addEventListener('adaptation', onTrackChanged);

  player.load(manifestUri).then(function() {
    console.log('The video has now been loaded!');
  }).catch(onError);  // onError is executed if the asynchronous load fails.
}

function onErrorEvent(event) {
  onError(event.detail);
}

function onTrackChanged(event){
  alert("track changed!")
}

function onError(error) {
  console.error('Error code', error.code, 'object', error);
}

initApp();

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: archivedArchived and locked; will not be updatedtype: docsImprovements or fixes to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions