1 line
28 KiB
JavaScript
1 line
28 KiB
JavaScript
!function(e){"use strict";function t(){var e=['<div class="player-controls">','<div class="player-progress">','<label for="seek{id}" class="sr-only">Seek</label>','<input id="seek{id}" class="player-progress-seek" type="range" min="0" max="100" step="0.5" value="0" data-player="seek">','<progress class="player-progress-played" max="100" value="0">',"<span>0</span>% "+E.i18n.played,"</progress>",'<progress class="player-progress-buffer" max="100" value="0">',"<span>0</span>% "+E.i18n.buffered,"</progress>","</div>",'<span class="player-controls-left">'];return s(E.controls,"restart")&&e.push('<button type="button" data-player="restart">','<svg><use xlink:href="#'+E.iconPrefix+'-restart" /></svg>','<span class="sr-only">'+E.i18n.restart+"</span>","</button>"),s(E.controls,"rewind")&&e.push('<button type="button" data-player="rewind">','<svg><use xlink:href="#'+E.iconPrefix+'-rewind" /></svg>','<span class="sr-only">'+E.i18n.rewind+"</span>","</button>"),s(E.controls,"play")&&e.push('<button type="button" data-player="play">','<svg><use xlink:href="#'+E.iconPrefix+'-play" /></svg>','<span class="sr-only">'+E.i18n.play+"</span>","</button>",'<button type="button" data-player="pause">','<svg><use xlink:href="#'+E.iconPrefix+'-pause" /></svg>','<span class="sr-only">'+E.i18n.pause+"</span>","</button>"),s(E.controls,"fast-forward")&&e.push('<button type="button" data-player="fast-forward">','<svg><use xlink:href="#'+E.iconPrefix+'-fast-forward" /></svg>','<span class="sr-only">'+E.i18n.forward+"</span>","</button>"),s(E.controls,"current-time")&&e.push('<span class="player-time">','<span class="sr-only">'+E.i18n.currentTime+"</span>",'<span class="player-current-time">00:00</span>',"</span>"),s(E.controls,"duration")&&e.push('<span class="player-time">','<span class="sr-only">'+E.i18n.duration+"</span>",'<span class="player-duration">00:00</span>',"</span>"),e.push("</span>",'<span class="player-controls-right">'),s(E.controls,"mute")&&e.push('<button type="button" data-player="mute">','<svg class="icon-muted"><use xlink:href="#'+E.iconPrefix+'-muted" /></svg>','<svg><use xlink:href="#'+E.iconPrefix+'-volume" /></svg>','<span class="sr-only">'+E.i18n.toggleMute+"</span>","</button>"),s(E.controls,"volume")&&e.push('<label for="volume{id}" class="sr-only">'+E.i18n.volume+"</label>",'<input id="volume{id}" class="player-volume" type="range" min="0" max="10" value="5" data-player="volume">'),s(E.controls,"captions")&&e.push('<button type="button" data-player="captions">','<svg class="icon-captions-on"><use xlink:href="#'+E.iconPrefix+'-captions-on" /></svg>','<svg><use xlink:href="#'+E.iconPrefix+'-captions-off" /></svg>','<span class="sr-only">'+E.i18n.toggleCaptions+"</span>","</button>"),s(E.controls,"fullscreen")&&e.push('<button type="button" data-player="fullscreen">','<svg class="icon-exit-fullscreen"><use xlink:href="#'+E.iconPrefix+'-exit-fullscreen" /></svg>','<svg><use xlink:href="#'+E.iconPrefix+'-enter-fullscreen" /></svg>','<span class="sr-only">'+E.i18n.toggleFullscreen+"</span>","</button>"),e.push("</span>","</div>"),e.join("")}function n(e,t){E.debug&&window.console&&console[t?"error":"log"](e)}function a(){var e,t,n,a=navigator.userAgent,r=navigator.appName,o=""+parseFloat(navigator.appVersion),s=parseInt(navigator.appVersion,10);return-1!==navigator.appVersion.indexOf("Windows NT")&&-1!==navigator.appVersion.indexOf("rv:11")?(r="IE",o="11;"):-1!==(t=a.indexOf("MSIE"))?(r="IE",o=a.substring(t+5)):-1!==(t=a.indexOf("Chrome"))?(r="Chrome",o=a.substring(t+7)):-1!==(t=a.indexOf("Safari"))?(r="Safari",o=a.substring(t+7),-1!==(t=a.indexOf("Version"))&&(o=a.substring(t+8))):-1!==(t=a.indexOf("Firefox"))?(r="Firefox",o=a.substring(t+8)):(e=a.lastIndexOf(" ")+1)<(t=a.lastIndexOf("/"))&&(r=a.substring(e,t),o=a.substring(t+1),r.toLowerCase()==r.toUpperCase()&&(r=navigator.appName)),-1!==(n=o.indexOf(";"))&&(o=o.substring(0,n)),-1!==(n=o.indexOf(" "))&&(o=o.substring(0,n)),s=parseInt(""+o,10),isNaN(s)&&(o=""+parseFloat(navigator.appVersion),s=parseInt(navigator.appVersion,10)),{name:r,version:s,ios:/(iPad|iPhone|iPod)/g.test(navigator.platform)}}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 o(e){if(!document.querySelectorAll('script[src="'+e+'"]').length){var t=document.createElement("script");t.src=e;var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(t,n)}}function s(e,t){return Array.prototype.indexOf&&-1!=e.indexOf(t)}function i(e,t,n){return e.replace(new RegExp(t.replace(/([.*+?\^=!:${}()|\[\]\/\\])/g,"\\$1"),"g"),n)}function l(e,t){e.length||(e=[e]);for(var n=e.length-1;n>=0;n--){var a=n>0?t.cloneNode(!0):t,r=e[n],o=r.parentNode,s=r.nextSibling;a.appendChild(r),s?o.insertBefore(a,s):o.appendChild(a)}}function u(e){for(var t=e.parentNode;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}function c(e){e.parentNode.removeChild(e)}function p(e,t){e.insertBefore(t,e.firstChild)}function d(e,t){for(var n in t)e.setAttribute(n,"boolean"==typeof t[n]&&t[n]?"":t[n])}function m(e,t,n){var a=document.createElement(e);d(a,n),p(t,a)}function f(e){return e.replace(".","")}function y(e,t,n){if(e)if(e.classList)e.classList[n?"add":"remove"](t);else{var a=(" "+e.className+" ").replace(/\s+/g," ").replace(" "+t+" ","");e.className=a+(n?" "+t:"")}}function b(e,t,n,a){var r=t.split(" ");if(e instanceof NodeList)for(var o=0;o<e.length;o++)e[o]instanceof Node&&b(e[o],arguments[1],arguments[2],arguments[3]);else for(var s=0;s<r.length;s++)e[a?"addEventListener":"removeEventListener"](r[s],n,!1)}function v(e,t,n){e&&b(e,t,n,!0)}function g(e,t,n){e&&b(e,t,n,!1)}function h(e,t){var n=document.createEvent("MouseEvents");n.initEvent(t,!0,!0),e.dispatchEvent(n)}function w(e,t){return t="boolean"==typeof t?t:!e.getAttribute("aria-pressed"),e.setAttribute("aria-pressed",t),t}function k(e,t){return 0===e||0===t||isNaN(e)||isNaN(t)?0:(e/t*100).toFixed(2)}function T(e,t){for(var n in t)t[n]&&t[n].constructor&&t[n].constructor===Object?(e[n]=e[n]||{},T(e[n],t[n])):e[n]=t[n];return e}function x(){var e={supportsFullScreen:!1,isFullScreen:function(){return!1},requestFullScreen:function(){},cancelFullScreen:function(){},fullScreenEventName:"",element:null,prefix:""},t="webkit moz o ms khtml".split(" ");if("undefined"!=typeof document.cancelFullScreen)e.supportsFullScreen=!0;else for(var n=0,a=t.length;a>n;n++){if(e.prefix=t[n],"undefined"!=typeof document[e.prefix+"CancelFullScreen"]){e.supportsFullScreen=!0;break}if("undefined"!=typeof document.msExitFullscreen&&document.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=document.body),this.prefix){case"":return document.fullscreenElement==e;case"moz":return document.mozFullScreenElement==e;default:return document[this.prefix+"FullscreenElement"]==e}},e.requestFullScreen=function(e){return"undefined"==typeof e&&(e=document.body),""===this.prefix?e.requestFullScreen():e[this.prefix+("ms"==this.prefix?"RequestFullscreen":"RequestFullScreen")]()},e.cancelFullScreen=function(){return""===this.prefix?document.cancelFullScreen():document[this.prefix+("ms"==this.prefix?"ExitFullscreen":"CancelFullScreen")]()},e.element=function(){return""===this.prefix?document.fullscreenElement:document[this.prefix+"FullscreenElement"]}),e}function F(){var e={supported:function(){try{return"localStorage"in window&&null!==window.localStorage}catch(e){return!1}}()};return e}function C(T){function C(e){if(!ht.usingTextTracks&&"video"===ht.type&&ht.supported.full&&(ht.subcount=0,e="number"==typeof e?e:ht.media.currentTime,ht.captions[ht.subcount])){for(;N(ht.captions[ht.subcount][0])<e.toFixed(1);)if(ht.subcount++,ht.subcount>ht.captions.length-1){ht.subcount=ht.captions.length-1;break}if(ht.media.currentTime.toFixed(1)>=P(ht.captions[ht.subcount][0])&&ht.media.currentTime.toFixed(1)<=N(ht.captions[ht.subcount][0])){ht.currentCaption=ht.captions[ht.subcount][1];var t=ht.currentCaption.trim();ht.captionsContainer.innerHTML!=t&&(ht.captionsContainer.innerHTML="",ht.captionsContainer.innerHTML=t)}else ht.captionsContainer.innerHTML=""}}function A(){ht.buttons.captions&&(y(ht.container,E.classes.captions.enabled,!0),E.captions.defaultActive&&(y(ht.container,E.classes.captions.active,!0),w(ht.buttons.captions,!0)))}function P(e){var t=[];return t=e.split(" --> "),I(t[0])}function N(e){var t=[];return t=e.split(" --> "),I(t[1])}function I(e){if(null===e||void 0===e)return 0;var t,n=[],a=[];return n=e.split(","),a=n[0].split(":"),t=Math.floor(60*a[0]*60)+Math.floor(60*a[1])+Math.floor(a[2])}function M(e){return ht.container.querySelectorAll(e)}function L(e){return M(e)[0]}function O(){try{return window.self!==window.top}catch(e){return!0}}function V(){var e=E.html;if(n("Injecting custom controls."),e||(e=t()),e=i(e,"{seektime}",E.seekTime),e=i(e,"{id}",Math.floor(1e4*Math.random())),ht.container.insertAdjacentHTML("beforeend",e),E.tooltips)for(var a=M(E.selectors.labels),r=a.length-1;r>=0;r--){var o=a[r];y(o,E.classes.hidden,!1),y(o,E.classes.tooltip,!0)}}function q(){try{return ht.controls=L(E.selectors.controls),ht.buttons={},ht.buttons.seek=L(E.selectors.buttons.seek),ht.buttons.play=L(E.selectors.buttons.play),ht.buttons.pause=L(E.selectors.buttons.pause),ht.buttons.restart=L(E.selectors.buttons.restart),ht.buttons.rewind=L(E.selectors.buttons.rewind),ht.buttons.forward=L(E.selectors.buttons.forward),ht.buttons.fullscreen=L(E.selectors.buttons.fullscreen),ht.buttons.mute=L(E.selectors.buttons.mute),ht.buttons.captions=L(E.selectors.buttons.captions),ht.checkboxes=M('[type="checkbox"]'),ht.progress={},ht.progress.container=L(E.selectors.progress.container),ht.progress.buffer={},ht.progress.buffer.bar=L(E.selectors.progress.buffer),ht.progress.buffer.text=ht.progress.buffer.bar&&ht.progress.buffer.bar.getElementsByTagName("span")[0],ht.progress.played={},ht.progress.played.bar=L(E.selectors.progress.played),ht.progress.played.text=ht.progress.played.bar&&ht.progress.played.bar.getElementsByTagName("span")[0],ht.volume=L(E.selectors.buttons.volume),ht.duration=L(E.selectors.duration),ht.currentTime=L(E.selectors.currentTime),ht.seekTime=M(E.selectors.seekTime),!0}catch(e){return n("It looks like there's a problem with your controls html. Bailing.",!0),ht.media.setAttribute("controls",""),!1}}function H(){if(ht.buttons.play){var e=ht.buttons.play.innerText||E.i18n.play;"undefined"!=typeof E.title&&E.title.length&&(e+=", "+E.title),ht.buttons.play.setAttribute("aria-label",e)}}function j(){if(!ht.media)return n("No audio or video element found!",!0),!1;if(ht.supported.full&&(ht.media.removeAttribute("controls"),y(ht.container,E.classes.type.replace("{0}",ht.type),!0),y(ht.container,E.classes.stopped,E.autoplay),ht.browser.ios&&y(ht.container,"ios",!0),"video"===ht.type)){var e=document.createElement("div");e.setAttribute("class",E.classes.videoWrapper),l(ht.media,e),ht.videoContainer=e}s(E.types.embed,ht.type)?(D(ht.embedId,ht.type),ht.embedId=null):E.autoplay&&$()}function D(e){for(var t=document.createElement("div"),n=ht.type+"-"+Math.floor(1e4*Math.random()),a=M('[id^="'+ht.type+'-"]'),r=a.length-1;r>=0;r--)c(a[r]);if(t.setAttribute("id",n),y(ht.media,E.classes.videoWrapper,!0),y(ht.media,E.classes.embedWrapper,!0),"youtube"===ht.type)ht.media.appendChild(t),"object"==typeof YT?R(e,t):(o("https://www.youtube.com/iframe_api"),window.onYouTubeIframeAPIReady=function(){R(e,t)});else if("vimeo"===ht.type){var s=document.createElement("iframe");if(s.loaded=!1,v(s,"load",function(){s.loaded=!0}),d(s,{src:"https://player.vimeo.com/video/"+e+"?player_id="+n+"&api=1&badge=0&byline=0&portrait=0&title=0",id:n,webkitallowfullscreen:"",mozallowfullscreen:"",allowfullscreen:"",frameborder:0}),t.appendChild(s),ht.media.appendChild(t),"function"==typeof Froogaloop)v(s,"load",_);else{o("https://rawgit.com/vimeo/player-api/master/javascript/froogaloop.js");var i=window.setInterval(function(){"$f"in window&&s.loaded&&(window.clearInterval(i),_.call(s))},50)}}}function B(){ht.supported.full&&(ht.container.querySelectorAll(E.selectors.controls).length||vt()),tt(),nt()}function R(e,t){"timer"in ht||(ht.timer={}),ht.embed=new YT.Player(t.id,{videoId:e,playerVars:{autoplay:E.autoplay?1:0,controls:ht.supported.full?0:1,rel:0,showinfo:0,iv_load_policy:3,cc_load_policy:E.captions.defaultActive?1:0,cc_lang_pref:"en",wmode:"transparent",modestbranding:1,disablekb:1},events:{onReady:function(e){var t=e.target;ht.media.play=function(){t.playVideo()},ht.media.pause=function(){t.pauseVideo()},ht.media.stop=function(){t.stopVideo()},ht.media.duration=t.getDuration(),ht.media.paused=!E.autoplay,ht.media.currentTime=t.getCurrentTime(),ht.media.muted=t.isMuted(),h(ht.media,"timeupdate"),window.clearInterval(ht.timer.buffering),ht.timer.buffering=window.setInterval(function(){ht.media.buffered=t.getVideoLoadedFraction(),h(ht.media,"progress"),1===ht.media.buffered&&window.clearInterval(ht.timer.buffering)},200),B(),E.displayDuration&&it()},onStateChange:function(e){var t=e.target;switch(window.clearInterval(ht.timer.playing),e.data){case 0:ht.media.paused=!0,h(ht.media,"ended");break;case 1:ht.media.paused=!1,h(ht.media,"play"),ht.timer.playing=window.setInterval(function(){ht.media.currentTime=t.getCurrentTime(),h(ht.media,"timeupdate")},200);break;case 2:ht.media.paused=!0,h(ht.media,"pause")}}}})}function _(){ht.embed=$f(this),ht.embed.addEvent("ready",function(){ht.media.play=function(){ht.embed.api("play")},ht.media.pause=function(){ht.embed.api("pause")},ht.media.stop=function(){ht.embed.api("stop")},ht.media.paused=!E.autoplay,ht.media.currentTime=0,B(),ht.embed.api("getCurrentTime",function(e){ht.media.currentTime=e,h(ht.media,"timeupdate")}),ht.embed.api("getDuration",function(e){ht.media.duration=e,ht.supported.full&&E.displayDuration&&it()}),ht.embed.addEvent("play",function(){console.log("play"),ht.media.paused=!1,h(ht.media,"play")}),ht.embed.addEvent("pause",function(){console.log("pause"),ht.media.paused=!0,h(ht.media,"pause")}),ht.embed.addEvent("playProgress",function(e){ht.media.currentTime=e.seconds,h(ht.media,"timeupdate")}),ht.embed.addEvent("loadProgress",function(e){ht.media.buffered=e.percent,h(ht.media,"progress")}),ht.embed.addEvent("finish",function(){ht.media.paused=!0,h(ht.media,"ended")})})}function W(){if("video"===ht.type){L(E.selectors.captions)||ht.videoContainer.insertAdjacentHTML("afterbegin",'<div class="'+f(E.selectors.captions)+'"><span></span></div>'),ht.captionsContainer=L(E.selectors.captions).querySelector("span"),ht.usingTextTracks=!1,ht.media.textTracks&&(ht.usingTextTracks=!0);for(var e,t="",a=ht.media.childNodes,r=0;r<a.length;r++)"track"===a[r].nodeName.toLowerCase()&&(e=a[r].kind,("captions"===e||"subtitles"===e)&&(t=a[r].getAttribute("src")));if(ht.captionExists=!0,""===t?(ht.captionExists=!1,n("No caption track found.")):n("Caption track found; URI: "+t),ht.captionExists){for(var o=ht.media.textTracks,s=0;s<o.length;s++)o[s].mode="hidden";if(A(ht),("IE"===ht.browser.name&&ht.browser.version>=10||"Firefox"===ht.browser.name&&ht.browser.version>=31||"Chrome"===ht.browser.name&&ht.browser.version>=43||"Safari"===ht.browser.name&&ht.browser.version>=7)&&(n("Detected unsupported browser for HTML5 captions. Using fallback."),ht.usingTextTracks=!1),ht.usingTextTracks){n("TextTracks supported.");for(var i=0;i<o.length;i++){var l=o[i];("captions"===l.kind||"subtitles"===l.kind)&&v(l,"cuechange",function(){ht.captionsContainer.innerHTML="",this.activeCues[0]&&this.activeCues[0].hasOwnProperty("text")&&ht.captionsContainer.appendChild(this.activeCues[0].getCueAsHTML().trim())})}}else if(n("TextTracks not supported so rendering captions manually."),ht.currentCaption="",ht.captions=[],""!==t){var u=new XMLHttpRequest;u.onreadystatechange=function(){if(4===u.readyState)if(200===u.status){var e,t=[],a=u.responseText;t=a.split("\n\n");for(var r=0;r<t.length;r++)e=t[r],ht.captions[r]=[],ht.captions[r]=e.split("\n");ht.captions.shift(),n("Successfully loaded the caption file via AJAX.")}else n("There was a problem loading the caption file via AJAX.",!0)},u.open("get",t,!0),u.send()}if("Safari"===ht.browser.name&&ht.browser.version>=7){n("Safari 7+ detected; removing track from DOM."),o=ht.media.getElementsByTagName("track");for(var c=0;c<o.length;c++)ht.media.removeChild(o[c])}}else y(ht.container,E.classes.captions.enabled)}}function z(){if("audio"!=ht.type&&E.fullscreen.enabled){var e=S.supportsFullScreen;e||E.fullscreen.fallback&&!O()?(n((e?"Native":"Fallback")+" fullscreen enabled."),y(ht.container,E.classes.fullscreen.enabled,!0)):n("Fullscreen not supported and fallback disabled."),w(ht.buttons.fullscreen,!1),E.fullscreen.hideControls&&y(ht.container,E.classes.fullscreen.hideControls,!0)}}function $(){ht.media.play()}function U(){ht.media.pause()}function X(e){e===!0?$():e===!1?U():ht.media[ht.media.paused?"play":"pause"]()}function Y(e){"number"!=typeof e&&(e=E.seekTime),G(ht.media.currentTime-e)}function J(e){"number"!=typeof e&&(e=E.seekTime),G(ht.media.currentTime+e)}function G(e){var t=0,a=ht.media.paused;"number"==typeof e?t=e:"object"!=typeof e||"input"!==e.type&&"change"!==e.type||(t=e.target.value/e.target.max*ht.media.duration),0>t?t=0:t>ht.media.duration&&(t=ht.media.duration);try{ht.media.currentTime=t.toFixed(1)}catch(r){}"embed"in ht&&("youtube"===ht.type&&ht.embed.seekTo(t),"vimeo"===ht.type&&ht.embed.api("seekTo",t),h(ht.media,"timeupdate"),a&&U()),n("Seeking to "+ht.media.currentTime+" seconds"),C(t)}function K(){y(ht.container,E.classes.playing,!ht.media.paused),y(ht.container,E.classes.stopped,ht.media.paused)}function Q(e){function t(){y(ht.container,E.classes.hover,!0),window.clearTimeout(r),o||(r=window.setTimeout(function(){y(ht.container,E.classes.hover,!1)},2e3))}function n(e){o="mouseenter"===e.type}var a=S.supportsFullScreen;e&&e.type===S.fullScreenEventName?ht.isFullscreen=S.isFullScreen(ht.container):a?(S.isFullScreen(ht.container)?S.cancelFullScreen():S.requestFullScreen(ht.container),ht.isFullscreen=S.isFullScreen(ht.container)):(ht.isFullscreen=!ht.isFullscreen,ht.isFullscreen?(v(document,"keyup",Z),document.body.style.overflow="hidden"):(g(document,"keyup",Z),document.body.style.overflow="")),y(ht.container,E.classes.fullscreen.active,ht.isFullscreen),w(ht.buttons.fullscreen,ht.isFullscreen);var r,o=!1;E.fullscreen.hideControls&&(y(ht.controls,E.classes.hover,!1),b(ht.controls,"mouseenter mouseleave",n,ht.isFullscreen),b(ht.container,"mousemove",t,ht.isFullscreen))}function Z(e){27===(e.which||e.charCode||e.keyCode)&&ht.isFullscreen&&Q()}function et(e){"boolean"!=typeof e&&(e=!ht.media.muted),w(ht.buttons.mute,e),ht.media.muted=e,"youtube"===ht.type&&(ht.embed[ht.media.muted?"mute":"unMute"](),h(ht.media,"volumechange"))}function tt(e){"undefined"==typeof e&&(e=E.storage.enabled&&F().supported?window.localStorage[E.storage.key]||E.volume:E.volume),e>10&&(e=10),0>e&&(e=0),ht.media.volume=parseFloat(e/10),E.volume=e,"youtube"===ht.type&&ht.embed.setVolume(100*ht.media.volume),"vimeo"===ht.type&&ht.embed.api("setVolume",ht.media.volume),"embed"in ht&&h(ht.media,"volumechange"),ht.media.muted&&e>0&&et()}function nt(){var e=ht.media.muted?0:10*ht.media.volume;ht.supported.full&&ht.volume&&(ht.volume.value=e),E.storage.enabled&&F().supported&&window.localStorage.setItem(E.storage.key,e),y(ht.container,E.classes.muted,0===e),ht.supported.full&&ht.buttons.mute&&w(ht.buttons.mute,0===e)}function at(e){ht.supported.full&&ht.buttons.captions&&("boolean"!=typeof e&&(e=-1===ht.container.className.indexOf(E.classes.captions.active)),w(ht.buttons.captions,e),y(ht.container,E.classes.captions.active,e))}function rt(e){var t="waiting"===e.type;clearTimeout(ht.loadingTimer),ht.loadingTimer=setTimeout(function(){y(ht.container,E.classes.loading,t)},t?250:0)}function ot(e){var t=ht.progress.played.bar,n=ht.progress.played.text,a=0;if(e)switch(e.type){case"timeupdate":case"seeking":a=k(ht.media.currentTime,ht.media.duration),"timeupdate"==e.type&&ht.buttons.seek&&(ht.buttons.seek.value=a);break;case"change":case"input":a=e.target.value;break;case"playing":case"progress":t=ht.progress.buffer.bar,n=ht.progress.buffer.text,a=function(){var e=ht.media.buffered;return e&&e.length?k(e.end(0),ht.media.duration):"number"==typeof e?100*e:0}()}t&&(t.value=a),n&&(n.innerHTML=a)}function st(e,t){if(t){isNaN(e)&&(e=0),ht.secs=parseInt(e%60),ht.mins=parseInt(e/60%60),ht.hours=parseInt(e/60/60%60);var n=parseInt(ht.media.duration/60/60%60)>0;ht.secs=("0"+ht.secs).slice(-2),ht.mins=("0"+ht.mins).slice(-2),t.innerHTML=(n?ht.hours+":":"")+ht.mins+":"+ht.secs}}function it(){var e=ht.media.duration||0;!ht.duration&&E.displayDuration&&ht.media.paused&&st(e,ht.currentTime),ht.duration&&st(e,ht.duration)}function lt(e){st(ht.media.currentTime,ht.currentTime),ot(e)}function ut(e){m("source",ht.media,e)}function ct(e){for(var t=e.length-1;t>=0;t--)m("track",ht.media,e[t])}function pt(e){if("string"==typeof e)ut({src:e});else if(e.constructor===Array)for(var t=e.length-1;t>=0;t--)ut(e[t])}function dt(e){if("undefined"!=typeof e){switch(U(),"youtube"===ht.type?(ht.embed.destroy(),window.clearInterval(ht.timer.buffering),window.clearInterval(ht.timer.playing)):"video"===ht.type&&c(ht.videoContainer),c(ht.media),"type"in e&&e.type!==ht.type&&(ht.type=e.type),ht.type){case"video":ht.media=document.createElement("video");break;case"audio":ht.media=document.createElement("audio");break;case"youtube":case"vimeo":ht.media=document.createElement("div"),ht.embedId=e.sources}p(ht.container,ht.media),s(E.types.html5,ht.type)&&(E.crossorigin&&ht.media.setAttribute("crossorigin",""),E.autoplay&&ht.media.setAttribute("autoplay",""),"poster"in e&&ht.media.setAttribute("poster",e.poster),E.loop&&ht.media.setAttribute("loop","")),ht.container.className=f(E.selectors.container),E.autoplay=e.autoplay||E.autoplay,s(E.types.embed,ht.type)&&(ht.embedId=e.sources),s(E.types.html5,ht.type)&&pt(e.sources),j(),gt(),s(E.types.html5,ht.type)&&(tt(),nt(),ht.supported.full&&(lt(),K()),"tracks"in e&&(ct(e.tracks),W()),ht.media.load(),E.autoplay&&$())}}function mt(e){"video"===ht.type&&ht.media.setAttribute("poster",e)}function ft(){function e(){var e=document.activeElement;e&&e!=document.body?document.querySelector&&(e=document.querySelector(":focus")):e=null;for(var t in ht.buttons){var n=ht.buttons[t];y(n,"tab-focus",n===e)}}var t="IE"==ht.browser.name?"change":"input";v(window,"keyup",function(t){var n=t.keyCode?t.keyCode:t.which;9==n&&e()});for(var n in ht.buttons){var a=ht.buttons[n];v(a,"blur",function(){y(a,"tab-focus",!1)})}v(ht.buttons.play,"click",function(){$(),setTimeout(function(){ht.buttons.pause.focus()},100)}),v(ht.buttons.pause,"click",function(){U(),setTimeout(function(){ht.buttons.play.focus()},100)}),v(ht.buttons.restart,"click",G),v(ht.buttons.rewind,"click",Y),v(ht.buttons.forward,"click",J),v(ht.buttons.seek,t,G),v(ht.volume,t,function(){tt(this.value)}),v(ht.buttons.mute,"click",et),v(ht.buttons.fullscreen,"click",Q),S.supportsFullScreen&&v(document,S.fullScreenEventName,Q),v(ht.media,"timeupdate seeking",lt),v(ht.media,"timeupdate",C),v(ht.media,"loadedmetadata",it),v(ht.buttons.captions,"click",at),v(ht.media,"ended",function(){"video"===ht.type&&(ht.captionsContainer.innerHTML=""),K()}),v(ht.media,"progress playing",ot),v(ht.media,"volumechange",nt),v(ht.media,"play pause",K),v(ht.media,"waiting canplay seeked",rt),"video"===ht.type&&E.click&&v(ht.videoContainer,"click",function(){ht.media.paused?h(ht.buttons.play,"click"):ht.media.ended?(G(),h(ht.buttons.play,"click")):h(ht.buttons.pause,"click")})}function yt(){if(!ht.init)return null;if(ht.container.setAttribute("class",f(E.selectors.container)),ht.init=!1,c(L(E.selectors.controls)),"youtube"===ht.type)return ht.embed.destroy(),void 0;"video"===ht.type&&(c(L(E.selectors.captions)),u(ht.videoContainer)),ht.media.setAttribute("controls","");var e=ht.media.cloneNode(!0);ht.media.parentNode.replaceChild(e,ht.media)}function bt(){if(ht.init)return null;S=x(),ht.browser=a(),ht.media=ht.container.querySelectorAll("audio, video, div")[0];var t=ht.media.tagName.toLowerCase();if("div"===t?(ht.type=ht.media.getAttribute("data-type"),ht.embedId=ht.media.getAttribute("data-video-id"),ht.media.removeAttribute("data-type"),ht.media.removeAttribute("data-video-id")):(ht.type=t,E.crossorigin=null!==ht.media.getAttribute("crossorigin"),E.autoplay=E.autoplay||null!==ht.media.getAttribute("autoplay"),E.loop=E.loop||null!==ht.media.getAttribute("loop")),ht.supported=e.supported(ht.type),!ht.supported.basic)return!1;if(n(ht.browser.name+" "+ht.browser.version),j(),"video"==ht.type||"audio"==ht.type){if(!ht.supported.full)return ht.init=!0,void 0;vt(),E.displayDuration&&it(),H()}ht.init=!0}function vt(){return V(),q()?(W(),gt(),tt(),nt(),void 0):!1}function gt(){z(),ft()}var ht=this;return ht.container=T,bt(),ht.init?{media:ht.media,play:$,pause:U,restart:G,rewind:Y,forward:J,seek:G,source:dt,poster:mt,setVolume:tt,togglePlay:X,toggleMute:et,toggleCaptions:at,toggleFullscreen:Q,isFullscreen:function(){return ht.isFullscreen||!1},support:function(e){return r(ht,e)},destroy:yt,restore:bt}:{}}var S,E,A={enabled:!0,debug:!1,autoplay:!1,loop:!1,seekTime:10,volume:5,click:!0,tooltips:!1,displayDuration:!0,iconPrefix:"icon",selectors:{container:".player",controls:".player-controls",labels:"[data-player] .sr-only, label .sr-only",buttons:{seek:'[data-player="seek"]',play:'[data-player="play"]',pause:'[data-player="pause"]',restart:'[data-player="restart"]',rewind:'[data-player="rewind"]',forward:'[data-player="fast-forward"]',mute:'[data-player="mute"]',volume:'[data-player="volume"]',captions:'[data-player="captions"]',fullscreen:'[data-player="fullscreen"]'},progress:{container:".player-progress",buffer:".player-progress-buffer",played:".player-progress-played"},captions:".player-captions",currentTime:".player-current-time",duration:".player-duration"},classes:{videoWrapper:"player-video-wrapper",embedWrapper:"player-video-embed",type:"player-{0}",stopped:"stopped",playing:"playing",muted:"muted",loading:"loading",tooltip:"player-tooltip",hidden:"sr-only",hover:"player-hover",captions:{enabled:"captions-enabled",active:"captions-active"},fullscreen:{enabled:"fullscreen-enabled",active:"fullscreen-active",hideControls:"fullscreen-hide-controls"}},captions:{defaultActive:!1},fullscreen:{enabled:!0,fallback:!0,hideControls:!0},storage:{enabled:!0,key:"plyr_volume"},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"},types:{embed:["youtube","vimeo"],html5:["video","audio"]}};e.supported=function(e){var t,n,r=a(),o="IE"===r.name&&r.version<=9,s=/iPhone|iPod/i.test(navigator.userAgent),i=!!document.createElement("audio").canPlayType,l=!!document.createElement("video").canPlayType;switch(e){case"video":t=l,n=t&&!o&&!s;break;case"audio":t=i,n=t&&!o;break;case"vimeo":case"youtube":t=!0,n=!o&&!s;break;default:t=i&&l,n=t&&!o}return{basic:t,full:n}},e.setup=function(t){if(E=T(A,t),!E.enabled||!e.supported().basic)return!1;for(var n=document.querySelectorAll(E.selectors.container),a=[],r=n.length-1;r>=0;r--){var o=n[r];if("undefined"==typeof o.plyr){var s=new C(o);o.plyr=Object.keys(s).length?s:!1,"function"==typeof E.onSetup&&E.onSetup.apply(o.plyr)}a.push(o.plyr)}return a}}(this.plyr=this.plyr||{}); |