Created
January 16, 2016 00:15
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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