This commit is contained in:
calzoneman 2015-05-02 17:37:09 -05:00
parent 391ea264f5
commit d7b69bce38
4 changed files with 38 additions and 33 deletions

View file

@ -829,11 +829,17 @@ Callbacks = {
VOLUME = 1;
}
function loadNext() {
if (data.type !== PLAYER.mediaType) {
loadMediaPlayer(data);
}
handleMediaUpdate(data);
}
// Persist the user's volume preference from the the player, if possible
if (PLAYER && typeof PLAYER.getVolume === "function") {
var name = PLAYER.__proto__.constructor.name;
PLAYER.getVolume(function (v) {
console.log(name, v)
if (typeof v === "number") {
if (v < 0 || v > 1) {
// Dailymotion's API was wrong once and caused a huge
@ -850,7 +856,11 @@ Callbacks = {
setOpt("volume", VOLUME);
}
}
loadNext();
});
} else {
loadNext();
}
// Reset voteskip since the video changed
@ -859,15 +869,6 @@ Callbacks = {
}
$("#currenttitle").text("Currently Playing: " + data.title);
// TODO: fix this
setTimeout(function () {
if (data.type !== PLAYER.mediaType) {
loadMediaPlayer(data);
}
handleMediaUpdate(data);
}, 100);
},
mediaUpdate: function(data) {

View file

@ -186,16 +186,19 @@
YouTubePlayer.prototype.load = function(data) {
this.setMediaProperties(data);
if (this.yt) {
if (this.yt && this.yt.ready) {
this.yt.loadVideoById(data.id, data.currentTime);
this.qualityRaceCondition = true;
if (USEROPTS.default_quality) {
return this.yt.setPlaybackQuality(USEROPTS.default_quality);
}
} else {
return console.error('WTF? YouTubePlayer::load() called but yt is not ready');
}
};
YouTubePlayer.prototype.onReady = function() {
this.yt.ready = true;
return this.setVolume(VOLUME);
};
@ -223,26 +226,26 @@
YouTubePlayer.prototype.play = function() {
this.paused = false;
if (this.yt) {
if (this.yt && this.yt.ready) {
return this.yt.playVideo();
}
};
YouTubePlayer.prototype.pause = function() {
this.paused = true;
if (this.yt) {
if (this.yt && this.yt.ready) {
return this.yt.pauseVideo();
}
};
YouTubePlayer.prototype.seekTo = function(time) {
if (this.yt) {
if (this.yt && this.yt.ready) {
return this.yt.seekTo(time, true);
}
};
YouTubePlayer.prototype.setVolume = function(volume) {
if (this.yt) {
if (this.yt && this.yt.ready) {
if (volume > 0) {
this.yt.unMute();
}
@ -251,7 +254,7 @@
};
YouTubePlayer.prototype.getTime = function(cb) {
if (this.yt) {
if (this.yt && this.yt.ready) {
return cb(this.yt.getCurrentTime());
} else {
return cb(0);
@ -259,7 +262,7 @@
};
YouTubePlayer.prototype.getVolume = function(cb) {
if (this.yt) {
if (this.yt && this.yt.ready) {
if (this.yt.isMuted()) {
return cb(0);
} else {
@ -282,14 +285,12 @@
window.loadMediaPlayer = function(data) {
var e;
if (data.type in TYPE_MAP) {
console.log(data);
try {
window.PLAYER = TYPE_MAP[data.type](data);
return window.PLAYER = TYPE_MAP[data.type](data);
} catch (_error) {
e = _error;
console.error(e);
return console.error(e);
}
return console.log(window.PLAYER);
}
};
@ -308,12 +309,13 @@
PLAYER.play();
}
if (waiting) {
PLAYER.seekTo(0);
if (PLAYER instanceof YouTubePlayer) {
PLAYER.pauseSeekRaceCondition = true;
} else {
PLAYER.seekTo(0);
PLAYER.pause();
}
return;
} else if (PLAYER instanceof YouTubePlayer) {
PLAYER.pauseSeekRaceCondition = false;
}