Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix Issue #31

  • Loading branch information...
commit 6a6474344b3c4b0c96b385a27fee7010971a36ae 1 parent 2903e53
@akamensky akamensky authored
Showing with 19 additions and 17 deletions.
  1. +5 −3 jQuery.tubeplayer.js
  2. +14 −14 jQuery.tubeplayer.min.js
View
8 jQuery.tubeplayer.js
@@ -118,7 +118,7 @@
case 101:
case 150: return _ret.notEmbeddable[player]();
- default: return null;
+ default: return _ret.defaultError[player]();
}
@@ -145,7 +145,7 @@
onPlayer:{unstarted:{},ended:{},playing:{},paused:{},buffering:{},cued:{}},
- onErr:{notFound:{},notEmbeddable:{},invalidParameter:{}}
+ onErr:{defaultError:{},notFound:{},notEmbeddable:{},invalidParameter:{}}
};
@@ -205,6 +205,7 @@
onQualityChange: function(){},
// error fn's
+ onError: function(){},
onErrorNotFound: function(){},
onErrorNotEmbeddable: function(){},
onErrorInvalidParameter: function(){}
@@ -464,6 +465,7 @@
// default onError events
var de = d.onErr;
+ de.defaultError[ID] = o.onError;
de.notFound[ID] = o.onErrorNotFound;
de.notEmbeddable[ID] = o.onErrorNotEmbeddable;
de.invalidParameter[ID] = o.onErrorInvalidParameter;
@@ -793,7 +795,7 @@
delete d.onPlayer[event][p.opts.playerID];
});
- events = ['notFound','notEmbeddable','invalidParameter'];
+ events = ['defaultError','notFound','notEmbeddable','invalidParameter'];
jQuery.each(events, function(i, event) {
delete d.onErr[event][p.opts.playerID];
});
View
28 jQuery.tubeplayer.min.js
@@ -1,18 +1,18 @@
(function(e){function k(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=Math.random()*16|0;return(a=="x"?b:b&3|8).toString(16)})}var d={};d.ytplayers={};d.inits=[];d.iframeScriptInited=false;d.inited=false;e.tubeplayer={};e.tubeplayer.TubePlayer=d;e.tubeplayer.events={};e.tubeplayer.defaults={afterReady:function(){},stateChange:function(a){var b=this.onPlayer;return function(c){if(typeof c==="object")c=c.data;switch(c){case -1:return b.unstarted[a]();case 0:return b.ended[a]();
-case 1:return b.playing[a]();case 2:return b.paused[a]();case 3:return b.buffering[a]();case 5:return b.cued[a]();default:return null}}},onError:function(a){var b=this.onErr;return function(c){if(typeof c==="object")c=c.data;switch(c){case 2:return b.invalidParameter[a]();case 100:return b.notFound[a]();case 101:case 150:return b.notEmbeddable[a]();default:return null}}},qualityChange:function(a){var b=this;return function(c){if(typeof c==="object")c=c.data;return b.onQualityChange[a](c)}},onQualityChange:{},
-onPlayer:{unstarted:{},ended:{},playing:{},paused:{},buffering:{},cued:{}},onErr:{notFound:{},notEmbeddable:{},invalidParameter:{}}};var l={width:425,height:355,allowFullScreen:"true",initialVideo:"DkoeNLuMbcI",start:0,preferredQuality:"default",showControls:true,showRelated:false,annotations:true,autoPlay:false,autoHide:true,loop:0,theme:"dark",color:"red",showinfo:false,modestbranding:true,protocol:"http",wmode:"transparent",swfobjectURL:"ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js",
-loadSWFObject:true,allowScriptAccess:"always",playerID:"tubeplayer-player-container",iframed:true,onPlay:function(){},onPause:function(){},onStop:function(){},onSeek:function(){},onMute:function(){},onUnMute:function(){},onPlayerUnstarted:function(){},onPlayerEnded:function(){},onPlayerPlaying:function(){},onPlayerPaused:function(){},onPlayerBuffering:function(){},onPlayerCued:function(){},onQualityChange:function(){},onErrorNotFound:function(){},onErrorNotEmbeddable:function(){},onErrorInvalidParameter:function(){}};
-e.fn.tubeplayer=function(a,b){var c=e(this),f=typeof a;if(arguments.length===0||f==="object")return c.each(function(){d.init(e(this),a)});else if(f==="string")return c.triggerHandler(a+".tubeplayer",typeof b!=="undefined"?b:null)};var g=function(a){return function(b,c){var f=d.getPkg(b);if(f.ytplayer){b=a(b,c,f);if(typeof b==="undefined")b=f.$player;return b}return f.$player}};e.tubeplayer.getPlayers=function(){return d.ytplayers};d.init=function(a,b){if(a.hasClass("jquery-youtube-tubeplayer"))return a;
+case 1:return b.playing[a]();case 2:return b.paused[a]();case 3:return b.buffering[a]();case 5:return b.cued[a]();default:return null}}},onError:function(a){var b=this.onErr;return function(c){if(typeof c==="object")c=c.data;switch(c){case 2:return b.invalidParameter[a]();case 100:return b.notFound[a]();case 101:case 150:return b.notEmbeddable[a]();default:return b.defaultError[a]()}}},qualityChange:function(a){var b=this;return function(c){if(typeof c==="object")c=c.data;return b.onQualityChange[a](c)}},
+onQualityChange:{},onPlayer:{unstarted:{},ended:{},playing:{},paused:{},buffering:{},cued:{}},onErr:{defaultError:{},notFound:{},notEmbeddable:{},invalidParameter:{}}};var l={width:425,height:355,allowFullScreen:"true",initialVideo:"DkoeNLuMbcI",start:0,preferredQuality:"default",showControls:true,showRelated:false,annotations:true,autoPlay:false,autoHide:true,loop:0,theme:"dark",color:"red",showinfo:false,modestbranding:true,protocol:"http",wmode:"transparent",swfobjectURL:"ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js",
+loadSWFObject:true,allowScriptAccess:"always",playerID:"tubeplayer-player-container",iframed:true,onPlay:function(){},onPause:function(){},onStop:function(){},onSeek:function(){},onMute:function(){},onUnMute:function(){},onPlayerUnstarted:function(){},onPlayerEnded:function(){},onPlayerPlaying:function(){},onPlayerPaused:function(){},onPlayerBuffering:function(){},onPlayerCued:function(){},onQualityChange:function(){},onError:function(){},onErrorNotFound:function(){},onErrorNotEmbeddable:function(){},
+onErrorInvalidParameter:function(){}};e.fn.tubeplayer=function(a,b){var c=e(this),f=typeof a;if(arguments.length===0||f==="object")return c.each(function(){d.init(e(this),a)});else if(f==="string")return c.triggerHandler(a+".tubeplayer",typeof b!=="undefined"?b:null)};var g=function(a){return function(b,c){var f=d.getPkg(b);if(f.ytplayer){b=a(b,c,f);if(typeof b==="undefined")b=f.$player;return b}return f.$player}};e.tubeplayer.getPlayers=function(){return d.ytplayers};d.init=function(a,b){if(a.hasClass("jquery-youtube-tubeplayer"))return a;
b=e.extend({},l,b);b.playerID+="-"+k();a.addClass("jquery-youtube-tubeplayer").data("opts.tubeplayer",b);for(var c in j)a.bind(c+".tubeplayer",a,j[c]);d.initDefaults(e.tubeplayer.defaults,b);e("<div></div>").attr("id",b.playerID).appendTo(a);d.initPlayer(a,b);return a};d.getPkg=function(a){a=a.data;var b=a.data("opts.tubeplayer");return{$player:a,opts:b,ytplayer:d.ytplayers[b.playerID]}};d.iframeReady=function(a){d.inits.push(function(){new YT.Player(a.playerID,{videoId:a.initialVideo,width:a.width,
height:a.height,playerVars:{autoplay:a.autoPlay?1:0,autohide:a.autoHide?1:0,controls:a.showControls?1:0,loop:a.loop?1:0,playlist:a.loop?a.initialVideo:"",rel:a.showRelated?1:0,fs:a.allowFullScreen?1:0,wmode:a.wmode,showinfo:a.showinfo?1:0,modestbranding:a.modestbranding?1:0,iv_load_policy:a.annotations?1:3,start:a.start,theme:a.theme,color:a.color},events:{onReady:function(b){d.ytplayers[a.playerID]=b.target;b=e(b.target).parents(".jquery-youtube-tubeplayer");e.tubeplayer.defaults.afterReady(b)},
onPlaybackQualityChange:e.tubeplayer.defaults.qualityChange(a.playerID),onStateChange:e.tubeplayer.defaults.stateChange(a.playerID),onError:e.tubeplayer.defaults.onError(a.playerID)}})});if(d.inits.length>=1&&!d.inited)return function(){for(var b=0;b<d.inits.length;b++)d.inits[b]();d.inited=true};d.inited&&d.inits.pop()();return window.onYouTubePlayerAPIReady};d.initDefaults=function(a,b){var c=b.playerID,f=a.onPlayer;f.unstarted[c]=b.onPlayerUnstarted;f.ended[c]=b.onPlayerEnded;f.playing[c]=b.onPlayerPlaying;
-f.paused[c]=b.onPlayerPaused;f.buffering[c]=b.onPlayerBuffering;f.cued[c]=b.onPlayerCued;a.onQualityChange[c]=b.onQualityChange;a=a.onErr;a.notFound[c]=b.onErrorNotFound;a.notEmbeddable[c]=b.onErrorNotEmbeddable;a.invalidParameter[c]=b.onErrorInvalidParameter};d.initPlayer=function(a,b){b.iframed?d.initIframePlayer(a,b):d.initFlashPlayer(a,b)};d.initIframePlayer=function(a,b){if(!d.iframeScriptInited){a=document.createElement("script");a.src=b.protocol+"://www.youtube.com/iframe_api";var c=document.getElementsByTagName("script")[0];
-c.parentNode.insertBefore(a,c);d.iframeScriptInited=true}window.onYouTubePlayerAPIReady=d.iframeReady(b)};d.initFlashPlayer=function(a,b){if(b.loadSWFObject){b.swfobjectURL=b.swfobjectURL.replace("http://","");b.swfobjectURL=b.swfobjectURL.replace("https://","");b.swfobjectURL=b.protocol+"://"+b.swfobjectURL;e.getScript(b.swfobjectURL,d.initFlashPlayerFN(b))}else d.initFlashPlayerFN(b)()};d.initFlashPlayerFN=function(a){return function(){var b=["//www.youtube.com/v/"];b.push(a.initialVideo);b.push("?&enablejsapi=1&version=3");
-b.push("&playerapiid="+a.playerID);b.push("&rel= "+(a.showRelated?1:0));b.push("&autoplay="+(a.autoPlay?1:0));b.push("&autohide="+(a.autoHide?1:0));b.push("&loop="+(a.loop?1:0));b.push("&playlist="+(a.loop?a.initialVideo:""));b.push("&controls="+(a.showControls?1:0));b.push("&showinfo="+(a.showinfo?1:0));b.push("&modestbranding="+(a.modestbranding?1:0));b.push("&iv_load_policy="+(a.annotations?1:3));b.push("&start="+a.start);b.push("&theme="+a.theme);b.push("&color="+a.color);b.push("&fs="+(a.allowFullScreen?
-1:0));swfobject.embedSWF(b.join(""),a.playerID,a.width,a.height,"8",null,null,{allowScriptAccess:a.allowScriptAccess,wmode:a.wmode,allowFullScreen:a.allowFullScreen},{id:a.playerID});window.onYouTubePlayerReady=function(c){var f=document.getElementById(c),i=c.replace(/-/g,""),h=e.tubeplayer.defaults;e.tubeplayer.events[i]={stateChange:h.stateChange(c),error:h.onError(c),qualityChange:h.qualityChange(c)};f.addEventListener("onStateChange","$.tubeplayer.events."+i+".stateChange");f.addEventListener("onError",
-"$.tubeplayer.events."+i+".error");f.addEventListener("onPlaybackQualityChange","$.tubeplayer.events."+i+".qualityChange");d.ytplayers[c]=f;c=e(f).parents(".jquery-youtube-tubeplayer");e.tubeplayer.defaults.afterReady(c)}}};d.getVideoIDFromURL=function(a){a=a||"";var b=a.indexOf("?");a=a.substring(b,a.length);b=a.indexOf("v=");if(b>-1){var c=a.indexOf("&",b);if(c===-1)c=a.length;return a.substring(b+2,c)}return""};var j={cue:g(function(a,b,c){c.ytplayer.cueVideoById(b,c.opts.preferredQuality)}),play:g(function(a,
-b,c){if(typeof b==="object")c.ytplayer.loadVideoById(b.id,b.time,c.opts.preferredQuality);else typeof b!=="undefined"?c.ytplayer.loadVideoById(b,0,c.opts.preferredQuality):c.ytplayer.playVideo();c.opts.onPlay(b)}),pause:g(function(a,b,c){c.ytplayer.pauseVideo();c.opts.onPause(c)}),stop:g(function(a,b,c){c.ytplayer.stopVideo();c.opts.onStop(c)}),seek:g(function(a,b,c){c.ytplayer.seekTo(b,true);c.opts.onSeek(b)}),mute:g(function(a,b,c){c.$player.attr("data-prev-mute-volume",c.ytplayer.getVolume());
-c.ytplayer.mute();c.opts.onMute(c)}),unmute:g(function(a,b,c){c.ytplayer.unMute();c.ytplayer.setVolume(c.$player.attr("data-prev-mute-volume")||50);c.opts.onUnMute()}),isMuted:g(function(a,b,c){return c.ytplayer.isMuted()}),volume:g(function(a,b,c){if(typeof b!=="undefined"){c.ytplayer.setVolume(b);c.$player.attr("data-prev-mute-volume",c.ytplayer.getVolume())}else return c.ytplayer.getVolume()||0}),quality:g(function(a,b,c){if(typeof b!=="undefined")c.ytplayer.setPlaybackQuality(b);else return c.ytplayer.getPlaybackQuality()}),
-data:g(function(a,b,c){a={};c=c.ytplayer;a.bytesLoaded=c.getVideoBytesLoaded();a.bytesTotal=c.getVideoBytesTotal();a.startBytes=c.getVideoStartBytes();a.state=c.getPlayerState();a.currentTime=c.getCurrentTime();a.duration=c.getDuration();a.videoURL=c.getVideoUrl();a.getVideoEmbedCode=c.getVideoEmbedCode();a.videoID=d.getVideoIDFromURL(a.videoURL);a.availableQualityLevels=c.getAvailableQualityLevels();return a}),videoId:g(function(a,b,c){return d.getVideoIDFromURL(c.ytplayer.getVideoUrl())}),size:g(function(a,
-b,c){if(typeof b!=="undefined"&&b.width&&b.height){c.ytplayer.setSize(b.width,b.height);e(c.ytplayer).css(b)}}),destroy:g(function(a,b,c){c.$player.removeClass("jquery-youtube-tubeplayer").data("opts.tubeplayer",null).unbind(".tubeplayer").html("");delete d.ytplayers[c.opts.playerID];var f=e.tubeplayer.defaults;a=["unstarted","ended","playing","paused","buffering","cued"];jQuery.each(a,function(i,h){delete f.onPlayer[h][c.opts.playerID]});a=["notFound","notEmbeddable","invalidParameter"];jQuery.each(a,
-function(i,h){delete f.onErr[h][c.opts.playerID]});delete f.onQualityChange[c.opts.playerID];delete e.tubeplayer.events[c.opts.playerID];e(c.ytplayer).remove();return null}),player:g(function(a,b,c){return c.ytplayer})}})(jQuery);
+f.paused[c]=b.onPlayerPaused;f.buffering[c]=b.onPlayerBuffering;f.cued[c]=b.onPlayerCued;a.onQualityChange[c]=b.onQualityChange;a=a.onErr;a.defaultError[c]=b.onError;a.notFound[c]=b.onErrorNotFound;a.notEmbeddable[c]=b.onErrorNotEmbeddable;a.invalidParameter[c]=b.onErrorInvalidParameter};d.initPlayer=function(a,b){b.iframed?d.initIframePlayer(a,b):d.initFlashPlayer(a,b)};d.initIframePlayer=function(a,b){if(!d.iframeScriptInited){a=document.createElement("script");a.src=b.protocol+"://www.youtube.com/iframe_api";
+var c=document.getElementsByTagName("script")[0];c.parentNode.insertBefore(a,c);d.iframeScriptInited=true}window.onYouTubePlayerAPIReady=d.iframeReady(b)};d.initFlashPlayer=function(a,b){if(b.loadSWFObject){b.swfobjectURL=b.swfobjectURL.replace("http://","");b.swfobjectURL=b.swfobjectURL.replace("https://","");b.swfobjectURL=b.protocol+"://"+b.swfobjectURL;e.getScript(b.swfobjectURL,d.initFlashPlayerFN(b))}else d.initFlashPlayerFN(b)()};d.initFlashPlayerFN=function(a){return function(){var b=["//www.youtube.com/v/"];
+b.push(a.initialVideo);b.push("?&enablejsapi=1&version=3");b.push("&playerapiid="+a.playerID);b.push("&rel= "+(a.showRelated?1:0));b.push("&autoplay="+(a.autoPlay?1:0));b.push("&autohide="+(a.autoHide?1:0));b.push("&loop="+(a.loop?1:0));b.push("&playlist="+(a.loop?a.initialVideo:""));b.push("&controls="+(a.showControls?1:0));b.push("&showinfo="+(a.showinfo?1:0));b.push("&modestbranding="+(a.modestbranding?1:0));b.push("&iv_load_policy="+(a.annotations?1:3));b.push("&start="+a.start);b.push("&theme="+
+a.theme);b.push("&color="+a.color);b.push("&fs="+(a.allowFullScreen?1:0));swfobject.embedSWF(b.join(""),a.playerID,a.width,a.height,"8",null,null,{allowScriptAccess:a.allowScriptAccess,wmode:a.wmode,allowFullScreen:a.allowFullScreen},{id:a.playerID});window.onYouTubePlayerReady=function(c){var f=document.getElementById(c),i=c.replace(/-/g,""),h=e.tubeplayer.defaults;e.tubeplayer.events[i]={stateChange:h.stateChange(c),error:h.onError(c),qualityChange:h.qualityChange(c)};f.addEventListener("onStateChange",
+"$.tubeplayer.events."+i+".stateChange");f.addEventListener("onError","$.tubeplayer.events."+i+".error");f.addEventListener("onPlaybackQualityChange","$.tubeplayer.events."+i+".qualityChange");d.ytplayers[c]=f;c=e(f).parents(".jquery-youtube-tubeplayer");e.tubeplayer.defaults.afterReady(c)}}};d.getVideoIDFromURL=function(a){a=a||"";var b=a.indexOf("?");a=a.substring(b,a.length);b=a.indexOf("v=");if(b>-1){var c=a.indexOf("&",b);if(c===-1)c=a.length;return a.substring(b+2,c)}return""};var j={cue:g(function(a,
+b,c){c.ytplayer.cueVideoById(b,c.opts.preferredQuality)}),play:g(function(a,b,c){if(typeof b==="object")c.ytplayer.loadVideoById(b.id,b.time,c.opts.preferredQuality);else typeof b!=="undefined"?c.ytplayer.loadVideoById(b,0,c.opts.preferredQuality):c.ytplayer.playVideo();c.opts.onPlay(b)}),pause:g(function(a,b,c){c.ytplayer.pauseVideo();c.opts.onPause(c)}),stop:g(function(a,b,c){c.ytplayer.stopVideo();c.opts.onStop(c)}),seek:g(function(a,b,c){c.ytplayer.seekTo(b,true);c.opts.onSeek(b)}),mute:g(function(a,
+b,c){c.$player.attr("data-prev-mute-volume",c.ytplayer.getVolume());c.ytplayer.mute();c.opts.onMute(c)}),unmute:g(function(a,b,c){c.ytplayer.unMute();c.ytplayer.setVolume(c.$player.attr("data-prev-mute-volume")||50);c.opts.onUnMute()}),isMuted:g(function(a,b,c){return c.ytplayer.isMuted()}),volume:g(function(a,b,c){if(typeof b!=="undefined"){c.ytplayer.setVolume(b);c.$player.attr("data-prev-mute-volume",c.ytplayer.getVolume())}else return c.ytplayer.getVolume()||0}),quality:g(function(a,b,c){if(typeof b!==
+"undefined")c.ytplayer.setPlaybackQuality(b);else return c.ytplayer.getPlaybackQuality()}),data:g(function(a,b,c){a={};c=c.ytplayer;a.bytesLoaded=c.getVideoBytesLoaded();a.bytesTotal=c.getVideoBytesTotal();a.startBytes=c.getVideoStartBytes();a.state=c.getPlayerState();a.currentTime=c.getCurrentTime();a.duration=c.getDuration();a.videoURL=c.getVideoUrl();a.getVideoEmbedCode=c.getVideoEmbedCode();a.videoID=d.getVideoIDFromURL(a.videoURL);a.availableQualityLevels=c.getAvailableQualityLevels();return a}),
+videoId:g(function(a,b,c){return d.getVideoIDFromURL(c.ytplayer.getVideoUrl())}),size:g(function(a,b,c){if(typeof b!=="undefined"&&b.width&&b.height){c.ytplayer.setSize(b.width,b.height);e(c.ytplayer).css(b)}}),destroy:g(function(a,b,c){c.$player.removeClass("jquery-youtube-tubeplayer").data("opts.tubeplayer",null).unbind(".tubeplayer").html("");delete d.ytplayers[c.opts.playerID];var f=e.tubeplayer.defaults;a=["unstarted","ended","playing","paused","buffering","cued"];jQuery.each(a,function(i,h){delete f.onPlayer[h][c.opts.playerID]});
+a=["defaultError","notFound","notEmbeddable","invalidParameter"];jQuery.each(a,function(i,h){delete f.onErr[h][c.opts.playerID]});delete f.onQualityChange[c.opts.playerID];delete e.tubeplayer.events[c.opts.playerID];e(c.ytplayer).remove();return null}),player:g(function(a,b,c){return c.ytplayer})}})(jQuery);
Please sign in to comment.
Something went wrong with that request. Please try again.