mirror of https://github.com/calzoneman/sync.git
Tried implementing Vimeo flash player, didn't fix problem
This commit is contained in:
parent
ab671917f7
commit
3932014ed0
|
@ -9,6 +9,8 @@ The above copyright notice and this permission notice shall be included in all c
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var VIMEO_FLASH = false;
|
||||||
|
|
||||||
var Player = function(data) {
|
var Player = function(data) {
|
||||||
if(!data) {
|
if(!data) {
|
||||||
data = {
|
data = {
|
||||||
|
@ -22,11 +24,19 @@ var Player = function(data) {
|
||||||
this.currentTime = data.currentTime || 0;
|
this.currentTime = data.currentTime || 0;
|
||||||
this.diff = 0;
|
this.diff = 0;
|
||||||
|
|
||||||
|
function postInit() {
|
||||||
|
this.load(data);
|
||||||
|
}
|
||||||
|
postInit.bind(this);
|
||||||
|
|
||||||
switch(this.type) {
|
switch(this.type) {
|
||||||
case "yt":
|
case "yt":
|
||||||
this.initYouTube();
|
this.initYouTube();
|
||||||
break;
|
break;
|
||||||
case "vi":
|
case "vi":
|
||||||
|
if(VIMEO_FLASH)
|
||||||
|
this.initVimeoFlash();
|
||||||
|
else
|
||||||
this.initVimeo();
|
this.initVimeo();
|
||||||
break;
|
break;
|
||||||
case "dm":
|
case "dm":
|
||||||
|
@ -60,7 +70,6 @@ var Player = function(data) {
|
||||||
this.nullPlayer();
|
this.nullPlayer();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
this.load(data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Player.prototype.nullPlayer = function() {
|
Player.prototype.nullPlayer = function() {
|
||||||
|
@ -205,6 +214,85 @@ Player.prototype.initVimeo = function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Player.prototype.initVimeoFlash = function() {
|
||||||
|
this.removeOld();
|
||||||
|
var url = "http://vimeo.com/moogaloop.swf?clip_id="+this.id;
|
||||||
|
url += "&" + [
|
||||||
|
"server=vimeo.com",
|
||||||
|
"api=2",
|
||||||
|
"show_title=0",
|
||||||
|
"show_byline=0",
|
||||||
|
"show_portrait=0",
|
||||||
|
"fullscreen=1",
|
||||||
|
"loop=0"
|
||||||
|
].join("&");
|
||||||
|
var flashvars = {
|
||||||
|
api: 2,
|
||||||
|
player_id: "ytapiplayer"
|
||||||
|
};
|
||||||
|
var params = {
|
||||||
|
allowfullscreen: true,
|
||||||
|
allowScriptAccess: "always"
|
||||||
|
};
|
||||||
|
swfobject.embedSWF(url
|
||||||
|
, "ytapiplayer"
|
||||||
|
, VWIDTH
|
||||||
|
, VHEIGHT
|
||||||
|
, "9.0.0"
|
||||||
|
, "expressInstall.swf"
|
||||||
|
, flashvars
|
||||||
|
, params);
|
||||||
|
|
||||||
|
this.player = $("#ytapiplayer")[0];
|
||||||
|
waitUntilDefined(this.player, "api_addEventListener", function () {
|
||||||
|
this.player.api_addEventListener("ready", function () {
|
||||||
|
socket.emit("playerReady");
|
||||||
|
this.player.api_play();
|
||||||
|
|
||||||
|
this.player.api_addEvent("finish", function () {
|
||||||
|
if(CLIENT.leader)
|
||||||
|
socket.emit("playNext");
|
||||||
|
});
|
||||||
|
|
||||||
|
this.player.api_addEvent("pause", function() {
|
||||||
|
PLAYER.paused = true;
|
||||||
|
sendVideoUpdate();
|
||||||
|
});
|
||||||
|
|
||||||
|
this.player.api_addEvent("play", function() {
|
||||||
|
PLAYER.paused = false;
|
||||||
|
sendVideoUpdate();
|
||||||
|
});
|
||||||
|
}.bind(this));
|
||||||
|
});
|
||||||
|
|
||||||
|
this.load = function(data) {
|
||||||
|
this.id = data.id;
|
||||||
|
this.initVimeoFlash();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.pause = function() {
|
||||||
|
this.player.api_pause();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.play = function() {
|
||||||
|
this.player.api_play();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.isPaused = function(callback) {
|
||||||
|
callback(this.paused);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.getTime = function(callback) {
|
||||||
|
var t = parseFloat(this.player.api_getCurrentTime());
|
||||||
|
callback(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.seek = function(time) {
|
||||||
|
this.player.api_seekTo(time);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Player.prototype.initDailymotion = function() {
|
Player.prototype.initDailymotion = function() {
|
||||||
this.removeOld();
|
this.removeOld();
|
||||||
this.player = DM.player("ytapiplayer", {
|
this.player = DM.player("ytapiplayer", {
|
||||||
|
|
|
@ -1473,3 +1473,13 @@ function loadChannelRanksPage(page) {
|
||||||
$($("#channelranks_pagination").find("li")[page]).addClass("active");
|
$($("#channelranks_pagination").find("li")[page]).addClass("active");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function waitUntilDefined(obj, key, fn) {
|
||||||
|
if(typeof obj[key] === "undefined") {
|
||||||
|
setTimeout(function () {
|
||||||
|
waitUntilDefined(obj, key, fn);
|
||||||
|
}, 100);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fn();
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue