Hack around YouTube HTML5 player race condition -- Really guys?

This commit is contained in:
calzoneman 2013-10-16 21:50:31 -05:00
parent 120d56d6c8
commit 033fbbf08a
2 changed files with 22 additions and 4 deletions

View File

@ -1,3 +1,7 @@
Wed Oct 16 21:48 2013 CDT
* www/assets/js/player.js: Add a stupid timeout hack to address
a race condition in YouTube's HTML5 player. Seriously?
Wed Oct 16 17:34 2013 CDT
* lib/utilities.js: Add a "Set" wrapper around objects to represent
sets.

View File

@ -67,8 +67,11 @@ var YouTubePlayer = function (data) {
self.load = function (data) {
if(self.player && self.player.loadVideoById) {
self.player.loadVideoById(data.id, data.currentTime);
if(VIDEOQUALITY)
if(VIDEOQUALITY) {
self.player.setPlaybackQuality(VIDEOQUALITY);
// What's that? Another stupid hack for the HTML5 player?
self.player.setPlaybackQuality(VIDEOQUALITY);
}
self.videoId = data.id;
self.videoLength = data.seconds;
}
@ -723,7 +726,6 @@ var ImgurPlayer = function (data) {
iframe.attr("height", VHEIGHT);
var prto = location.protocol;
iframe.attr("src", prto+"//imgur.com/a/"+self.videoId+"/embed");
console.log(prto);
iframe.attr("frameborder", "0");
iframe.attr("scrolling", "no");
iframe.css("border", "none");
@ -804,8 +806,20 @@ function handleMediaUpdate(data) {
}
if (wait) {
PLAYER.seek(0);
PLAYER.pause();
var tm = 1;
/* Stupid hack -- In this thrilling episode of
"the YouTube API developers should eat a boat", the
HTML5 player apparently breaks if I play()-seek(0)-pause()
quickly (as a "start buffering but don't play yet"
mechanism)
*/
if (PLAYER.type === "yt") {
tm = 500;
}
setTimeout(function () {
PLAYER.seek(0);
PLAYER.pause();
}, tm);
return;
}