Change RawVideoPlayer and FlashPlayer to FilePlayer

This commit is contained in:
Calvin Montgomery 2014-06-01 10:54:53 -07:00
parent 862a7d876d
commit 30d4e65061
2 changed files with 102 additions and 103 deletions

View File

@ -859,11 +859,10 @@ Callbacks = {
and unwilling to compromise on the issue. and unwilling to compromise on the issue.
*/ */
if (NO_VIMEO && data.type === "vi" && data.meta.direct) { if (NO_VIMEO && data.type === "vi" && data.meta.direct) {
data.type = "fi";
// For browsers that don't support native h264 playback // For browsers that don't support native h264 playback
if (USEROPTS.no_h264) { if (USEROPTS.no_h264) {
data.type = "fl"; data.forceFlash = true;
} else {
data.type = "rv";
} }
/* Convert youtube-style quality key to vimeo workaround quality */ /* Convert youtube-style quality key to vimeo workaround quality */
@ -895,6 +894,8 @@ Callbacks = {
if (data.type === "rt") { if (data.type === "rt") {
data.url = data.id; data.url = data.id;
data.type = "fi";
data.forceFlash = true;
} }
if(data.type != PLAYER.type) { if(data.type != PLAYER.type) {

View File

@ -800,98 +800,6 @@ function flashEventHandler(id, ev, data) {
} }
} }
var FlashPlayer = function (data) {
removeOld();
var self = this;
self.volume = VOLUME;
self.videoId = data.id;
self.videoUrl = data.url;
self.videoLength = data.seconds;
self.paused = false;
self.currentTime = 0;
self.init = function () {
var params = {
allowFullScreen: "true",
allowScriptAccess: "always",
allowNetworking: "all",
wMode: "direct"
};
var flashvars = {
src: encodeURIComponent(self.videoUrl),
// For some reason this param seems not to work
clipStartTime: Math.floor(data.currentTime),
javascriptCallbackFunction: "flashEventHandler",
autoPlay: true,
volume: VOLUME
};
if (self.videoUrl.indexOf("rtmp") === 0) {
flashvars.streamType = "live";
} else {
flashvars.streamType = "recorded";
}
swfobject.embedSWF("/StrobeMediaPlayback.swf",
"ytapiplayer",
VWIDTH, VHEIGHT,
"10.1.0",
null,
flashvars,
params,
{ name: "ytapiplayer" }
);
self.player = $("#ytapiplayer")[0];
};
self.load = function (data) {
self.videoId = data.id;
self.videoUrl = data.url;
self.videoLength = data.seconds;
self.init();
};
self.pause = function () {
if (self.player && self.player.pause)
self.player.pause();
};
self.play = function () {
// Why is it play2? What happened to play1?
if (self.player && self.player.play2)
self.player.play2();
};
self.isPaused = function (cb) {
cb(self.paused);
};
self.getTime = function (cb) {
cb(self.currentTime);
};
self.seek = function (to) {
if (self.player && self.player.seek) {
self.player.seek(Math.floor(to));
}
};
self.getVolume = function (cb) {
cb(self.volume);
};
self.setVolume = function (vol) {
if (self.player && self.player.setVolume)
self.player.setVolume(vol);
};
waitUntilDefined(window, "swfobject", function () {
self.init();
});
};
var JWPlayer = function (data) { var JWPlayer = function (data) {
var self = this; var self = this;
self.videoId = data.id; self.videoId = data.id;
@ -1161,8 +1069,89 @@ var GoogleDocsPlayer = function (data) {
self.init(data); self.init(data);
}; };
function RawVideoPlayer(data) { function FilePlayer(data) {
var self = this; var self = this;
self.initFlash = function (data) {
waitUntilDefined(window, "swfobject", function () {
self.volume = VOLUME;
self.videoId = data.id;
self.videoURL = data.url;
self.videoLength = data.seconds;
self.paused = false;
self.currentTime = 0;
var params = {
allowFullScreen: "true",
allowScriptAccess: "always",
allowNetworking: "all",
wMode: "direct"
};
var flashvars = {
src: encodeURIComponent(self.videoURL),
// For some reason this param seems not to work
clipStartTime: Math.floor(data.currentTime),
javascriptCallbackFunction: "flashEventHandler",
autoPlay: true,
volume: VOLUME
};
if (self.videoURL.indexOf("rtmp") === 0) {
flashvars.streamType = "live";
} else {
flashvars.streamType = "recorded";
}
swfobject.embedSWF("/StrobeMediaPlayback.swf",
"ytapiplayer",
VWIDTH, VHEIGHT,
"10.1.0",
null,
flashvars,
params,
{ name: "ytapiplayer" }
);
self.player = $("#ytapiplayer")[0];
resizeStuff();
self.pause = function () {
if (self.player && self.player.pause)
self.player.pause();
};
self.play = function () {
// Why is it play2? What happened to play1?
if (self.player && self.player.play2)
self.player.play2();
};
self.isPaused = function (cb) {
cb(self.paused);
};
self.getTime = function (cb) {
cb(self.currentTime);
};
self.seek = function (to) {
if (self.player && self.player.seek) {
self.player.seek(Math.floor(to));
}
};
self.getVolume = function (cb) {
cb(self.volume);
};
self.setVolume = function (vol) {
if (self.player && self.player.setVolume)
self.player.setVolume(vol);
};
});
};
self.init = function (data) { self.init = function (data) {
self.videoId = data.id; self.videoId = data.id;
self.videoURL = data.url; self.videoURL = data.url;
@ -1175,12 +1164,14 @@ function RawVideoPlayer(data) {
.html("Your browser does not support HTML5 <code>&lt;video&gt;</code> tags :("); .html("Your browser does not support HTML5 <code>&lt;video&gt;</code> tags :(");
video.error(function (err) { video.error(function (err) {
setTimeout(function () { setTimeout(function () {
fallbackRaw(data); console.log("<video> tag failed, falling back to Flash");
self.initFlash(data);
}, 100); }, 100);
}); });
removeOld(video); removeOld(video);
self.player = video[0]; self.player = video[0];
self.setVolume(VOLUME); self.setVolume(VOLUME);
resizeStuff();
}; };
self.load = function (data) { self.load = function (data) {
@ -1213,7 +1204,10 @@ function RawVideoPlayer(data) {
self.seek = function (time) { self.seek = function (time) {
if (self.player) { if (self.player) {
self.player.currentTime = time; try {
self.player.currentTime = time;
} catch (e) {
}
} }
}; };
@ -1233,10 +1227,13 @@ function RawVideoPlayer(data) {
} }
}; };
self.init(data); if (data.forceFlash) {
self.initFlash(data);
} else {
self.init(data);
}
}; };
function handleMediaUpdate(data) { function handleMediaUpdate(data) {
// Don't update if the position is past the video length, but // Don't update if the position is past the video length, but
// make an exception when the video length is 0 seconds // make an exception when the video length is 0 seconds
@ -1334,13 +1331,14 @@ var constructors = {
"tw": TwitchTVPlayer, "tw": TwitchTVPlayer,
"jt": JustinTVPlayer, "jt": JustinTVPlayer,
"us": UstreamPlayer, "us": UstreamPlayer,
"rt": FlashPlayer,
"jw": JWPlayer, "jw": JWPlayer,
"im": ImgurPlayer, "im": ImgurPlayer,
"cu": CustomPlayer, "cu": CustomPlayer,
"gd": GoogleDocsPlayer, "gd": GoogleDocsPlayer,
"rv": RawVideoPlayer, "rt": FilePlayer,
"fl": FlashPlayer "rv": FilePlayer,
"fl": FilePlayer,
"fi": FilePlayer
}; };
function loadMediaPlayer(data) { function loadMediaPlayer(data) {