15 lines
42 KiB
JavaScript
15 lines
42 KiB
JavaScript
|
/*
|
||
|
* jPlayer Plugin for jQuery JavaScript Library
|
||
|
* http://www.jplayer.org
|
||
|
*
|
||
|
* Copyright (c) 2009 - 2011 Happyworm Ltd
|
||
|
* Dual licensed under the MIT and GPL licenses.
|
||
|
* - http://www.opensource.org/licenses/mit-license.php
|
||
|
* - http://www.gnu.org/copyleft/gpl.html
|
||
|
*
|
||
|
* Author: Mark J Panaghiston
|
||
|
* Version: 2.1.0
|
||
|
* Date: 1st September 2011
|
||
|
*/
|
||
|
(function(a,b){a.fn.jPlayer=function(c){var d=typeof c=="string",e=Array.prototype.slice.call(arguments,1),g=this,c=!d&&e.length?a.extend.apply(null,[!0,c].concat(e)):c;return d&&c.charAt(0)==="_"?g:(d?this.each(function(){var d=a.data(this,"jPlayer"),h=d&&a.isFunction(d[c])?d[c].apply(d,e):d;if(h!==d&&h!==b)return g=h,!1}):this.each(function(){var b=a.data(this,"jPlayer");b?b.option(c||{}):a.data(this,"jPlayer",new a.jPlayer(c,this))}),g)},a.jPlayer=function(b,c){if(arguments.length){this.element=a(c),this.options=a.extend(!0,{},this.options,b);var d=this;this.element.bind("remove.jPlayer",function(){d.destroy()}),this._init()}},a.jPlayer.emulateMethods="load play pause",a.jPlayer.emulateStatus="src readyState networkState currentTime duration paused ended playbackRate",a.jPlayer.emulateOptions="muted volume",a.jPlayer.reservedEvent="ready flashreset resize repeat error warning",a.jPlayer.event={ready:"jPlayer_ready",flashreset:"jPlayer_flashreset",resize:"jPlayer_resize",repeat:"jPlayer_repeat",click:"jPlayer_click",error:"jPlayer_error",warning:"jPlayer_warning",loadstart:"jPlayer_loadstart",progress:"jPlayer_progress",suspend:"jPlayer_suspend",abort:"jPlayer_abort",emptied:"jPlayer_emptied",stalled:"jPlayer_stalled",play:"jPlayer_play",pause:"jPlayer_pause",loadedmetadata:"jPlayer_loadedmetadata",loadeddata:"jPlayer_loadeddata",waiting:"jPlayer_waiting",playing:"jPlayer_playing",canplay:"jPlayer_canplay",canplaythrough:"jPlayer_canplaythrough",seeking:"jPlayer_seeking",seeked:"jPlayer_seeked",timeupdate:"jPlayer_timeupdate",ended:"jPlayer_ended",ratechange:"jPlayer_ratechange",durationchange:"jPlayer_durationchange",volumechange:"jPlayer_volumechange"},a.jPlayer.htmlEvent="loadstart,abort,emptied,stalled,loadedmetadata,loadeddata,canplay,canplaythrough,ratechange".split(","),a.jPlayer.pause=function(){a.each(a.jPlayer.prototype.instances,function(a,b){b.data("jPlayer").status.srcSet&&b.jPlayer("pause")})},a.jPlayer.timeFormat={showHour:!1,showMin:!0,showSec:!0,padHour:!1,padMin:!0,padSec:!0,sepHour:":",sepMin:":",sepSec:""},a.jPlayer.convertTime=function(b){var c=new Date(b*1e3),d=c.getUTCHours(),b=c.getUTCMinutes(),c=c.getUTCSeconds(),d=a.jPlayer.timeFormat.padHour&&d<10?"0"+d:d,b=a.jPlayer.timeFormat.padMin&&b<10?"0"+b:b,c=a.jPlayer.timeFormat.padSec&&c<10?"0"+c:c;return(a.jPlayer.timeFormat.showHour?d+a.jPlayer.timeFormat.sepHour:"")+(a.jPlayer.timeFormat.showMin?b+a.jPlayer.timeFormat.sepMin:"")+(a.jPlayer.timeFormat.showSec?c+a.jPlayer.timeFormat.sepSec:"")},a.jPlayer.uaBrowser=function(a){var a=a.toLowerCase(),b=/(opera)(?:.*version)?[ \/]([\w.]+)/,c=/(msie) ([\w.]+)/,d=/(mozilla)(?:.*? rv:([\w.]+))?/,a=/(webkit)[ \/]([\w.]+)/.exec(a)||b.exec(a)||c.exec(a)||a.indexOf("compatible")<0&&d.exec(a)||[];return{browser:a[1]||"",version:a[2]||"0"}},a.jPlayer.uaPlatform=function(a){var b=a.toLowerCase(),c=/(android)/,d=/(mobile)/,a=/(ipad|iphone|ipod|android|blackberry|playbook|windows ce|webos)/.exec(b)||[],b=/(ipad|playbook)/.exec(b)||!d.exec(b)&&c.exec(b)||[];return a[1]&&(a[1]=a[1].replace(/\s/g,"_")),{platform:a[1]||"",tablet:b[1]||""}},a.jPlayer.browser={},a.jPlayer.platform={};var c=a.jPlayer.uaBrowser(navigator.userAgent);c.browser&&(a.jPlayer.browser[c.browser]=!0,a.jPlayer.browser.version=c.version),c=a.jPlayer.uaPlatform(navigator.userAgent),c.platform&&(a.jPlayer.platform[c.platform]=!0,a.jPlayer.platform.mobile=!c.tablet,a.jPlayer.platform.tablet=!!c.tablet),a.jPlayer.prototype={count:0,version:{script:"2.1.0",needFlash:"2.1.0",flash:"unknown"},options:{swfPath:"js",solution:"html, flash",supplied:"mp3",preload:"metadata",volume:.8,muted:!1,wmode:"opaque",backgroundColor:"#000000",cssSelectorAncestor:"#jp_container_1",cssSelector:{videoPlay:".jp-video-play",play:".jp-play",pause:".jp-pause",stop:".jp-stop",seekBar:".jp-seek-bar",playBar:".jp-play-bar",mute:".jp-mute",unmute:".jp-unmute",volumeBar:".jp-volume-bar",volumeBarValue:".jp-volume-bar-value",volumeMax:".jp-volume-max",currentTime:".jp-current-time",duration:".jp-duration",fullScreen:".jp-full-screen",restoreScreen:".jp-restore-screen",repeat:".jp-
|
||
|
.element.unbind(".jPlayerAutohide"),this.css.jq.gui.unbind(".jPlayerAutohide"),this.status.nativeVideoControls?this.css.jq.gui.hide():this.options.fullScreen&&this.options.autohide.full||!this.options.fullScreen&&this.options.autohide.restored?(this.element.bind("mousemove.jPlayer.jPlayerAutohide",b),this.css.jq.gui.bind("mousemove.jPlayer.jPlayerAutohide",b),this.css.jq.gui.hide()):this.css.jq.gui.show())},fullScreen:function(){this._setOption("fullScreen",!0)},restoreScreen:function(){this._setOption("fullScreen",!1)},_html_initMedia:function(){this.htmlElement.media.src=this.status.src,this.options.preload!=="none"&&this._html_load(),this._trigger(a.jPlayer.event.timeupdate)},_html_setAudio:function(b){var c=this;a.each(this.formats,function(a,d){if(c.html.support[d]&&b[d])return c.status.src=b[d],c.status.format[d]=!0,c.status.formatType=d,!1}),this.htmlElement.media=this.htmlElement.audio,this._html_initMedia()},_html_setVideo:function(b){var c=this;a.each(this.formats,function(a,d){if(c.html.support[d]&&b[d])return c.status.src=b[d],c.status.format[d]=!0,c.status.formatType=d,!1}),this.status.nativeVideoControls&&(this.htmlElement.video.poster=this._validString(b.poster)?b.poster:""),this.htmlElement.media=this.htmlElement.video,this._html_initMedia()},_html_resetMedia:function(){this.htmlElement.media&&(this.htmlElement.media.id===this.internal.video.id&&!this.status.nativeVideoControls&&this.internal.video.jq.css({width:"0px",height:"0px"}),this.htmlElement.media.pause())},_html_clearMedia:function(){this.htmlElement.media&&(this.htmlElement.media.src="",this.htmlElement.media.load())},_html_load:function(){this.status.waitForLoad&&(this.status.waitForLoad=!1,this.htmlElement.media.load()),clearTimeout(this.internal.htmlDlyCmdId)},_html_play:function(a){var b=this;this._html_load(),this.htmlElement.media.play();if(!isNaN(a))try{this.htmlElement.media.currentTime=a}catch(c){this.internal.htmlDlyCmdId=setTimeout(function(){b.play(a)},100);return}this._html_checkWaitForPlay()},_html_pause:function(a){var b=this;a>0?this._html_load():clearTimeout(this.internal.htmlDlyCmdId),this.htmlElement.media.pause();if(!isNaN(a))try{this.htmlElement.media.currentTime=a}catch(c){this.internal.htmlDlyCmdId=setTimeout(function(){b.pause(a)},100);return}a>0&&this._html_checkWaitForPlay()},_html_playHead:function(a){var b=this;this._html_load();try{if(typeof this.htmlElement.media.seekable=="object"&&this.htmlElement.media.seekable.length>0)this.htmlElement.media.currentTime=a*this.htmlElement.media.seekable.end(this.htmlElement.media.seekable.length-1)/100;else if(this.htmlElement.media.duration>0&&!isNaN(this.htmlElement.media.duration))this.htmlElement.media.currentTime=a*this.htmlElement.media.duration/100;else throw"e"}catch(c){this.internal.htmlDlyCmdId=setTimeout(function(){b.playHead(a)},100);return}this.status.waitForLoad||this._html_checkWaitForPlay()},_html_checkWaitForPlay:function(){this.status.waitForPlay&&(this.status.waitForPlay=!1,this.css.jq.videoPlay.length&&this.css.jq.videoPlay.hide(),this.status.video&&(this.internal.poster.jq.hide(),this.internal.video.jq.css({width:this.status.width,height:this.status.height})))},_html_volume:function(a){this.html.audio.available&&(this.htmlElement.audio.volume=a),this.html.video.available&&(this.htmlElement.video.volume=a)},_html_mute:function(a){this.html.audio.available&&(this.htmlElement.audio.muted=a),this.html.video.available&&(this.htmlElement.video.muted=a)},_flash_setAudio:function(b){var c=this;try{if(a.each(this.formats,function(a,d){if(c.flash.support[d]&&b[d]){switch(d){case"m4a":case"fla":c._getMovie().fl_setAudio_m4a(b[d]);break;case"mp3":c._getMovie().fl_setAudio_mp3(b[d])}return c.status.src=b[d],c.status.format[d]=!0,c.status.formatType=d,!1}}),this.options.preload==="auto")this._flash_load(),this.status.waitForLoad=!1}catch(d){this._flashError(d)}},_flash_setVideo:function(b){var c=this;try{if(a.each(this.formats,function(a,d){if(c.flash.support[d]&&b[d]){switch(d){case"m4v":case"flv":c._getMovie().fl_setVideo_m4v(b[d])}return c.status.src=b[d],c.status.for
|