Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OnAdaptationEvent not firing when selectTrack changes tracks #447

Closed
ajbeach2 opened this issue Jul 18, 2016 · 2 comments
Closed

OnAdaptationEvent not firing when selectTrack changes tracks #447

ajbeach2 opened this issue Jul 18, 2016 · 2 comments
Labels
status: archived Archived and locked; will not be updated type: docs Improvements or fixes to documentation

Comments

@ajbeach2
Copy link

ajbeach2 commented Jul 18, 2016

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();
@ajbeach2 ajbeach2 changed the title OnTrackEventChanged not firing when selectTrack changes tracks OnAdaptationEvent not firing when selectTrack changes tracks Jul 18, 2016
@joeyparrish joeyparrish added status: working as intended The behavior is intended; this is not a bug type: docs Improvements or fixes to documentation and removed status: working as intended The behavior is intended; this is not a bug labels Jul 18, 2016
@joeyparrish
Copy link
Member

Yes, this is intended behavior. The event fires when there's an automatic adaptation, but not a manual one. Presumably, if you call the method to change tracks, you know you've called it. Also, choosing a track manually disables ABR, so an adaptation event (which signals that the ABR system has made a decision) wouldn't make much sense.

I can see, though, that the docs are not very clear on these points. I will update them.

@joeyparrish
Copy link
Member

The docs have been updated. Hope that helps!

@shaka-project shaka-project locked and limited conversation to collaborators Mar 22, 2018
@shaka-bot shaka-bot added the status: archived Archived and locked; will not be updated label Apr 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: archived Archived and locked; will not be updated type: docs Improvements or fixes to documentation
Projects
None yet
Development

No branches or pull requests

3 participants