From 120cdf50e49cd9a573972c4ef619b71055267192 Mon Sep 17 00:00:00 2001 From: calzoneman Date: Fri, 12 Jul 2013 16:34:55 -0400 Subject: [PATCH] Re-address #173 --- www/assets/js/player.js | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/www/assets/js/player.js b/www/assets/js/player.js index c201a96d..5026ca25 100644 --- a/www/assets/js/player.js +++ b/www/assets/js/player.js @@ -126,6 +126,10 @@ Player.prototype.initYouTube = function() { this.player.playVideo(); } + this.isPaused = function(callback) { + callback(this.player.getPlayerState() != YT.PlayerState.PLAYING); + } + this.getTime = function(callback) { if(this.player.getCurrentTime) callback(this.player.getCurrentTime()); @@ -185,6 +189,10 @@ Player.prototype.initVimeo = function() { this.player.api("play"); } + this.isPaused = function(callback) { + callback(this.paused); + } + this.getTime = function(callback) { // Vimeo api returns time as a string because fuck logic this.player.api("getCurrentTime", function(time) { @@ -239,6 +247,10 @@ Player.prototype.initDailymotion = function() { this.player.api("play"); } + this.isPaused = function(callback) { + callback(this.paused); + } + this.getTime = function(callback) { callback(this.player.currentTime); } @@ -292,13 +304,11 @@ Player.prototype.initSoundcloud = function() { } this.play = function() { - this.player.isPaused(function(paused) { - // Instead of just unpausing, this actually seeks to 0 - // What the actual fuck - paused && this.player.play(); - }); + this.player.play(); } + this.isPaused = this.player.isPaused; + this.getTime = function(callback) { this.player.getPosition(function(pos) { callback(pos / 1000); @@ -325,6 +335,8 @@ Player.prototype.initLivestream = function() { this.play = function() { } + this.isPaused = function() { } + this.getTime = function() { } this.seek = function() { } @@ -352,6 +364,8 @@ Player.prototype.initTwitch = function() { this.play = function() { } + this.isPaused = function() { } + this.getTime = function() { } this.seek = function() { } @@ -379,6 +393,8 @@ Player.prototype.initJustinTV = function() { this.play = function() { } + this.isPaused = function() { } + this.getTime = function() { } this.seek = function() { } @@ -407,6 +423,8 @@ Player.prototype.initRTMP = function() { this.play = function() { } + this.isPaused = function() { } + this.getTime = function() { } this.seek = function() { } @@ -451,6 +469,10 @@ Player.prototype.initJWPlayer = function() { jwplayer().play(true); } + this.isPaused = function(callback) { + callback(jwplayer().getState() !== "PLAYING"); + } + this.getTime = function(callback) { // Only return time for non-live media if(jwplayer().getDuration() != -1) { @@ -483,6 +505,8 @@ Player.prototype.initUstream = function() { this.play = function() { } + this.isPaused = function() { } + this.getTime = function() { } this.seek = function() { } @@ -508,6 +532,8 @@ Player.prototype.initImgur = function() { this.play = function() { } + this.isPaused = function() { } + this.getTime = function() { } this.seek = function() { } @@ -533,7 +559,9 @@ Player.prototype.update = function(data) { this.pause(); } else { - this.play(); + this.isPaused(function(paused) { + paused && this.play(); + }.bind(this)); } this.getTime(function(seconds) { var time = data.currentTime;