!function(e){"use strict";function t(e,t){v.debug&&window.console&&console[t?"error":"log"](e)}function n(){var e,t,n,r=navigator.userAgent,a=navigator.appName,s=""+parseFloat(navigator.appVersion),o=parseInt(navigator.appVersion,10);return-1!==navigator.appVersion.indexOf("Windows NT")&&-1!==navigator.appVersion.indexOf("rv:11")?(a="IE",s="11;"):-1!==(t=r.indexOf("MSIE"))?(a="IE",s=r.substring(t+5)):-1!==(t=r.indexOf("Chrome"))?(a="Chrome",s=r.substring(t+7)):-1!==(t=r.indexOf("Safari"))?(a="Safari",s=r.substring(t+7),-1!==(t=r.indexOf("Version"))&&(s=r.substring(t+8))):-1!==(t=r.indexOf("Firefox"))?(a="Firefox",s=r.substring(t+8)):(e=r.lastIndexOf(" ")+1)<(t=r.lastIndexOf("/"))&&(a=r.substring(e,t),s=r.substring(t+1),a.toLowerCase()==a.toUpperCase()&&(a=navigator.appName)),-1!==(n=s.indexOf(";"))&&(s=s.substring(0,n)),-1!==(n=s.indexOf(" "))&&(s=s.substring(0,n)),o=parseInt(""+s,10),isNaN(o)&&(s=""+parseFloat(navigator.appVersion),o=parseInt(navigator.appVersion,10)),[a,o]}function r(e,t,n){return e.replace(new RegExp(t.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1"),"g"),n)}function a(e,t){e.length||(e=[e]);for(var n=e.length-1;n>=0;n--){var r=n>0?t.cloneNode(!0):t,a=e[n],s=a.parentNode,o=a.nextSibling;r.appendChild(a),o?s.insertBefore(r,o):s.appendChild(r)}}function s(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 o(e,t,n,r){t=t.split(" ");for(var a=0;an;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"webkit"===e.prefix&&navigator.userAgent.match(/Version\/[\d\.]+.*Safari/)&&(e.supportsFullScreen=!1),e.supportsFullScreen&&(e.fullScreenEventName="ms"==e.prefix?"MSFullscreenChange":e.prefix+"fullscreenchange",e.isFullScreen=function(){switch(this.prefix){case"":return document.fullScreen;case"webkit":return document.webkitIsFullScreen;case"ms":return null!==document.msFullscreenElement;default:return document[this.prefix+"FullScreen"]}},e.requestFullScreen=function(e){return""===this.prefix?e.requestFullScreen():e[this.prefix+("ms"==this.prefix?"RequestFullscreen":"RequestFullScreen")]("webkit"===this.prefix?e.ALLOW_KEYBOARD_INPUT:null)},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 m(e){function o(){for(_.subcount=0;m(_.captions[_.subcount][0])<_.media.currentTime.toFixed(1);)if(_.subcount++,_.subcount>_.captions.length-1){_.subcount=_.captions.length-1;break}}function p(){s(_.container,v.classes.captions.enabled,!0),v.captions.defaultActive&&(s(_.container,v.classes.captions.active,!0),_.buttons.captions.setAttribute("checked","checked"))}function d(e){var t=[];return t=e.split(" --> "),g(t[0])}function m(e){var t=[];return t=e.split(" --> "),g(t[1])}function g(e){if(null===e||void 0===e)return 0;var t,n=[],r=[];return n=e.split(","),r=n[0].split(":"),t=Math.floor(60*r[0]*60)+Math.floor(60*r[1])+Math.floor(r[2])}function y(e){return _.container.querySelectorAll(e)}function h(e){return y(e)[0]}function x(){try{return window.self!==window.top}catch(e){return!0}}function w(){t("Injecting custom controls.");var e=v.html;e=r(e,"{aria-label}",v.playAriaLabel),e=r(e,"{id}",_.random),_.container.insertAdjacentHTML("beforeend",e)}function k(){try{return _.controls=h(v.selectors.controls),_.buttons={},_.buttons.play=h(v.selectors.buttons.play),_.buttons.pause=h(v.selectors.buttons.pause),_.buttons.restart=h(v.selectors.buttons.restart),_.buttons.rewind=h(v.selectors.buttons.rewind),_.buttons.forward=h(v.selectors.buttons.forward),_.buttons.mute=h(v.selectors.buttons.mute),_.buttons.captions=h(v.selectors.buttons.captions),_.buttons.fullscreen=h(v.selectors.buttons.fullscreen),_.progress={},_.progress.container=h(v.selectors.progress.container),_.progress.buffer={},_.progress.buffer.bar=h(v.selectors.progress.buffer),_.progress.buffer.text=_.progress.buffer.bar.getElementsByTagName("span")[0],_.progress.played={},_.progress.played.bar=h(v.selectors.progress.played),_.progress.played.text=_.progress.played.bar.getElementsByTagName("span")[0],_.volume=h(v.selectors.buttons.volume),_.duration=h(v.selectors.duration),_.seekTime=y(v.selectors.seekTime),!0}catch(e){return t("It looks like there's a problem with your controls html. Bailing.",!0),!1}}function T(){if(_.media=_.container.querySelectorAll("audio, video")[0],!_.media)return t("No audio or video element found!",!0),!1;if(_.media.removeAttribute("controls"),_.type="video"==_.media.tagName.toLowerCase()?"video":"audio",s(_.container,v.classes[_.type],!0),s(_.container,v.classes.stopped,null===_.media.getAttribute("autoplay")),"video"===_.type){var e=document.createElement("div");e.setAttribute("class",v.classes.videoWrapper),a(_.media,e),_.videoContainer=e}}function S(){if("video"===_.type){_.videoContainer.insertAdjacentHTML("afterbegin","
"),_.captionsContainer=h(v.selectors.captions),_.isTextTracks=!1,_.media.textTracks&&(_.isTextTracks=!0);for(var e,n="",r=_.media.childNodes,a=0;a=31||"Safari"===_.browserName&&_.browserMajorVersion>=7)&&(t("Detected IE 10/11 or Firefox 31+ or Safari 7+."),_.isTextTracks=!1),_.isTextTracks){t("TextTracks supported.");for(var l=0;ld(_.captions[_.subcount][0])&&_.media.currentTime.toFixed(1)m(_.captions[_.subcount][0])&&_.subcount<_.captions.length-1&&_.subcount++,_.captionsContainer.innerHTML=_.currentCaption}),""!==n){var f=new XMLHttpRequest;f.onreadystatechange=function(){if(4===f.readyState)if(200===f.status){var e,n=[],r=f.responseText;n=r.split("\n\n");for(var a=0;a=7){t("Safari 7+ detected; removing track from DOM."),o=_.media.getElementsByTagName("track");for(var b=0;bt?0:t,_.isTextTracks||"video"!==_.type||o(_)}function A(e){"number"!=typeof e&&(e=v.seekInterval);var t=_.media.currentTime+e;_.media.currentTime=t>_.media.duration?_.media.duration:t,_.isTextTracks||"video"!==_.type||o(_)}function V(){var e=b.supportsFullScreen;event.type===b.fullScreenEventName?v.fullscreen.active=b.isFullScreen():e?(b.isFullScreen()?b.cancelFullScreen():b.requestFullScreen(_.container),v.fullscreen.active=b.isFullScreen()):(v.fullscreen.active=!v.fullscreen.active,v.fullscreen.active?(i(document,"keyup",O),document.body.style.overflow="hidden"):(c(document,"keyup",O),document.body.style.overflow="")),s(_.container,v.classes.fullscreen.active,v.fullscreen.active)}function O(e){27===(e.which||e.charCode||e.keyCode)&&v.fullscreen.active&&V()}function j(e){"undefined"==typeof e&&(e=v.storage.enabled&&v.storage.supported?window.localStorage.plyr_volume||v.volume:v.volume),e>10&&(e=10),_.volume.value=e,_.media.volume=parseFloat(e/10),B(),v.storage.enabled&&v.storage.supported&&(window.localStorage.plyr_volume=e)}function q(e){"undefined"==typeof active&&(e=!_.media.muted,_.buttons.mute.checked=e),_.media.muted=e,B()}function H(e){"undefined"==typeof e&&(e=-1===_.container.className.indexOf(v.classes.captions.active),_.buttons.captions.checked=e),e?s(_.container,v.classes.captions.active,!0):s(_.container,v.classes.captions.active)}function B(){s(_.container,v.classes.muted,0===_.media.volume||_.media.muted)}function R(e){var t,n,r=0;switch(e.type){case"timeupdate":t=_.progress.played.bar,n=_.progress.played.text,r=l(_.media.currentTime,_.media.duration);break;case"playing":case"progress":t=_.progress.buffer.bar,n=_.progress.buffer.text,r=function(){var e=_.media.buffered;return e.length?l(e.end(0),_.media.duration):0}()}t&&r>0&&(t.value=r,n.innerHTML=r)}function P(){_.secs=parseInt(_.media.currentTime%60),_.mins=parseInt(_.media.currentTime/60%60),_.secs=("0"+_.secs).slice(-2),_.mins=("0"+_.mins).slice(-2),_.duration.innerHTML=_.mins+":"+_.secs}function W(){i(_.buttons.play,"click",function(){C(),setTimeout(function(){_.buttons.pause.focus()},100)}),i(_.buttons.pause,"click",function(){M(),setTimeout(function(){_.buttons.play.focus()},100)}),i(_.buttons.restart,"click",I),i(_.buttons.rewind,"click",L),i(_.buttons.forward,"click",A),i(_.volume,"change",function(){j(this.value)}),i(_.buttons.mute,"change",function(){q(this.checked)}),i(_.buttons.fullscreen,"click",V),i(document,b.fullScreenEventName,V),"video"===_.type&&v.click&&i(_.videoContainer,"click",function(){_.media.paused?C():_.media.ended?I():M()}),i(_.media,"timeupdate",P),i(_.media,"timeupdate",R),i(_.progress.played.bar,"click",function(e){_.pos=u(e).x/this.offsetWidth,_.media.currentTime=_.pos*_.media.duration,_.isTextTracks||"video"!==_.type||o(_)}),i(_.buttons.captions,"click",function(){H(this.checked)}),i(_.media,"ended",function(){"video"===_.type&&(_.captionsContainer.innerHTML=""),E()}),i(_.media,"progress",R),i(_.media,"playing",R),i(_.media,"volumechange",B),i(_.media,"play pause",E)}function X(){return b=f(),_.browserInfo=n(),_.browserName=_.browserInfo[0],_.browserMajorVersion=_.browserInfo[1],t(_.browserName+" "+_.browserMajorVersion),"IE"!==_.browserName||8!==_.browserMajorVersion&&9!==_.browserMajorVersion?(v.playAriaLabel="undefined"!=typeof v.title&&v.title.length?"Play "+v.title:"Play",T(),_.random=Math.floor(1e4*Math.random()),w(),k()?(S(),j(),N(),F(),W(),void 0):!1):(t("Browser not suppported.",!0),!1)}var _=this;return _.container=e,X(),{media:_.media,play:C,pause:M,restart:I,rewind:L,forward:A,setVolume:j,toggleMute:q,toggleCaptions:H}}var b,v,g={enabled:!0,debug:!1,seekInterval:10,volume:5,click:!0,selectors:{container:".player",controls:".player-controls",buttons:{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",duration:".player-duration",seekTime:".player-seek-time"},classes:{video:"player-video",videoWrapper:"player-video-wrapper",audio:"player-audio",stopped:"stopped",playing:"playing",muted:"muted",captions:{enabled:"captions-enabled",active:"captions-active"},fullscreen:{enabled:"fullscreen-enabled",active:"fullscreen-active"}},captions:{defaultActive:!1},fullscreen:{enabled:!0,fallback:!0},storage:{enabled:!0,supported:function(){try{return"localStorage"in window&&null!==window.localStorage}catch(e){return!1}}}};e.setup=function(e){if(v=d(g,e),!v.enabled)return!1;for(var t=document.querySelectorAll(v.selectors.container),n=[],r=t.length-1;r>=0;r--){var a=t[r];"undefined"==typeof a.plyr&&(a.plyr=new m(a)),n.push(a.plyr)}return n}}(this.plyr=this.plyr||{});