diff --git a/dist/plyr.js b/dist/plyr.js index 5f835925e..89916420a 100644 --- a/dist/plyr.js +++ b/dist/plyr.js @@ -1,2 +1,2 @@ !function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=t(e,document):"function"==typeof define&&define.amd?define(null,function(){t(e,document)}):e.plyr=t(e,document)}("undefined"!=typeof window?window:this,function(e,t){"use strict";function n(){var e,n,r,s=navigator.userAgent,a=navigator.appName,o=""+parseFloat(navigator.appVersion),i=parseInt(navigator.appVersion,10);return-1!==navigator.appVersion.indexOf("Windows NT")&&-1!==navigator.appVersion.indexOf("rv:11")?(a="IE",o="11;"):-1!==(n=s.indexOf("MSIE"))?(a="IE",o=s.substring(n+5)):-1!==(n=s.indexOf("Chrome"))?(a="Chrome",o=s.substring(n+7)):-1!==(n=s.indexOf("Safari"))?(a="Safari",o=s.substring(n+7),-1!==(n=s.indexOf("Version"))&&(o=s.substring(n+8))):-1!==(n=s.indexOf("Firefox"))?(a="Firefox",o=s.substring(n+8)):(e=s.lastIndexOf(" ")+1)<(n=s.lastIndexOf("/"))&&(a=s.substring(e,n),o=s.substring(n+1),a.toLowerCase()==a.toUpperCase()&&(a=navigator.appName)),-1!==(r=o.indexOf(";"))&&(o=o.substring(0,r)),-1!==(r=o.indexOf(" "))&&(o=o.substring(0,r)),i=parseInt(""+o,10),isNaN(i)&&(o=""+parseFloat(navigator.appVersion),i=parseInt(navigator.appVersion,10)),{name:a,version:i,ios:/(iPad|iPhone|iPod)/g.test(navigator.platform),touch:"ontouchstart"in t.documentElement}}function r(e,t){var n=e.media;if("video"==e.type)switch(t){case"video/webm":return!(!n.canPlayType||!n.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/no/,""));case"video/mp4":return!(!n.canPlayType||!n.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"').replace(/no/,""));case"video/ogg":return!(!n.canPlayType||!n.canPlayType('video/ogg; codecs="theora"').replace(/no/,""))}else if("audio"==e.type)switch(t){case"audio/mpeg":return!(!n.canPlayType||!n.canPlayType("audio/mpeg;").replace(/no/,""));case"audio/ogg":return!(!n.canPlayType||!n.canPlayType('audio/ogg; codecs="vorbis"').replace(/no/,""));case"audio/wav":return!(!n.canPlayType||!n.canPlayType('audio/wav; codecs="1"').replace(/no/,""))}return!1}function s(e){if(!t.querySelectorAll('script[src="'+e+'"]').length){var n=t.createElement("script");n.src=e;var r=t.getElementsByTagName("script")[0];r.parentNode.insertBefore(n,r)}}function a(e,t){return Array.prototype.indexOf&&-1!=e.indexOf(t)}function o(e,t,n){return e.replace(new RegExp(t.replace(/([.*+?\^=!:${}()|\[\]\/\\])/g,"\\$1"),"g"),n)}function i(e,t){e.length||(e=[e]);for(var n=e.length-1;n>=0;n--){var r=n>0?t.cloneNode(!0):t,s=e[n],a=s.parentNode,o=s.nextSibling;r.appendChild(s),o?a.insertBefore(r,o):a.appendChild(r)}}function l(e){for(var t=e.parentNode;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}function u(e){e&&e.parentNode.removeChild(e)}function c(e,t){e.insertBefore(t,e.firstChild)}function p(e,t){for(var n in t)e.setAttribute(n,"boolean"==typeof t[n]&&t[n]?"":t[n])}function d(e,n,r){var s=t.createElement(e);p(s,r),c(n,s)}function f(e){return e.replace(".","")}function m(e,t,n){if(e)if(e.classList)e.classList[n?"add":"remove"](t);else{var r=(" "+e.className+" ").replace(/\s+/g," ").replace(" "+t+" ","");e.className=r+(n?" "+t:"")}}function y(e,t){return e?e.classList?e.classList.contains(t):new RegExp("(\\s|^)"+t+"(\\s|$)").test(e.className):!1}function b(e,t,n){e&&h(e,t,n,!0)}function v(e,t,n){e&&h(e,t,n,!1)}function g(e,t,n,r){b(e,t,function(t){n&&n.apply(e,[t]),r.apply(e,[t])})}function h(e,t,n,r){var s=t.split(" ");if(e instanceof NodeList)for(var a=0;ar;r++){var s=e[r];for(var a in s)s[a]&&s[a].constructor&&s[a].constructor===Object?(t[a]=t[a]||{},T(t[a],s[a])):t[a]=s[a]}return t}}function _(){var e={supportsFullScreen:!1,isFullScreen:function(){return!1},requestFullScreen:function(){},cancelFullScreen:function(){},fullScreenEventName:"",element:null,prefix:""},n="webkit moz o ms khtml".split(" ");if("undefined"!=typeof t.cancelFullScreen)e.supportsFullScreen=!0;else for(var r=0,s=n.length;s>r;r++){if(e.prefix=n[r],"undefined"!=typeof t[e.prefix+"CancelFullScreen"]){e.supportsFullScreen=!0;break}if("undefined"!=typeof t.msExitFullscreen&&t.msFullscreenEnabled){e.prefix="ms",e.supportsFullScreen=!0;break}}return e.supportsFullScreen&&(e.fullScreenEventName="ms"==e.prefix?"MSFullscreenChange":e.prefix+"fullscreenchange",e.isFullScreen=function(e){switch("undefined"==typeof e&&(e=t.body),this.prefix){case"":return t.fullscreenElement==e;case"moz":return t.mozFullScreenElement==e;default:return t[this.prefix+"FullscreenElement"]==e}},e.requestFullScreen=function(e){return"undefined"==typeof e&&(e=t.body),""===this.prefix?e.requestFullScreen():e[this.prefix+("ms"==this.prefix?"RequestFullscreen":"RequestFullScreen")]()},e.cancelFullScreen=function(){return""===this.prefix?t.cancelFullScreen():t[this.prefix+("ms"==this.prefix?"ExitFullscreen":"CancelFullScreen")]()},e.element=function(){return""===this.prefix?t.fullscreenElement:t[this.prefix+"FullscreenElement"]}),e}function F(){var t={supported:function(){if(!("localStorage"in e))return!1;try{e.localStorage.setItem("___test","OK");var t=e.localStorage.getItem("___test");return e.localStorage.removeItem("___test"),"OK"===t}catch(n){return!1}return!1}()};return t}function C(h,T){function C(t,n){T.debug&&e.console&&console[n?"warn":"log"](t)}function A(){var e=['
','
','','','',"0% "+T.i18n.played,"",'',"0% "+T.i18n.buffered,""];return T.tooltips.seek&&e.push('00:00'),e.push("
",''),a(T.controls,"restart")&&e.push('"),a(T.controls,"rewind")&&e.push('"),a(T.controls,"play")&&e.push('",'"),a(T.controls,"fast-forward")&&e.push('"),a(T.controls,"current-time")&&e.push('',''+T.i18n.currentTime+"",'00:00',""),a(T.controls,"duration")&&e.push('',''+T.i18n.duration+"",'00:00',""),e.push("",''),a(T.controls,"mute")&&e.push('"),a(T.controls,"volume")&&e.push('",''),a(T.controls,"captions")&&e.push('"),a(T.controls,"fullscreen")&&e.push('"),e.push("","
"),e.join("")}function I(){if(Ce.supported.full&&("audio"!=Ce.type||T.fullscreen.allowAudio)&&T.fullscreen.enabled){var e=E.supportsFullScreen;e||T.fullscreen.fallback&&!R()?(C((e?"Native":"Fallback")+" fullscreen enabled"),m(Ce.container,T.classes.fullscreen.enabled,!0)):C("Fullscreen not supported and fallback disabled"),w(Ce.buttons.fullscreen,!1),j(),T.fullscreen.hideControls&&m(Ce.container,T.classes.fullscreen.hideControls,!0)}}function P(){if("video"===Ce.type){q(T.selectors.captions)||Ce.videoContainer.insertAdjacentHTML("afterbegin",'
'),Ce.usingTextTracks=!1,Ce.media.textTracks&&(Ce.usingTextTracks=!0);for(var e,t="",n=Ce.media.childNodes,r=0;r=10||"Firefox"===Ce.browser.name&&Ce.browser.version>=31)&&(C("Detected browser with known TextTrack issues - using manual fallback"),Ce.usingTextTracks=!1),Ce.usingTextTracks){C("TextTracks supported");for(var o=0;o ");for(var r=0;rCe.captions.length-1){Ce.subcount=Ce.captions.length-1;break}Ce.media.currentTime.toFixed(1)>=n(Ce.captions[Ce.subcount][0])&&Ce.media.currentTime.toFixed(1)<=r(Ce.captions[Ce.subcount][0])?(Ce.currentCaption=Ce.captions[Ce.subcount][1],M(Ce.currentCaption)):M()}}function O(){Ce.buttons.captions&&(m(Ce.container,T.classes.captions.enabled,!0),T.captions.defaultActive&&(m(Ce.container,T.classes.captions.active,!0),w(Ce.buttons.captions,!0)))}function V(e){return Ce.container.querySelectorAll(e)}function q(e){return V(e)[0]}function R(){try{return e.self!==e.top}catch(t){return!0}}function j(){function e(e){9===e.which&&Ce.isFullscreen&&(e.target!==r||e.shiftKey?e.target===n&&e.shiftKey&&(e.preventDefault(),r.focus()):(e.preventDefault(),n.focus()))}var t=V("input:not([disabled]), button:not([disabled])"),n=t[0],r=t[t.length-1];b(Ce.container,"keydown",e)}function H(e,t){if("string"==typeof t)d(e,Ce.media,{src:t});else if(t.constructor===Array)for(var n=t.length-1;n>=0;n--)d(e,Ce.media,t[n])}function B(){var e=T.html;C("Injecting custom controls"),e||(e=A()),e=o(e,"{seektime}",T.seekTime),e=o(e,"{id}",Math.floor(1e4*Math.random()));var n;if(null!==T.selectors.controls.container&&(n=T.selectors.controls.container,"string"==typeof selector&&(n=t.querySelector(n))),n instanceof HTMLElement||(n=Ce.container),n.insertAdjacentHTML("beforeend",e),T.tooltips.controls)for(var r=V(T.selectors.labels+" ."+T.classes.hidden),s=r.length-1;s>=0;s--){var a=r[s];m(a,T.classes.hidden,!1),m(a,T.classes.tooltip,!0)}}function D(){try{return Ce.controls=q(T.selectors.controls.wrapper),Ce.buttons={},Ce.buttons.seek=q(T.selectors.buttons.seek),Ce.buttons.play=q(T.selectors.buttons.play),Ce.buttons.pause=q(T.selectors.buttons.pause),Ce.buttons.restart=q(T.selectors.buttons.restart),Ce.buttons.rewind=q(T.selectors.buttons.rewind),Ce.buttons.forward=q(T.selectors.buttons.forward),Ce.buttons.fullscreen=q(T.selectors.buttons.fullscreen),Ce.buttons.volume=q(T.selectors.buttons.volume),Ce.buttons.mute=q(T.selectors.buttons.mute),Ce.buttons.captions=q(T.selectors.buttons.captions),Ce.checkboxes=V('[type="checkbox"]'),Ce.progress={},Ce.progress.container=q(T.selectors.progress.container),Ce.progress.buffer={},Ce.progress.buffer.bar=q(T.selectors.progress.buffer),Ce.progress.buffer.text=Ce.progress.buffer.bar&&Ce.progress.buffer.bar.getElementsByTagName("span")[0],Ce.progress.played={},Ce.progress.played.bar=q(T.selectors.progress.played),Ce.progress.played.text=Ce.progress.played.bar&&Ce.progress.played.bar.getElementsByTagName("span")[0],Ce.progress.tooltip=Ce.progress.container&&Ce.progress.container.querySelector("."+T.classes.tooltip),Ce.volume=q(T.selectors.buttons.volume),Ce.duration=q(T.selectors.duration),Ce.currentTime=q(T.selectors.currentTime),Ce.seekTime=V(T.selectors.seekTime),!0}catch(e){return C("It looks like there is a problem with your controls html",!0),$(!0),!1}}function Y(){m(Ce.container,N.selectors.container.replace(".",""),Ce.supported.full)}function $(e){e?Ce.media.setAttribute("controls",""):Ce.media.removeAttribute("controls")}function W(e){var t=T.i18n.play;"undefined"!=typeof T.title&&T.title.length&&(t+=", "+T.title),Ce.supported.full&&Ce.buttons.play&&Ce.buttons.play.setAttribute("aria-label",t),e instanceof HTMLElement&&e.setAttribute("title",T.i18n.frameTitle.replace("{title}",T.title))}function z(){if(!Ce.media)return C("No audio or video element found",!0),!1;if(Ce.supported.full&&(m(Ce.container,T.classes.type.replace("{0}",Ce.type),!0),m(Ce.container,T.classes.stopped,T.autoplay),m(Ce.container,T.classes.isIos,Ce.browser.ios),m(Ce.container,T.classes.isTouch,Ce.browser.touch),"video"===Ce.type)){var e=t.createElement("div");e.setAttribute("class",T.classes.videoWrapper),i(Ce.media,e),Ce.videoContainer=e}a(T.types.embed,Ce.type)?(K(),Ce.embedId=null):T.autoplay&&G()}function K(){for(var n=t.createElement("div"),r=Ce.embedId,a=Ce.type+"-"+Math.floor(1e4*Math.random()),o=V('[id^="'+Ce.type+'-"]'),i=o.length-1;i>=0;i--)u(o[i]);if(m(Ce.media,T.classes.videoWrapper,!0),m(Ce.media,T.classes.embedWrapper,!0),"youtube"===Ce.type)Ce.media.appendChild(n),n.setAttribute("id",a),"object"==typeof YT?X(r,n):(s(T.urls.youtube.api),e.onYouTubeReadyCallbacks=e.onYouTubeReadyCallbacks||[],e.onYouTubeReadyCallbacks.push(function(){X(r,n)}),e.onYouTubeIframeAPIReady=function(){e.onYouTubeReadyCallbacks.forEach(function(e){e()})});else if("vimeo"===Ce.type){var l=t.createElement("iframe");l.loaded=!1,b(l,"load",function(){l.loaded=!0}),p(l,{src:"https://player.vimeo.com/video/"+r+"?player_id="+a+"&api=1&badge=0&byline=0&portrait=0&title=0",id:a,webkitallowfullscreen:"",mozallowfullscreen:"",allowfullscreen:"",frameborder:0}),Ce.supported.full?(n.appendChild(l),Ce.media.appendChild(n)):Ce.media.appendChild(l),"$f"in e||s(T.urls.vimeo.api);var c=e.setInterval(function(){"$f"in e&&l.loaded&&(e.clearInterval(c),J.call(l))},50)}}function U(){Fe(),W(q("iframe"))}function X(t,n){"timer"in Ce||(Ce.timer={}),Ce.embed=new YT.Player(n.id,{videoId:t,playerVars:{autoplay:0,controls:Ce.supported.full?0:1,rel:0,showinfo:0,iv_load_policy:3,cc_load_policy:T.captions.defaultActive?1:0,cc_lang_pref:"en",wmode:"transparent",modestbranding:1,disablekb:1,origin:"*"},events:{onReady:function(t){var n=t.target;Ce.media.play=function(){n.playVideo(),Ce.media.paused=!1},Ce.media.pause=function(){n.pauseVideo(),Ce.media.paused=!0},Ce.media.stop=function(){n.stopVideo(),Ce.media.paused=!0},Ce.media.duration=n.getDuration(),Ce.media.paused=!0,Ce.media.currentTime=n.getCurrentTime(),Ce.media.muted=n.isMuted(),k(Ce.media,"timeupdate"),e.clearInterval(Ce.timer.buffering),Ce.timer.buffering=e.setInterval(function(){Ce.media.buffered=n.getVideoLoadedFraction(),k(Ce.media,"progress"),1===Ce.media.buffered&&(e.clearInterval(Ce.timer.buffering),k(Ce.media,"canplaythrough"))},200),U(),me()},onStateChange:function(t){var n=t.target;switch(e.clearInterval(Ce.timer.playing),t.data){case 0:Ce.media.paused=!0,k(Ce.media,"ended");break;case 1:Ce.media.paused=!1,Ce.media.seeking=!1,k(Ce.media,"play"),k(Ce.media,"playing"),Ce.timer.playing=e.setInterval(function(){Ce.media.currentTime=n.getCurrentTime(),k(Ce.media,"timeupdate")},100);break;case 2:Ce.media.paused=!0,k(Ce.media,"pause")}}}})}function J(){Ce.embed=$f(this),Ce.embed.addEvent("ready",function(){Ce.media.play=function(){Ce.embed.api("play"),Ce.media.paused=!1},Ce.media.pause=function(){Ce.embed.api("pause"),Ce.media.paused=!0},Ce.media.stop=function(){Ce.embed.api("stop"),Ce.media.paused=!0},Ce.media.paused=!0,Ce.media.currentTime=0,U(),Ce.embed.api("getCurrentTime",function(e){Ce.media.currentTime=e,k(Ce.media,"timeupdate")}),Ce.embed.api("getDuration",function(e){Ce.media.duration=e,me()}),Ce.embed.addEvent("play",function(){Ce.media.paused=!1,k(Ce.media,"play"),k(Ce.media,"playing")}),Ce.embed.addEvent("pause",function(){Ce.media.paused=!0,k(Ce.media,"pause")}),Ce.embed.addEvent("playProgress",function(e){Ce.media.seeking=!1,Ce.media.currentTime=e.seconds,k(Ce.media,"timeupdate")}),Ce.embed.addEvent("loadProgress",function(e){Ce.media.buffered=e.percent,k(Ce.media,"progress"),1===parseInt(e.percent)&&k(Ce.media,"canplaythrough")}),Ce.embed.addEvent("finish",function(){Ce.media.paused=!0,k(Ce.media,"ended")})})}function G(){"play"in Ce.media&&Ce.media.play()}function Q(){"pause"in Ce.media&&Ce.media.pause()}function Z(e){e===!0?G():e===!1?Q():Ce.media[Ce.media.paused?"play":"pause"]()}function ee(e){"number"!=typeof e&&(e=T.seekTime),ne(Ce.media.currentTime-e)}function te(e){"number"!=typeof e&&(e=T.seekTime),ne(Ce.media.currentTime+e)}function ne(e){var t=0,n=Ce.media.paused,r=re();"number"==typeof e?t=e:"object"!=typeof e||"input"!==e.type&&"change"!==e.type||(t=e.target.value/e.target.max*r),0>t?t=0:t>r&&(t=r);try{Ce.media.currentTime=t.toFixed(1)}catch(s){}if(a(T.types.embed,Ce.type)){switch(Ce.type){case"youtube":Ce.embed.seekTo(t);break;case"vimeo":Ce.embed.api("seekTo",t.toFixed(0))}n&&Q(),k(Ce.media,"timeupdate"),Ce.media.seeking=!0}C("Seeking to "+Ce.media.currentTime+" seconds"),L(t)}function re(){var e=parseInt(T.duration);return isNaN(e)?Ce.media.duration:e}function se(){m(Ce.container,T.classes.playing,!Ce.media.paused),m(Ce.container,T.classes.stopped,Ce.media.paused)}function ae(e){var n=E.supportsFullScreen;e&&e.type===E.fullScreenEventName?Ce.isFullscreen=E.isFullScreen(Ce.container):n?(E.isFullScreen(Ce.container)?E.cancelFullScreen():E.requestFullScreen(Ce.container),Ce.isFullscreen=E.isFullScreen(Ce.container)):(Ce.isFullscreen=!Ce.isFullscreen,Ce.isFullscreen?(b(t,"keyup",oe),t.body.style.overflow="hidden"):(v(t,"keyup",oe),t.body.style.overflow="")),m(Ce.container,T.classes.fullscreen.active,Ce.isFullscreen),Ce.isFullscreen?Ce.container.setAttribute("tabindex","-1"):Ce.container.removeAttribute("tabindex"),j(Ce.isFullscreen),w(Ce.buttons.fullscreen,Ce.isFullscreen),T.fullscreen.hideControls&&ve(!0),k(Ce.container,Ce.isFullscreen?"enterfullscreen":"exitfullscreen")}function oe(e){27===(e.which||e.charCode||e.keyCode)&&Ce.isFullscreen&&ae()}function ie(e){if("boolean"!=typeof e&&(e=!Ce.media.muted),w(Ce.buttons.mute,e),Ce.media.muted=e,a(T.types.embed,Ce.type)){switch(Ce.type){case"youtube":Ce.embed[Ce.media.muted?"mute":"unMute"]();break;case"vimeo":Ce.embed.api("setVolume",Ce.media.muted?0:parseFloat(T.volume/10))}k(Ce.media,"volumechange")}}function le(t){if("undefined"==typeof t&&(t=T.volume,T.storage.enabled&&F().supported&&(t=e.localStorage.getItem(T.storage.key),e.localStorage.removeItem("plyr-volume"))),(null===t||isNaN(t))&&(t=T.volume),t>10&&(t=10),0>t&&(t=0),Ce.media.volume=parseFloat(t/10),T.volume=t,a(T.types.embed,Ce.type)){switch(Ce.type){case"youtube":Ce.embed.setVolume(100*Ce.media.volume);break;case"vimeo":Ce.embed.api("setVolume",Ce.media.volume)}k(Ce.media,"volumechange")}Ce.media.muted&&t>0&&ie()}function ue(){var t=Ce.media.muted?0:10*Ce.media.volume;Ce.supported.full&&Ce.volume&&(Ce.volume.value=t),T.storage.enabled&&F().supported&&!isNaN(t)&&e.localStorage.setItem(T.storage.key,t),m(Ce.container,T.classes.muted,0===t),Ce.supported.full&&Ce.buttons.mute&&w(Ce.buttons.mute,0===t)}function ce(e){Ce.supported.full&&Ce.buttons.captions&&("boolean"!=typeof e&&(e=-1===Ce.container.className.indexOf(T.classes.captions.active)),Ce.captionsEnabled=e,w(Ce.buttons.captions,Ce.captionsEnabled),m(Ce.container,T.classes.captions.active,Ce.captionsEnabled),k(Ce.container,Ce.captionsEnabled?"captionsenabled":"captionsdisabled"))}function pe(e){var t="waiting"===e.type;clearTimeout(Ce.timers.loading),Ce.timers.loading=setTimeout(function(){m(Ce.container,T.classes.loading,t)},t?250:0)}function de(e){var t=Ce.progress.played.bar,n=Ce.progress.played.text,r=0,s=re();if(e)switch(e.type){case"timeupdate":case"seeking":r=x(Ce.media.currentTime,s),"timeupdate"==e.type&&Ce.buttons.seek&&(Ce.buttons.seek.value=r);break;case"change":case"input":r=e.target.value;break;case"playing":case"progress":t=Ce.progress.buffer.bar,n=Ce.progress.buffer.text,r=function(){var e=Ce.media.buffered;return e&&e.length?x(e.end(0),s):"number"==typeof e?100*e:0}()}t&&(t.value=r),n&&(n.innerHTML=r)}function fe(e,t){if(t){isNaN(e)&&(e=0),Ce.secs=parseInt(e%60),Ce.mins=parseInt(e/60%60),Ce.hours=parseInt(e/60/60%60);var n=parseInt(re()/60/60%60)>0;Ce.secs=("0"+Ce.secs).slice(-2),Ce.mins=("0"+Ce.mins).slice(-2),t.innerHTML=(n?Ce.hours+":":"")+Ce.mins+":"+Ce.secs}}function me(){if(Ce.supported.full){var e=re()||0;!Ce.duration&&T.displayDuration&&Ce.media.paused&&fe(e,Ce.currentTime),Ce.duration&&fe(e,Ce.duration),be()}}function ye(e){fe(Ce.media.currentTime,Ce.currentTime),e&&"timeupdate"==e.type&&Ce.media.seeking||de(e)}function be(e){if(T.tooltips.seek&&!Ce.browser.touch){var t=Ce.progress.container.getBoundingClientRect(),n=0,r=T.classes.tooltip+"--visible";if(e)n=100/t.width*(e.pageX-t.left);else{if(!y(Ce.progress.tooltip,r))return;n=Ce.progress.tooltip.style.left.replace("%","")}0>n?n=0:n>100&&(n=100),fe(re()/100*n,Ce.progress.tooltip),Ce.progress.tooltip.style.left=n+"%",e&&a(["mouseenter","mouseleave"],e.type)&&m(Ce.progress.tooltip,r,"mouseenter"===e.type)}}function ve(t){Ce.isFullscreen&&(m(Ce.container,T.classes.hover,!0),e.clearTimeout(Ce.timers.hover),Ce.timers.hover=e.setTimeout(function(){Ce.controls.mouseover&&t!==!0||m(Ce.container,T.classes.hover,!1)},2e3))}function ge(e){if("undefined"!=typeof e)return void he(e);var t;switch(Ce.type){case"youtube":t=Ce.embed.getVideoUrl();break;case"vimeo":Ce.embed.api("getVideoUrl",function(e){t=e});break;default:t=Ce.media.currentSrc}return t||""}function he(n){if(!("undefined"!=typeof n&&"sources"in n&&n.sources.length))return void C("Invalid source format",!0);if(Q(),"youtube"===Ce.type?(Ce.embed.destroy(),e.clearInterval(Ce.timer.buffering),e.clearInterval(Ce.timer.playing)):"video"===Ce.type&&Ce.videoContainer&&u(Ce.videoContainer),u(Ce.media),"type"in n&&(Ce.type=n.type,"video"===Ce.type)){var r=n.sources[0];"type"in r&&a(T.types.embed,r.type)&&(Ce.type=r.type)}switch(Ce.supported=S.supported(Ce.type),Ce.type){case"video":Ce.media=t.createElement("video");break;case"audio":Ce.media=t.createElement("audio");break;case"youtube":case"vimeo":Ce.media=t.createElement("div"),Ce.embedId=n.sources[0].src}c(Ce.container,Ce.media),a(T.types.html5,Ce.type)&&(T.crossorigin&&Ce.media.setAttribute("crossorigin",""),T.autoplay&&Ce.media.setAttribute("autoplay",""),"poster"in n&&Ce.media.setAttribute("poster",n.poster),T.loop&&Ce.media.setAttribute("loop","")),Ce.container.className=Ce.originalClassName,m(Ce.container,T.classes.fullscreen.active,Ce.isFullscreen),m(Ce.container,T.classes.captions.active,Ce.captionsEnabled),Y(),T.autoplay=n.autoplay||T.autoplay,a(T.types.html5,Ce.type)&&H("source",n.sources),z(),a(T.types.html5,Ce.type)&&("tracks"in n&&H("track",n.tracks),Ce.media.load(),Fe(),me()),T.autoplay&&G(),"title"in n&&(T.title=n.title,W()),Ce.container.plyr.media=Ce.media}function ke(e){"video"===Ce.type&&Ce.media.setAttribute("poster",e)}function we(){function n(){var e=Ce.media.paused;e?G():Q();var t=Ce.buttons[e?"play":"pause"],n=Ce.buttons[e?"pause":"play"];if(n){var r=y(t,T.classes.tabFocus);setTimeout(function(){n.focus(),r&&(m(t,T.classes.tabFocus,!1),m(n,T.classes.tabFocus,!0))},100)}}function r(){var e=t.activeElement;e&&e!=t.body?t.querySelector&&(e=t.querySelector(":focus")):e=null;for(var n in Ce.buttons){var r=Ce.buttons[n];m(r,T.classes.tabFocus,r===e)}}var s="IE"==Ce.browser.name?"change":"input";b(e,"keyup",function(e){var t=e.keyCode?e.keyCode:e.which;9==t&&r()}),b(t.body,"click",function(){m(q("."+T.classes.tabFocus),T.classes.tabFocus,!1)});for(var a in Ce.buttons){var o=Ce.buttons[a];b(o,"blur",function(){m(o,"tab-focus",!1)})}g(Ce.buttons.play,"click",T.listeners.play,n),g(Ce.buttons.pause,"click",T.listeners.pause,n),g(Ce.buttons.restart,"click",T.listeners.restart,ne),g(Ce.buttons.rewind,"click",T.listeners.rewind,ee),g(Ce.buttons.forward,"click",T.listeners.forward,te),g(Ce.buttons.seek,s,T.listeners.seek,ne),g(Ce.volume,s,T.listeners.volume,function(){le(Ce.volume.value)}),g(Ce.buttons.mute,"click",T.listeners.mute,ie),g(Ce.buttons.fullscreen,"click",T.listeners.fullscreen,ae),E.supportsFullScreen&&b(t,E.fullScreenEventName,ae),b(Ce.buttons.captions,"click",ce),b(Ce.progress.container,"mouseenter mouseleave mousemove",be);T.fullscreen.hideControls&&b(Ce.controls,"mouseenter mouseleave",function(e){Ce.controls.mouseover="mouseenter"===e.type})}function xe(){b(Ce.media,"timeupdate seeking",ye),b(Ce.media,"timeupdate",L),b(Ce.media,"durationchange loadedmetadata",me),b(Ce.media,"ended",function(){"video"===Ce.type&&M(),se()}),b(Ce.media,"progress playing",de),b(Ce.media,"volumechange",ue),b(Ce.media,"play pause",se),b(Ce.media,"waiting canplay seeked",pe),T.click&&b(Ce.media,"click",function(){Ce.media.paused?G():Ce.media.ended?(ne(),G()):Q()}),T.fullscreen.hideControls&&b(Ce.media,"mousemove",ve),b(Ce.media,T.events.join(" "),function(e){k(Ce.container,e.type)})}function Te(){if(!Ce.init)return null;if(Ce.container.setAttribute("class",f(T.selectors.container)),Ce.init=!1,u(q(T.selectors.controls.wrapper)),"youtube"===Ce.type)return void Ce.embed.destroy();"video"===Ce.type&&(u(q(T.selectors.captions)),l(Ce.videoContainer)),$(!0);var e=Ce.media.cloneNode(!0);Ce.media.parentNode.replaceChild(e,Ce.media)}function _e(){if(Ce.init)return null;E=_(),Ce.browser=n(),Ce.media=Ce.container.querySelectorAll("audio, video, div")[0],Ce.originalClassName=Ce.container.className;var e=Ce.media.tagName.toLowerCase();if("div"===e?(Ce.type=Ce.media.getAttribute("data-type"),Ce.embedId=Ce.media.getAttribute("data-video-id"),Ce.media.removeAttribute("data-type"),Ce.media.removeAttribute("data-video-id")):(Ce.type=e,T.crossorigin=null!==Ce.media.getAttribute("crossorigin"),T.autoplay=T.autoplay||null!==Ce.media.getAttribute("autoplay"),T.loop=T.loop||null!==Ce.media.getAttribute("loop")),Ce.supported=S.supported(Ce.type),Y(),!Ce.supported.basic)return!1;if(C(Ce.browser.name+" "+Ce.browser.version),z(),a(T.types.html5,Ce.type)){if(!Ce.supported.full)return void(Ce.init=!0);Fe(),W()}Ce.init=!0}function Fe(){if(!Ce.supported.full)return C("No full support for this media type ("+Ce.type+")",!0),u(q(T.selectors.controls.wrapper)),void $(!0);var e=!V(T.selectors.controls.wrapper).length;e&&B(),D()&&(e&&we(),xe(),$(),I(),P(),le(),ue(),ye(),se(),me())}var Ce=this;return Ce.container=h,Ce.timers={},C(T),_e(),Ce.init?{media:Ce.media,play:G,pause:Q,restart:ne,rewind:ee,forward:te,seek:ne,source:ge,poster:ke,setVolume:le,togglePlay:Z,toggleMute:ie,toggleCaptions:ce,toggleFullscreen:ae,isFullscreen:function(){return Ce.isFullscreen||!1},support:function(e){return r(Ce,e)},destroy:Te,restore:_e}:{}}var E,S={},N={enabled:!0,debug:!1,autoplay:!1,loop:!1,seekTime:10,volume:5,duration:null,displayDuration:!0,iconPrefix:"icon",click:!0,tooltips:{controls:!1,seek:!0},selectors:{container:".plyr",controls:{container:null,wrapper:".plyr__controls"},labels:"[data-plyr]",buttons:{seek:'[data-plyr="seek"]',play:'[data-plyr="play"]',pause:'[data-plyr="pause"]',restart:'[data-plyr="restart"]',rewind:'[data-plyr="rewind"]',forward:'[data-plyr="fast-forward"]',mute:'[data-plyr="mute"]',volume:'[data-plyr="volume"]',captions:'[data-plyr="captions"]',fullscreen:'[data-plyr="fullscreen"]'},progress:{container:".plyr__progress",buffer:".plyr__progress--buffer",played:".plyr__progress--played"},captions:".plyr__captions",currentTime:".plyr__time--current",duration:".plyr__time--duration"},classes:{videoWrapper:"plyr__video-wrapper",embedWrapper:"plyr__video-embed",type:"plyr--{0}",stopped:"plyr--stopped",playing:"plyr--playing",muted:"plyr--muted",loading:"plyr--loading",hover:"plyr--hover",tooltip:"plyr__tooltip",hidden:"plyr__sr-only",isIos:"plyr--is-ios",isTouch:"plyr--is-touch",captions:{enabled:"plyr--captions-enabled",active:"plyr--captions-active"},fullscreen:{enabled:"plyr--fullscreen-enabled",active:"plyr--fullscreen-active",hideControls:"plyr--fullscreen--hide-controls"},tabFocus:"tab-focus"},captions:{defaultActive:!1},fullscreen:{enabled:!0,fallback:!0,hideControls:!0,allowAudio:!1},storage:{enabled:!0,key:"plyr"},controls:["restart","rewind","play","fast-forward","current-time","duration","mute","volume","captions","fullscreen"],i18n:{restart:"Restart",rewind:"Rewind {seektime} secs",play:"Play",pause:"Pause",forward:"Forward {seektime} secs",played:"played",buffered:"buffered",currentTime:"Current time",duration:"Duration",volume:"Volume",toggleMute:"Toggle Mute",toggleCaptions:"Toggle Captions",toggleFullscreen:"Toggle Fullscreen",frameTitle:"Player for {title}"},types:{embed:["youtube","vimeo"],html5:["video","audio"]},urls:{vimeo:{api:"https://cdn.plyr.io/froogaloop/1.0.0/plyr.froogaloop.js"},youtube:{api:"https://www.youtube.com/iframe_api"}},listeners:{seek:null,play:null,pause:null,restart:null,rewind:null,forward:null,mute:null,volume:null,captions:null,fullscreen:null},events:["ended","progress","stalled","playing","waiting","canplay","canplaythrough","loadstart","loadeddata","loadedmetadata","timeupdate","volumechange","play","pause","error","seeking","emptied"]};return S.supported=function(e){var r,s,a=n(),o="IE"===a.name&&a.version<=9,i=/iPhone|iPod/i.test(navigator.userAgent),l=!!t.createElement("audio").canPlayType,u=!!t.createElement("video").canPlayType; -switch(e){case"video":r=u,s=r&&!o&&!i;break;case"audio":r=l,s=r&&!o;break;case"vimeo":case"youtube":r=!0,s=!o&&!i;break;default:r=l&&u,s=r&&!o}return{basic:r,full:s}},S.setup=function(e,n){var r=[];if("string"==typeof e?e=t.querySelectorAll(e):e instanceof HTMLElement?e=[e]:e instanceof NodeList||"string"==typeof e||("undefined"==typeof n&&"object"==typeof e&&(n=e),e=t.querySelectorAll(N.selectors.container)),!S.supported().basic||!e.length)return!1;for(var s=e.length-1;s>=0;s--){var a=e[s];if("undefined"==typeof a.plyr){var o=T(N,n,JSON.parse(a.getAttribute("data-plyr")));if(!o.enabled)return;var i=new C(a,o);a.plyr=Object.keys(i).length?i:!1,k(a,"setup",{plyr:a.plyr})}r.push(a.plyr)}return r},S}),function(){function e(e,t){t=t||{bubbles:!1,cancelable:!1,detail:void 0};var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),n}e.prototype=window.Event.prototype,"CustomEvent"in window||(window.CustomEvent=e)}(); \ No newline at end of file +switch(e){case"video":r=u,s=r&&!o&&!i;break;case"audio":r=l,s=r&&!o;break;case"vimeo":case"youtube":r=!0,s=!o&&!i;break;default:r=l&&u,s=r&&!o}return{basic:r,full:s}},S.setup=function(e,n){var r=[];if("string"==typeof e?e=t.querySelectorAll(e):e instanceof HTMLElement?e=[e]:e instanceof NodeList||"string"==typeof e||("undefined"==typeof n&&"object"==typeof e&&(n=e),e=t.querySelectorAll(N.selectors.container)),!S.supported().basic||!e.length)return!1;for(var s=e.length-1;s>=0;s--){var a=e[s];if("undefined"==typeof a.plyr){var o=T(N,n,JSON.parse(a.getAttribute("data-plyr")));if(!o.enabled)return;var i=new C(a,o);a.plyr=Object.keys(i).length?i:!1,k(a,"setup",{plyr:a.plyr})}r.push(a.plyr)}return r},S}),function(){function e(e,t){t=t||{bubbles:!1,cancelable:!1,detail:void 0};var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),n}return"function"==typeof window.CustomEvent?!1:(e.prototype=window.Event.prototype,void(window.CustomEvent=e))}(); \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index 35c9d973b..5083a75be 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -214,8 +214,10 @@ options = { // If aws is setup if("cdn" in aws) { - var cdnpath = new RegExp(aws.cdn.bucket + "\/(\\d+\\.)?(\\d+\\.)?(\\*|\\d+)","gi"), - localpath = new RegExp("(\.\.\/)?dist", "gi"); + var regex = "(\\d+\\.)?(\\d+\\.)?(\\*|\\d+)", + cdnpath = new RegExp(aws.cdn.bucket + "\/" + regex, "gi"), + semver = new RegExp("v" + regex, "gi"), + localpath = new RegExp("(\.\.\/)?dist", "gi"); } // Publish version to CDN bucket @@ -244,6 +246,11 @@ gulp.task("docs", function () { .pipe(replace(cdnpath, aws.cdn.bucket + "/" + version)) .pipe(gulp.dest(root)); + // Replace versioned files in plyr.js + gulp.src(path.join(root, "src/js/plyr.js")) + .pipe(replace(semver, "v" + version)) + .pipe(gulp.dest(path.join(root, "src/js/"))); + // Replace local file paths with remote paths in docs // e.g. "../dist/plyr.js" to "https://cdn.plyr.io/x.x.x/plyr.js" gulp.src([paths.docs.root + "*.html"]) diff --git a/package.json b/package.json index 00d9d3100..332c4f63b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "plyr", - "version": "1.5.14", + "version": "1.5.15", "description": "A simple, accessible and customizable HTML5, YouTube and Vimeo media player", "homepage": "http://plyr.io", "main": "src/js/plyr.js", diff --git a/readme.md b/readme.md index 907946841..0bc3e3bf7 100644 --- a/readme.md +++ b/readme.md @@ -40,7 +40,7 @@ If you have any cool ideas or features, please let me know by [creating an issue Check `docs/index.html` and `docs/dist/docs.js` for an example setup. -**Heads up:** the example `index.html` file needs to be served from a webserver (such as Apache, Nginx, IIS or similar) unless you change the file sources to include http or https. e.g. change `//cdn.plyr.io/1.5.14/plyr.js` to `https://cdn.plyr.io/1.5.14/plyr.js` +**Heads up:** the example `index.html` file needs to be served from a webserver (such as Apache, Nginx, IIS or similar) unless you change the file sources to include http or https. e.g. change `//cdn.plyr.io/1.5.15/plyr.js` to `https://cdn.plyr.io/1.5.15/plyr.js` ### Node Package Manager (NPM) Using NPM, you can grab Plyr: @@ -69,11 +69,11 @@ More info is on [npm](https://www.npmjs.com/package/ember-cli-plyr) and [GitHub] If you want to use our CDN, you can use the following: ```html - - + + ``` -You can also access the `sprite.svg` file at `https://cdn.plyr.io/1.5.14/sprite.svg`. +You can also access the `sprite.svg` file at `https://cdn.plyr.io/1.5.15/sprite.svg`. ### CSS & Styling If you want to use the default css, add the `plyr.css` file from `/dist` into your head, or even better use `plyr.less` or `plyr.sass` file included in `/src` in your build to save a request. @@ -175,7 +175,7 @@ Be sure to [validate your caption files](https://quuz.org/webvtt/) Here's an example of a default setup: ```html - + ``` diff --git a/src/js/plyr.js b/src/js/plyr.js index 575449971..24c6d76d2 100644 --- a/src/js/plyr.js +++ b/src/js/plyr.js @@ -1,5 +1,6 @@ // ========================================================================== // Plyr +// plyr.js v1.5.15 // https://github.com/selz/plyr // License: The MIT License (MIT) // ========================================================================== @@ -2832,16 +2833,18 @@ // Custom event polyfill // https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent (function () { + if (typeof window.CustomEvent === 'function') { + return false; + } + function CustomEvent (event, params) { params = params || { bubbles: false, cancelable: false, detail: undefined }; var evt = document.createEvent('CustomEvent'); - evt.initCustomEvent( event, params.bubbles, params.cancelable, params.detail ); + evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail); return evt; } CustomEvent.prototype = window.Event.prototype; - if(!('CustomEvent' in window)) { - window.CustomEvent = CustomEvent; - } + window.CustomEvent = CustomEvent; })();