Skip to content

Instantly share code, notes, and snippets.

@boushley
Created January 16, 2016 00:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boushley/588d2159b5eba1a15ed1 to your computer and use it in GitHub Desktop.
Save boushley/588d2159b5eba1a15ed1 to your computer and use it in GitHub Desktop.
An example of how you could calculate wait time without modifying or extending dash.js
(function(){
var videoElement = document.querySelector("#videoPlayer");
var url = "http://dash.edgesuite.net/envivio/Envivio-dash2/manifest.mpd";
var player = MediaPlayer().create();
player.initialize(videoElement, url, true);
var waitTimeStart;
videoElement.addEventListener('waiting', function() {
// If a second stream stalls keep the oldest start time
if (!waitTimeStart) {
waitTimeStart = performance.now();
}
});
videoElement.addEventListener('playing', function() {
if (waitTimeStart) {
console.log('Stream was stalled for: ', performance.now() - waitTimeStart);
waitTimeStart = null;
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment