Fix a few bugs with the mediaelement player

This commit is contained in:
calzoneman 2014-01-07 13:51:58 -06:00
parent d14ee4f0db
commit 090ae06b69

View file

@ -993,9 +993,9 @@ var GoogleDocsPlayer = function (data) {
function MediaElementsPlayer(data) { function MediaElementsPlayer(data) {
var self = this; var self = this;
self.init = function (data) { self.init = function (data) {
waitUntilDefined(window, "MediaElementPlayer", function () {
self.videoId = data.id; self.videoId = data.id;
self.videoURL = data.url; self.videoURL = data.url;
waitUntilDefined(window, "MediaElementPlayer", function () {
var video = $("<video/>") var video = $("<video/>")
.attr("src", self.videoURL) .attr("src", self.videoURL)
.attr("id", "#ytapiplayer") .attr("id", "#ytapiplayer")
@ -1004,6 +1004,7 @@ function MediaElementsPlayer(data) {
removeOld(video); removeOld(video);
self.player = new MediaElementPlayer("#ytapiplayer"); self.player = new MediaElementPlayer("#ytapiplayer");
self.setVolume(VOLUME);
}); });
}; };
@ -1025,7 +1026,7 @@ function MediaElementsPlayer(data) {
self.isPaused = function (callback) { self.isPaused = function (callback) {
if (self.player) { if (self.player) {
callback(self.player.paused); callback(self.player.media.paused);
} }
}; };
@ -1037,21 +1038,23 @@ function MediaElementsPlayer(data) {
self.seek = function (time) { self.seek = function (time) {
if (self.player) { if (self.player) {
self.player.setCurrentTime(time); self.player.media.currentTime = time;
} }
}; };
self.getVolume = function (cb) { self.getVolume = function (cb) {
if (self.player) { if (self.player) {
cb(self.player.volume); cb(self.player.media.volume);
} }
}; };
self.setVolume = function (vol) { self.setVolume = function (vol) {
if (self.player) { if (self.player) {
self.player.setVolume(vol); self.player.media.volume = vol;
} }
}; };
self.init(data);
}; };
function handleMediaUpdate(data) { function handleMediaUpdate(data) {
@ -1151,7 +1154,7 @@ var constructors = {
"im": ImgurPlayer, "im": ImgurPlayer,
"cu": CustomPlayer, "cu": CustomPlayer,
"gd": GoogleDocsPlayer, "gd": GoogleDocsPlayer,
"me": MediaElementsPlayer, "me": MediaElementsPlayer
}; };
function loadMediaPlayer(data) { function loadMediaPlayer(data) {