From 4610f4a8c957977e53d596712bce927b390cca68 Mon Sep 17 00:00:00 2001 From: Sam Potts Date: Sun, 21 Aug 2016 19:44:46 +1000 Subject: [PATCH] Firefox and Edge fixes --- changelog.md | 1 + demo/index.html | 4 ++-- dist/plyr.js | 4 ++-- src/js/plyr.js | 15 +++++++++++++++ 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/changelog.md b/changelog.md index 0476c00ad..955e004c2 100644 --- a/changelog.md +++ b/changelog.md @@ -6,6 +6,7 @@ This version contains several ***breaking changes***: - `setup()` has been reverted to pre v1.8.0 behaviour; meaning it will return the *instance* rather than the *element*. This is because the reference to the instance is no longer added to the original element (see below). - The reference to the `plyr` instance is now added to the media element rather than original container. This is because if a container with multiple children was passed to `setup()` the references to all instances would have been added to the container, creating issues. I would recommend using the return value from `setup()` or the new `get()` method to access the instance. - Players will always be wrapped in their own div now - this makes `setup()` and `destroy()` cleaner. This *may* break any custom styling based on DOM position. +- Players no longer seek to 0 on 'ended' - this is to fix a bug with Microsoft Edge as it triggers 'ended' on media change for whatever reason. They'll never change ;-) And some other changes and bug fixes: diff --git a/demo/index.html b/demo/index.html index e8c4aef57..d8ea6c2f0 100644 --- a/demo/index.html +++ b/demo/index.html @@ -73,8 +73,8 @@

Plyr

- - + + diff --git a/dist/plyr.js b/dist/plyr.js index 9950fd4b2..9e658e4a3 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),l=!1,u=!1,c=!1,p=!1;return-1!==navigator.appVersion.indexOf("Windows NT")&&-1!==navigator.appVersion.indexOf("rv:11")?(l=!0,a="IE",o="11"):-1!==(n=s.indexOf("MSIE"))?(l=!0,a="IE",o=s.substring(n+5)):-1!==(n=s.indexOf("Chrome"))?(c=!0,a="Chrome",o=s.substring(n+7)):-1!==(n=s.indexOf("Safari"))?(p=!0,a="Safari",o=s.substring(n+7),-1!==(n=s.indexOf("Version"))&&(o=s.substring(n+8))):-1!==(n=s.indexOf("Firefox"))?(u=!0,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,isIE:l,isFirefox:u,isChrome:c,isSafari:p,isIos:/(iPad|iPhone|iPod)/g.test(navigator.platform),isTouch:"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;return r.appendChild(s),o?a.insertBefore(r,o):a.appendChild(r),r}}function l(e){e&&e.parentNode.removeChild(e)}function u(e,t){e.insertBefore(t,e.firstChild)}function c(e,t){for(var n in t)e.setAttribute(n,P["boolean"](t[n])&&t[n]?"":t[n])}function p(e,n,r){var s=t.createElement(e);c(s,r),u(n,s)}function d(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 f(e,t){return e?e.classList?e.classList.contains(t):new RegExp("(\\s|^)"+t+"(\\s|$)").test(e.className):!1}function y(e,n){var r=Element.prototype,s=r.matches||r.webkitMatchesSelector||r.mozMatchesSelector||r.msMatchesSelector||function(e){return-1!==[].indexOf.call(t.querySelectorAll(e),this)};return s.call(e,n)}function b(e,t,n,r,s){g(e,t,function(t){n&&n.apply(e,[t]),r.apply(e,[t])},s)}function v(e,t,n,r,s){var a=t.split(" ");if(P["boolean"](s)||(s=!1),e instanceof NodeList)for(var o=0;or;r++){var s=e[r];for(var a in s)s[a]&&s[a].constructor&&s[a].constructor===Object?(t[a]=t[a]||{},x(t[a],s[a])):t[a]=s[a]}return t}}function T(){var e={supportsFullScreen:!1,isFullScreen:function(){return!1},requestFullScreen:function(){},cancelFullScreen:function(){},fullScreenEventName:"",element:null,prefix:""},n="webkit o ms khtml".split(" ");if(P.undefined(t.cancelFullScreen))for(var r=0,s=n.length;s>r;r++){if(e.prefix=n[r],!P.undefined(t[e.prefix+"CancelFullScreen"])){e.supportsFullScreen=!0;break}if(!P.undefined(t.msExitFullscreen)&&t.msFullscreenEnabled){e.prefix="ms",e.supportsFullScreen=!0;break}}else e.supportsFullScreen=!0;return e.supportsFullScreen&&(e.fullScreenEventName="ms"===e.prefix?"MSFullscreenChange":e.prefix+"fullscreenchange",e.isFullScreen=function(e){switch(P.undefined(e)&&(e=t.body),this.prefix){case"":return t.fullscreenElement===e;default:return t[this.prefix+"FullscreenElement"]===e}},e.requestFullScreen=function(e){return P.undefined(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 S(y,v){function S(e,t,n,r){h(e,t,n,x({},r,{plyr:De}))}function C(t,n){v.debug&&e.console&&(n=Array.prototype.slice.call(n),P.string(v.logPrefix)&&v.logPrefix.length&&n.unshift(v.logPrefix),console[t].apply(console,n))}function F(){return{url:v.iconUrl,absolute:0===v.iconUrl.indexOf("http")||He.browser.isIE}}function L(){var e=[],t=F(),n=(t.absolute?"":t.url)+"#"+v.iconPrefix;return a(v.controls,"play-large")&&e.push('"),e.push('
'),a(v.controls,"restart")&&e.push('"),a(v.controls,"rewind")&&e.push('"),a(v.controls,"play")&&e.push('",'"),a(v.controls,"fast-forward")&&e.push('"),a(v.controls,"progress")&&(e.push('','','','','',"0% "+v.i18n.buffered,""),v.tooltips.seek&&e.push('00:00'),e.push("")),a(v.controls,"current-time")&&e.push('',''+v.i18n.currentTime+"",'00:00',""),a(v.controls,"duration")&&e.push('',''+v.i18n.duration+"",'00:00',""),a(v.controls,"mute")&&e.push('"),a(v.controls,"volume")&&e.push('','",'','',""),a(v.controls,"captions")&&e.push('"),a(v.controls,"fullscreen")&&e.push('"),e.push("
"),e.join("")}function O(){if(He.supported.full&&("audio"!==He.type||v.fullscreen.allowAudio)&&v.fullscreen.enabled){var e=A.supportsFullScreen;e||v.fullscreen.fallback&&!W()?(Be((e?"Native":"Fallback")+" fullscreen enabled"),m(He.container,v.classes.fullscreen.enabled,!0)):Be("Fullscreen not supported and fallback disabled"),He.buttons&&He.buttons.fullscreen&&k(He.buttons.fullscreen,!1),Y()}}function j(){if("video"===He.type){H(v.selectors.captions)||He.videoContainer.insertAdjacentHTML("afterbegin",'
'),He.usingTextTracks=!1,He.media.textTracks&&(He.usingTextTracks=!0);for(var e,t="",n=He.media.childNodes,r=0;r=10||He.browser.isFirefox&&He.browser.version>=31)&&(Be("Detected browser with known TextTrack issues - using manual fallback"),He.usingTextTracks=!1),He.usingTextTracks){Be("TextTracks supported");for(var o=0;o ");for(var r=0;rHe.captions.length-1){He.subcount=He.captions.length-1;break}He.media.currentTime.toFixed(1)>=n(He.captions[He.subcount][0])&&He.media.currentTime.toFixed(1)<=r(He.captions[He.subcount][0])?(He.currentCaption=He.captions[He.subcount][1],V(He.currentCaption)):V()}}function R(){if(He.buttons.captions){m(He.container,v.classes.captions.enabled,!0);var e=He.storage.captionsEnabled;P["boolean"](e)||(e=v.captions.defaultActive),e&&(m(He.container,v.classes.captions.active,!0),k(He.buttons.captions,!0))}}function D(e){return He.container.querySelectorAll(e)}function H(e){return D(e)[0]}function W(){try{return e.self!==e.top}catch(t){return!0}}function Y(){function e(e){9===e.which&&He.isFullscreen&&(e.target!==r||e.shiftKey?e.target===n&&e.shiftKey&&(e.preventDefault(),r.focus()):(e.preventDefault(),n.focus()))}var t=D("input:not([disabled]), button:not([disabled])"),n=t[0],r=t[t.length-1];g(He.container,"keydown",e)}function B(e,t){if(P.string(t))p(e,He.media,{src:t});else if(t.constructor===Array)for(var n=t.length-1;n>=0;n--)p(e,He.media,t[n])}function X(){if(v.loadSprite){var e=F();e.absolute?(Be("AJAX loading absolute SVG sprite"+(He.browser.isIE?" (due to IE)":"")),_(e.url,"sprite-plyr")):Be("Sprite will be used as external resource directly")}var n=v.html;Be("Injecting custom controls"),n||(n=L()),n=o(n,"{seektime}",v.seekTime),n=o(n,"{id}",Math.floor(1e4*Math.random()));var r;if(P.string(v.selectors.controls.container)&&(r=t.querySelector(v.selectors.controls.container)),P.htmlElement(r)||(r=He.container),r.insertAdjacentHTML("beforeend",n),v.tooltips.controls)for(var s=D([v.selectors.controls.wrapper," ",v.selectors.labels," .",v.classes.hidden].join("")),a=s.length-1;a>=0;a--){var i=s[a];m(i,v.classes.hidden,!1),m(i,v.classes.tooltip,!0)}}function U(){try{return He.controls=H(v.selectors.controls.wrapper),He.buttons={},He.buttons.seek=H(v.selectors.buttons.seek),He.buttons.play=D(v.selectors.buttons.play),He.buttons.pause=H(v.selectors.buttons.pause),He.buttons.restart=H(v.selectors.buttons.restart),He.buttons.rewind=H(v.selectors.buttons.rewind),He.buttons.forward=H(v.selectors.buttons.forward),He.buttons.fullscreen=H(v.selectors.buttons.fullscreen),He.buttons.mute=H(v.selectors.buttons.mute),He.buttons.captions=H(v.selectors.buttons.captions),He.progress={},He.progress.container=H(v.selectors.progress.container),He.progress.buffer={},He.progress.buffer.bar=H(v.selectors.progress.buffer),He.progress.buffer.text=He.progress.buffer.bar&&He.progress.buffer.bar.getElementsByTagName("span")[0],He.progress.played=H(v.selectors.progress.played),He.progress.tooltip=He.progress.container&&He.progress.container.querySelector("."+v.classes.tooltip),He.volume={},He.volume.input=H(v.selectors.volume.input),He.volume.display=H(v.selectors.volume.display),He.duration=H(v.selectors.duration),He.currentTime=H(v.selectors.currentTime),He.seekTime=D(v.selectors.seekTime),!0}catch(e){return Xe("It looks like there is a problem with your controls HTML"),$(!0),!1}}function J(){m(He.container,v.selectors.container.replace(".",""),He.supported.full)}function $(e){e&&a(v.types.html5,He.type)?He.media.setAttribute("controls",""):He.media.removeAttribute("controls")}function G(e){var t=v.i18n.play;if(P.string(v.title)&&v.title.length&&(t+=", "+v.title,He.container.setAttribute("aria-label",v.title)),He.supported.full&&He.buttons.play)for(var n=He.buttons.play.length-1;n>=0;n--)He.buttons.play[n].setAttribute("aria-label",t);P.htmlElement(e)&&e.setAttribute("title",v.i18n.frameTitle.replace("{title}",v.title))}function K(){var t=null;He.storage={},M.supported&&v.storage.enabled&&(e.localStorage.removeItem("plyr-volume"),t=e.localStorage.getItem(v.storage.key),t&&(/^\d+(\.\d+)?$/.test(t)?z({volume:parseFloat(t)}):He.storage=JSON.parse(t)))}function z(t){M.supported&&v.storage.enabled&&(x(He.storage,t),e.localStorage.setItem(v.storage.key,JSON.stringify(He.storage)))}function Q(){if(!He.media)return void Xe("No media element found!");if(He.supported.full&&(m(He.container,v.classes.type.replace("{0}",He.type),!0),a(v.types.embed,He.type)&&m(He.container,v.classes.type.replace("{0}","video"),!0),m(He.container,v.classes.stopped,v.autoplay),m(He.ontainer,v.classes.isIos,He.browser.isIos),m(He.container,v.classes.isTouch,He.browser.isTouch),"video"===He.type)){var e=t.createElement("div");e.setAttribute("class",v.classes.videoWrapper),i(He.media,e),He.videoContainer=e}a(v.types.embed,He.type)&&Z()}function Z(){for(var n=t.createElement("div"),r=He.embedId,a=He.type+"-"+Math.floor(1e4*Math.random()),o=D('[id^="'+He.type+'-"]'),i=o.length-1;i>=0;i--)l(o[i]);if(m(He.media,v.classes.videoWrapper,!0),m(He.media,v.classes.embedWrapper,!0),"youtube"===He.type)He.media.appendChild(n),n.setAttribute("id",a),P.object(e.YT)?te(r,n):(s(v.urls.youtube.api),e.onYouTubeReadyCallbacks=e.onYouTubeReadyCallbacks||[],e.onYouTubeReadyCallbacks.push(function(){te(r,n)}),e.onYouTubeIframeAPIReady=function(){e.onYouTubeReadyCallbacks.forEach(function(e){e()})});else if("vimeo"===He.type)if(He.supported.full?He.media.appendChild(n):n=He.media,n.setAttribute("id",a),P.object(e.Vimeo))ne(r,n);else{s(v.urls.vimeo.api);var u=e.setInterval(function(){P.object(e.Vimeo)&&(e.clearInterval(u),ne(r,n))},50)}else if("soundcloud"===He.type){var p=t.createElement("iframe");p.loaded=!1,g(p,"load",function(){p.loaded=!0}),c(p,{src:"https://w.soundcloud.com/player/?url=https://api.soundcloud.com/tracks/"+r,id:a}),n.appendChild(p),He.media.appendChild(n),e.SC||s(v.urls.soundcloud.api);var d=e.setInterval(function(){e.SC&&p.loaded&&(e.clearInterval(d),re.call(p))},50)}}function ee(){He.supported.full&&(qe(),Re()),G(H("iframe"))}function te(t,n){He.embed=new e.YT.Player(n.id,{videoId:t,playerVars:{autoplay:v.autoplay?1:0,controls:He.supported.full?0:1,rel:0,showinfo:0,iv_load_policy:3,cc_load_policy:v.captions.defaultActive?1:0,cc_lang_pref:"en",wmode:"transparent",modestbranding:1,disablekb:1,origin:"*"},events:{onError:function(e){S(He.container,"error",!0,{code:e.data,embed:e.target})},onReady:function(t){var n=t.target;He.media.play=function(){n.playVideo(),He.media.paused=!1},He.media.pause=function(){n.pauseVideo(),He.media.paused=!0},He.media.stop=function(){n.stopVideo(),He.media.paused=!0},He.media.duration=n.getDuration(),He.media.paused=!0,He.media.currentTime=0,He.media.muted=n.isMuted(),v.title=n.getVideoData().title,He.supported.full&&He.media.querySelector("iframe").setAttribute("tabindex","-1"),ee(),S(He.media,"timeupdate"),S(He.media,"durationchange"),e.clearInterval(We.buffering),We.buffering=e.setInterval(function(){He.media.buffered=n.getVideoLoadedFraction(),(null===He.media.lastBuffered||He.media.lastBufferedt?t=0:t>r&&(t=r),Ce(t);try{He.media.currentTime=t.toFixed(4)}catch(s){}if(a(v.types.embed,He.type)){switch(He.type){case"youtube":He.embed.seekTo(t);break;case"vimeo":He.embed.setCurrentTime(t.toFixed(0));break;case"soundcloud":He.embed.seekTo(1e3*t)}n&&ae(),S(He.media,"timeupdate"),He.media.seeking=!0}Be("Seeking to "+He.media.currentTime+" seconds"),q(t)}function ce(){var e=parseInt(v.duration),t=0;return null===He.media.duration||isNaN(He.media.duration)||(t=He.media.duration),isNaN(e)?t:e}function pe(){m(He.container,v.classes.playing,!He.media.paused),m(He.container,v.classes.stopped,He.media.paused),Ae(He.media.paused)}function de(){I={x:e.pageXOffset||0,y:e.pageYOffset||0}}function me(){e.scrollTo(I.x,I.y)}function fe(e){var n=A.supportsFullScreen;if(n){if(!e||e.type!==A.fullScreenEventName)return A.isFullScreen(He.container)?A.cancelFullScreen():(de(),A.requestFullScreen(He.container)),void(He.isFullscreen=A.isFullScreen(He.container));He.isFullscreen=A.isFullScreen(He.container)}else He.isFullscreen=!He.isFullscreen,t.body.style.overflow=He.isFullscreen?"hidden":"";m(He.container,v.classes.fullscreen.active,He.isFullscreen),Y(He.isFullscreen),He.buttons&&He.buttons.fullscreen&&k(He.buttons.fullscreen,He.isFullscreen),S(He.container,He.isFullscreen?"enterfullscreen":"exitfullscreen",!0),!He.isFullscreen&&n&&me()}function ye(e){if(P["boolean"](e)||(e=!He.media.muted),k(He.buttons.mute,e),He.media.muted=e,0===He.media.volume&&be(v.volume),a(v.types.embed,He.type)){switch(He.type){case"youtube":He.embed[He.media.muted?"mute":"unMute"]();break;case"vimeo":case"soundcloud":He.embed.setVolume(He.media.muted?0:parseFloat(v.volume/v.volumeMax))}S(He.media,"volumechange")}}function be(e){var t=v.volumeMax,n=v.volumeMin;if(P.undefined(e)&&(e=He.storage.volume),(null===e||isNaN(e))&&(e=v.volume),e>t&&(e=t),n>e&&(e=n),He.media.volume=parseFloat(e/t),He.volume.display&&(He.volume.display.value=e),a(v.types.embed,He.type)){switch(He.type){case"youtube":He.embed.setVolume(100*He.media.volume);break;case"vimeo":case"soundcloud":He.embed.setVolume(He.media.volume)}S(He.media,"volumechange")}He.media.muted&&e>0&&ye()}function ve(e){var t=He.media.muted?0:He.media.volume*v.volumeMax;P.number(e)||(e=v.volumeStep),be(t+e)}function ge(e){var t=He.media.muted?0:He.media.volume*v.volumeMax;P.number(e)||(e=v.volumeStep),be(t-e)}function he(){var e=He.media.muted?0:He.media.volume*v.volumeMax;He.supported.full&&(He.volume.input&&(He.volume.input.value=e),He.volume.display&&(He.volume.display.value=e)),z({volume:e}),m(He.container,v.classes.muted,0===e),He.supported.full&&He.buttons.mute&&k(He.buttons.mute,0===e)}function ke(e){He.supported.full&&He.buttons.captions&&(P["boolean"](e)||(e=-1===He.container.className.indexOf(v.classes.captions.active)),He.captionsEnabled=e,k(He.buttons.captions,He.captionsEnabled),m(He.container,v.classes.captions.active,He.captionsEnabled),S(He.container,He.captionsEnabled?"captionsenabled":"captionsdisabled",!0),z({captionsEnabled:He.captionsEnabled}))}function we(e){var t="waiting"===e.type;clearTimeout(We.loading),We.loading=setTimeout(function(){m(He.container,v.classes.loading,t),Ae(t)},t?250:0)}function xe(e){if(He.supported.full){var t=He.progress.played,n=0,r=ce();if(e)switch(e.type){case"timeupdate":case"seeking":if(He.controls.pressed)return;n=w(He.media.currentTime,r),"timeupdate"===e.type&&He.buttons.seek&&(He.buttons.seek.value=n);break;case"playing":case"progress":t=He.progress.buffer,n=function(){var e=He.media.buffered;return e&&e.length?w(e.end(0),r):P.number(e)?100*e:0}()}Te(t,n)}}function Te(e,t){if(He.supported.full){if(P.undefined(t)&&(t=0),P.undefined(e)){if(!He.progress||!He.progress.buffer)return;e=He.progress.buffer}P.htmlElement(e)?e.value=t:e&&(e.bar&&(e.bar.value=t),e.text&&(e.text.innerHTML=t))}}function Se(e,t){if(t){isNaN(e)&&(e=0),He.secs=parseInt(e%60),He.mins=parseInt(e/60%60),He.hours=parseInt(e/60/60%60);var n=parseInt(ce()/60/60%60)>0;He.secs=("0"+He.secs).slice(-2),He.mins=("0"+He.mins).slice(-2),t.innerHTML=(n?He.hours+":":"")+He.mins+":"+He.secs}}function _e(){if(He.supported.full){var e=ce()||0;!He.duration&&v.displayDuration&&He.media.paused&&Se(e,He.currentTime),He.duration&&Se(e,He.duration),Fe()}}function Ee(e){Se(He.media.currentTime,He.currentTime),e&&"timeupdate"===e.type&&He.media.seeking||xe(e)}function Ce(e){P.number(e)||(e=0);var t=ce(),n=w(e,t);He.progress&&He.progress.played&&(He.progress.played.value=n),He.buttons&&He.buttons.seek&&(He.buttons.seek.value=n)}function Fe(e){var t=ce();if(v.tooltips.seek&&He.progress.container&&0!==t){var n=He.progress.container.getBoundingClientRect(),r=0,s=v.classes.tooltip+"--visible";if(e)r=100/n.width*(e.pageX-n.left);else{if(!f(He.progress.tooltip,s))return;r=He.progress.tooltip.style.left.replace("%","")}0>r?r=0:r>100&&(r=100),Se(t/100*r,He.progress.tooltip),He.progress.tooltip.style.left=r+"%",e&&a(["mouseenter","mouseleave"],e.type)&&m(He.progress.tooltip,s,"mouseenter"===e.type)}}function Ae(t){if(v.hideControls&&"audio"!==He.type){var n=0,r=!1,s=t,o=f(He.container,v.classes.loading);if(P["boolean"](t)||(t&&t.type?(r="enterfullscreen"===t.type,s=a(["mousemove","touchstart","mouseenter","focus"],t.type),a(["mousemove","touchmove"],t.type)&&(n=2e3),"focus"===t.type&&(n=3e3)):s=f(He.container,v.classes.hideControls)),e.clearTimeout(We.hover),s||He.media.paused||o){if(m(He.container,v.classes.hideControls,!1),He.media.paused||o)return;He.browser.isTouch&&(n=3e3)}s&&He.media.paused||(We.hover=e.setTimeout(function(){(!He.controls.pressed&&!He.controls.hover||r)&&m(He.container,v.classes.hideControls,!0)},n))}}function Ie(e){if(!P.undefined(e))return void Ne(e);var t;switch(He.type){case"youtube":t=He.embed.getVideoUrl();break;case"vimeo":He.embed.getVideoUrl.then(function(e){t=e});break;case"soundcloud":He.embed.getCurrentSound(function(e){t=e.permalink_url});break;default:t=He.media.currentSrc}return t||""}function Ne(e){function n(){if(He.embed=null,l(He.media),"video"===He.type&&He.videoContainer&&l(He.videoContainer),He.container&&He.container.removeAttribute("class"),"type"in e&&(He.type=e.type,"video"===He.type)){var n=e.sources[0];"type"in n&&a(v.types.embed,n.type)&&(He.type=n.type)}switch(He.supported=E(He.type),He.type){case"video":He.media=t.createElement("video");break;case"audio":He.media=t.createElement("audio");break;case"youtube":case"vimeo":case"soundcloud":He.media=t.createElement("div"),He.embedId=e.sources[0].src}u(He.container,He.media),P["boolean"](e.autoplay)&&(v.autoplay=e.autoplay),a(v.types.html5,He.type)&&(v.crossorigin&&He.media.setAttribute("crossorigin",""),v.autoplay&&He.media.setAttribute("autoplay",""),"poster"in e&&He.media.setAttribute("poster",e.poster),v.loop&&He.media.setAttribute("loop","")),m(He.container,v.classes.fullscreen.active,He.isFullscreen),m(He.container,v.classes.captions.active,He.captionsEnabled),J(),a(v.types.html5,He.type)&&B("source",e.sources),Q(),a(v.types.html5,He.type)&&("tracks"in e&&B("track",e.tracks),He.media.load()),(a(v.types.html5,He.type)||a(v.types.embed,He.type)&&!He.supported.full)&&(qe(),Re()),v.title=e.title,G()}return P.object(e)&&"sources"in e&&e.sources.length?(m(He.container,v.classes.ready,!1),ae(),Ce(),Te(),Oe(),void je(n,!1)):void Xe("Invalid source format")}function Pe(e){"video"===He.type&&He.media.setAttribute("poster",e)}function Me(){function n(){var e=oe(),t=He.buttons[e?"play":"pause"],n=He.buttons[e?"pause":"play"];if(n=n&&n.length>1?n[n.length-1]:n[0]){var r=f(t,v.classes.tabFocus);setTimeout(function(){n.focus(),r&&(m(t,v.classes.tabFocus,!1),m(n,v.classes.tabFocus,!0))},100)}}function r(){var e=t.activeElement;return e=e&&e!==t.body?t.querySelector(":focus"):null}function s(e){return e.keyCode?e.keyCode:e.which}function o(e){for(var t in He.buttons){var n=He.buttons[t];if(P.nodeList(n))for(var r=0;r0)&&(t?ge(n):ve(n)),(e.deltaY>0||e.deltaX<0)&&(t?ve(n):ge(n))})}function Le(){if(g(He.media,"timeupdate seeking",Ee),g(He.media,"timeupdate",q),g(He.media,"durationchange loadedmetadata",_e),g(He.media,"ended",function(){"video"===He.type&&v.showPosterOnEnd&&("video"===He.type&&V(),ue(),He.media.load())}),g(He.media,"progress playing",xe),g(He.media,"volumechange",he),g(He.media,"play pause ended",pe),g(He.media,"waiting canplay seeked",we),v.clickToPlay&&"audio"!==He.type){var e=H("."+v.classes.videoWrapper);if(!e)return;e.style.cursor="pointer",g(e,"click",function(){v.hideControls&&He.browser.isTouch&&!He.media.paused||(He.media.paused?se():He.media.ended?(ue(),se()):ae())})}v.disableContextMenu&&g(He.media,"contextmenu",function(e){e.preventDefault()}),g(He.media,v.events.concat(["keyup","keydown"]).join(" "),function(e){S(He.container,e.type,!0)})}function Oe(){if(a(v.types.html5,He.type)){for(var e=He.media.querySelectorAll("source"),t=0;t=0;n--){var r=n>0?t.cloneNode(!0):t,s=e[n],a=s.parentNode,o=s.nextSibling;return r.appendChild(s),o?a.insertBefore(r,o):a.appendChild(r),r}}function l(e){e&&e.parentNode.removeChild(e)}function u(e,t){e.insertBefore(t,e.firstChild)}function c(e,t){for(var n in t)e.setAttribute(n,P["boolean"](t[n])&&t[n]?"":t[n])}function p(e,n,r){var s=t.createElement(e);c(s,r),u(n,s)}function d(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 f(e,t){return e?e.classList?e.classList.contains(t):new RegExp("(\\s|^)"+t+"(\\s|$)").test(e.className):!1}function y(e,n){var r=Element.prototype,s=r.matches||r.webkitMatchesSelector||r.mozMatchesSelector||r.msMatchesSelector||function(e){return-1!==[].indexOf.call(t.querySelectorAll(e),this)};return s.call(e,n)}function b(e,t,n,r,s){g(e,t,function(t){n&&n.apply(e,[t]),r.apply(e,[t])},s)}function v(e,t,n,r,s){var a=t.split(" ");if(P["boolean"](s)||(s=!1),e instanceof NodeList)for(var o=0;or;r++){var s=e[r];for(var a in s)s[a]&&s[a].constructor&&s[a].constructor===Object?(t[a]=t[a]||{},x(t[a],s[a])):t[a]=s[a]}return t}}function T(){var e={supportsFullScreen:!1,isFullScreen:function(){return!1},requestFullScreen:function(){},cancelFullScreen:function(){},fullScreenEventName:"",element:null,prefix:""},n="webkit o ms khtml".split(" ");if(P.undefined(t.cancelFullScreen))for(var r=0,s=n.length;s>r;r++){if(e.prefix=n[r],!P.undefined(t[e.prefix+"CancelFullScreen"])){e.supportsFullScreen=!0;break}if(!P.undefined(t.msExitFullscreen)&&t.msFullscreenEnabled){e.prefix="ms",e.supportsFullScreen=!0;break}}else e.supportsFullScreen=!0;return e.supportsFullScreen&&(e.fullScreenEventName="ms"===e.prefix?"MSFullscreenChange":e.prefix+"fullscreenchange",e.isFullScreen=function(e){switch(P.undefined(e)&&(e=t.body),this.prefix){case"":return t.fullscreenElement===e;default:return t[this.prefix+"FullscreenElement"]===e}},e.requestFullScreen=function(e){return P.undefined(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 S(y,v){function S(e,t,n,r){h(e,t,n,x({},r,{plyr:De}))}function C(t,n){v.debug&&e.console&&(n=Array.prototype.slice.call(n),P.string(v.logPrefix)&&v.logPrefix.length&&n.unshift(v.logPrefix),console[t].apply(console,n))}function F(){return{url:v.iconUrl,absolute:0===v.iconUrl.indexOf("http")||He.browser.isIE}}function L(){var e=[],t=F(),n=(t.absolute?"":t.url)+"#"+v.iconPrefix;return a(v.controls,"play-large")&&e.push('"),e.push('
'),a(v.controls,"restart")&&e.push('"),a(v.controls,"rewind")&&e.push('"),a(v.controls,"play")&&e.push('",'"),a(v.controls,"fast-forward")&&e.push('"),a(v.controls,"progress")&&(e.push('','','','','',"0% "+v.i18n.buffered,""),v.tooltips.seek&&e.push('00:00'),e.push("")),a(v.controls,"current-time")&&e.push('',''+v.i18n.currentTime+"",'00:00',""),a(v.controls,"duration")&&e.push('',''+v.i18n.duration+"",'00:00',""),a(v.controls,"mute")&&e.push('"),a(v.controls,"volume")&&e.push('','",'','',""),a(v.controls,"captions")&&e.push('"),a(v.controls,"fullscreen")&&e.push('"),e.push("
"),e.join("")}function O(){if(He.supported.full&&("audio"!==He.type||v.fullscreen.allowAudio)&&v.fullscreen.enabled){var e=A.supportsFullScreen;e||v.fullscreen.fallback&&!W()?(Be((e?"Native":"Fallback")+" fullscreen enabled"),m(He.container,v.classes.fullscreen.enabled,!0)):Be("Fullscreen not supported and fallback disabled"),He.buttons&&He.buttons.fullscreen&&k(He.buttons.fullscreen,!1),Y()}}function j(){if("video"===He.type){H(v.selectors.captions)||He.videoContainer.insertAdjacentHTML("afterbegin",'
'),He.usingTextTracks=!1,He.media.textTracks&&(He.usingTextTracks=!0);for(var e,t="",n=He.media.childNodes,r=0;r=10||He.browser.isFirefox&&He.browser.version>=31)&&(Be("Detected browser with known TextTrack issues - using manual fallback"),He.usingTextTracks=!1),He.usingTextTracks){Be("TextTracks supported");for(var o=0;o ");for(var r=0;rHe.captions.length-1){He.subcount=He.captions.length-1;break}He.media.currentTime.toFixed(1)>=n(He.captions[He.subcount][0])&&He.media.currentTime.toFixed(1)<=r(He.captions[He.subcount][0])?(He.currentCaption=He.captions[He.subcount][1],V(He.currentCaption)):V()}}function R(){if(He.buttons.captions){m(He.container,v.classes.captions.enabled,!0);var e=He.storage.captionsEnabled;P["boolean"](e)||(e=v.captions.defaultActive),e&&(m(He.container,v.classes.captions.active,!0),k(He.buttons.captions,!0))}}function D(e){return He.container.querySelectorAll(e)}function H(e){return D(e)[0]}function W(){try{return e.self!==e.top}catch(t){return!0}}function Y(){function e(e){9===e.which&&He.isFullscreen&&(e.target!==r||e.shiftKey?e.target===n&&e.shiftKey&&(e.preventDefault(),r.focus()):(e.preventDefault(),n.focus()))}var t=D("input:not([disabled]), button:not([disabled])"),n=t[0],r=t[t.length-1];g(He.container,"keydown",e)}function B(e,t){if(P.string(t))p(e,He.media,{src:t});else if(t.constructor===Array)for(var n=t.length-1;n>=0;n--)p(e,He.media,t[n])}function X(){if(v.loadSprite){var e=F();e.absolute?(Be("AJAX loading absolute SVG sprite"+(He.browser.isIE?" (due to IE)":"")),_(e.url,"sprite-plyr")):Be("Sprite will be used as external resource directly")}var n=v.html;Be("Injecting custom controls"),n||(n=L()),n=o(n,"{seektime}",v.seekTime),n=o(n,"{id}",Math.floor(1e4*Math.random()));var r;if(P.string(v.selectors.controls.container)&&(r=t.querySelector(v.selectors.controls.container)),P.htmlElement(r)||(r=He.container),r.insertAdjacentHTML("beforeend",n),v.tooltips.controls)for(var s=D([v.selectors.controls.wrapper," ",v.selectors.labels," .",v.classes.hidden].join("")),a=s.length-1;a>=0;a--){var i=s[a];m(i,v.classes.hidden,!1),m(i,v.classes.tooltip,!0)}}function U(){try{return He.controls=H(v.selectors.controls.wrapper),He.buttons={},He.buttons.seek=H(v.selectors.buttons.seek),He.buttons.play=D(v.selectors.buttons.play),He.buttons.pause=H(v.selectors.buttons.pause),He.buttons.restart=H(v.selectors.buttons.restart),He.buttons.rewind=H(v.selectors.buttons.rewind),He.buttons.forward=H(v.selectors.buttons.forward),He.buttons.fullscreen=H(v.selectors.buttons.fullscreen),He.buttons.mute=H(v.selectors.buttons.mute),He.buttons.captions=H(v.selectors.buttons.captions),He.progress={},He.progress.container=H(v.selectors.progress.container),He.progress.buffer={},He.progress.buffer.bar=H(v.selectors.progress.buffer),He.progress.buffer.text=He.progress.buffer.bar&&He.progress.buffer.bar.getElementsByTagName("span")[0],He.progress.played=H(v.selectors.progress.played),He.progress.tooltip=He.progress.container&&He.progress.container.querySelector("."+v.classes.tooltip),He.volume={},He.volume.input=H(v.selectors.volume.input),He.volume.display=H(v.selectors.volume.display),He.duration=H(v.selectors.duration),He.currentTime=H(v.selectors.currentTime),He.seekTime=D(v.selectors.seekTime),!0}catch(e){return Xe("It looks like there is a problem with your controls HTML"),$(!0),!1}}function J(){m(He.container,v.selectors.container.replace(".",""),He.supported.full)}function $(e){e&&a(v.types.html5,He.type)?He.media.setAttribute("controls",""):He.media.removeAttribute("controls")}function G(e){var t=v.i18n.play;if(P.string(v.title)&&v.title.length&&(t+=", "+v.title,He.container.setAttribute("aria-label",v.title)),He.supported.full&&He.buttons.play)for(var n=He.buttons.play.length-1;n>=0;n--)He.buttons.play[n].setAttribute("aria-label",t);P.htmlElement(e)&&e.setAttribute("title",v.i18n.frameTitle.replace("{title}",v.title))}function K(){var t=null;He.storage={},M.supported&&v.storage.enabled&&(e.localStorage.removeItem("plyr-volume"),t=e.localStorage.getItem(v.storage.key),t&&(/^\d+(\.\d+)?$/.test(t)?z({volume:parseFloat(t)}):He.storage=JSON.parse(t)))}function z(t){M.supported&&v.storage.enabled&&(x(He.storage,t),e.localStorage.setItem(v.storage.key,JSON.stringify(He.storage)))}function Q(){if(!He.media)return void Xe("No media element found!");if(He.supported.full&&(m(He.container,v.classes.type.replace("{0}",He.type),!0),a(v.types.embed,He.type)&&m(He.container,v.classes.type.replace("{0}","video"),!0),m(He.container,v.classes.stopped,v.autoplay),m(He.ontainer,v.classes.isIos,He.browser.isIos),m(He.container,v.classes.isTouch,He.browser.isTouch),"video"===He.type)){var e=t.createElement("div");e.setAttribute("class",v.classes.videoWrapper),i(He.media,e),He.videoContainer=e}a(v.types.embed,He.type)&&Z()}function Z(){for(var n=t.createElement("div"),r=He.embedId,a=He.type+"-"+Math.floor(1e4*Math.random()),o=D('[id^="'+He.type+'-"]'),i=o.length-1;i>=0;i--)l(o[i]);if(m(He.media,v.classes.videoWrapper,!0),m(He.media,v.classes.embedWrapper,!0),"youtube"===He.type)He.media.appendChild(n),n.setAttribute("id",a),P.object(e.YT)?te(r,n):(s(v.urls.youtube.api),e.onYouTubeReadyCallbacks=e.onYouTubeReadyCallbacks||[],e.onYouTubeReadyCallbacks.push(function(){te(r,n)}),e.onYouTubeIframeAPIReady=function(){e.onYouTubeReadyCallbacks.forEach(function(e){e()})});else if("vimeo"===He.type)if(He.supported.full?He.media.appendChild(n):n=He.media,n.setAttribute("id",a),P.object(e.Vimeo))ne(r,n);else{s(v.urls.vimeo.api);var u=e.setInterval(function(){P.object(e.Vimeo)&&(e.clearInterval(u),ne(r,n))},50)}else if("soundcloud"===He.type){var p=t.createElement("iframe");p.loaded=!1,g(p,"load",function(){p.loaded=!0}),c(p,{src:"https://w.soundcloud.com/player/?url=https://api.soundcloud.com/tracks/"+r,id:a}),n.appendChild(p),He.media.appendChild(n),e.SC||s(v.urls.soundcloud.api);var d=e.setInterval(function(){e.SC&&p.loaded&&(e.clearInterval(d),re.call(p))},50)}}function ee(){He.supported.full&&(qe(),Re()),G(H("iframe"))}function te(t,n){He.embed=new e.YT.Player(n.id,{videoId:t,playerVars:{autoplay:v.autoplay?1:0,controls:He.supported.full?0:1,rel:0,showinfo:0,iv_load_policy:3,cc_load_policy:v.captions.defaultActive?1:0,cc_lang_pref:"en",wmode:"transparent",modestbranding:1,disablekb:1,origin:"*"},events:{onError:function(e){S(He.container,"error",!0,{code:e.data,embed:e.target})},onReady:function(t){var n=t.target;He.media.play=function(){n.playVideo(),He.media.paused=!1},He.media.pause=function(){n.pauseVideo(),He.media.paused=!0},He.media.stop=function(){n.stopVideo(),He.media.paused=!0},He.media.duration=n.getDuration(),He.media.paused=!0,He.media.currentTime=0,He.media.muted=n.isMuted(),v.title=n.getVideoData().title,He.supported.full&&He.media.querySelector("iframe").setAttribute("tabindex","-1"),ee(),S(He.media,"timeupdate"),S(He.media,"durationchange"),e.clearInterval(We.buffering),We.buffering=e.setInterval(function(){He.media.buffered=n.getVideoLoadedFraction(),(null===He.media.lastBuffered||He.media.lastBufferedt?t=0:t>r&&(t=r),Ce(t);try{He.media.currentTime=t.toFixed(4)}catch(s){}if(a(v.types.embed,He.type)){switch(He.type){case"youtube":He.embed.seekTo(t);break;case"vimeo":He.embed.setCurrentTime(t.toFixed(0));break;case"soundcloud":He.embed.seekTo(1e3*t)}n&&ae(),S(He.media,"timeupdate"),He.media.seeking=!0}Be("Seeking to "+He.media.currentTime+" seconds"),q(t)}function ce(){var e=parseInt(v.duration),t=0;return null===He.media.duration||isNaN(He.media.duration)||(t=He.media.duration),isNaN(e)?t:e}function pe(){m(He.container,v.classes.playing,!He.media.paused),m(He.container,v.classes.stopped,He.media.paused),Ae(He.media.paused)}function de(){I={x:e.pageXOffset||0,y:e.pageYOffset||0}}function me(){e.scrollTo(I.x,I.y)}function fe(e){var n=A.supportsFullScreen;if(n){if(!e||e.type!==A.fullScreenEventName)return A.isFullScreen(He.container)?A.cancelFullScreen():(de(),A.requestFullScreen(He.container)),void(He.isFullscreen=A.isFullScreen(He.container));He.isFullscreen=A.isFullScreen(He.container)}else He.isFullscreen=!He.isFullscreen,t.body.style.overflow=He.isFullscreen?"hidden":"";m(He.container,v.classes.fullscreen.active,He.isFullscreen),Y(He.isFullscreen),He.buttons&&He.buttons.fullscreen&&k(He.buttons.fullscreen,He.isFullscreen),S(He.container,He.isFullscreen?"enterfullscreen":"exitfullscreen",!0),!He.isFullscreen&&n&&me()}function ye(e){if(P["boolean"](e)||(e=!He.media.muted),k(He.buttons.mute,e),He.media.muted=e,0===He.media.volume&&be(v.volume),a(v.types.embed,He.type)){switch(He.type){case"youtube":He.embed[He.media.muted?"mute":"unMute"]();break;case"vimeo":case"soundcloud":He.embed.setVolume(He.media.muted?0:parseFloat(v.volume/v.volumeMax))}S(He.media,"volumechange")}}function be(e){var t=v.volumeMax,n=v.volumeMin;if(P.undefined(e)&&(e=He.storage.volume),(null===e||isNaN(e))&&(e=v.volume),e>t&&(e=t),n>e&&(e=n),He.media.volume=parseFloat(e/t),He.volume.display&&(He.volume.display.value=e),a(v.types.embed,He.type)){switch(He.type){case"youtube":He.embed.setVolume(100*He.media.volume);break;case"vimeo":case"soundcloud":He.embed.setVolume(He.media.volume)}S(He.media,"volumechange")}He.media.muted&&e>0&&ye()}function ve(e){var t=He.media.muted?0:He.media.volume*v.volumeMax;P.number(e)||(e=v.volumeStep),be(t+e)}function ge(e){var t=He.media.muted?0:He.media.volume*v.volumeMax;P.number(e)||(e=v.volumeStep),be(t-e)}function he(){var e=He.media.muted?0:He.media.volume*v.volumeMax;He.supported.full&&(He.volume.input&&(He.volume.input.value=e),He.volume.display&&(He.volume.display.value=e)),z({volume:e}),m(He.container,v.classes.muted,0===e),He.supported.full&&He.buttons.mute&&k(He.buttons.mute,0===e)}function ke(e){He.supported.full&&He.buttons.captions&&(P["boolean"](e)||(e=-1===He.container.className.indexOf(v.classes.captions.active)),He.captionsEnabled=e,k(He.buttons.captions,He.captionsEnabled),m(He.container,v.classes.captions.active,He.captionsEnabled),S(He.container,He.captionsEnabled?"captionsenabled":"captionsdisabled",!0),z({captionsEnabled:He.captionsEnabled}))}function we(e){var t="waiting"===e.type;clearTimeout(We.loading),We.loading=setTimeout(function(){m(He.container,v.classes.loading,t),Ae(t)},t?250:0)}function xe(e){if(He.supported.full){var t=He.progress.played,n=0,r=ce();if(e)switch(e.type){case"timeupdate":case"seeking":if(He.controls.pressed)return;n=w(He.media.currentTime,r),"timeupdate"===e.type&&He.buttons.seek&&(He.buttons.seek.value=n);break;case"playing":case"progress":t=He.progress.buffer,n=function(){var e=He.media.buffered;return e&&e.length?w(e.end(0),r):P.number(e)?100*e:0}()}Te(t,n)}}function Te(e,t){if(He.supported.full){if(P.undefined(t)&&(t=0),P.undefined(e)){if(!He.progress||!He.progress.buffer)return;e=He.progress.buffer}P.htmlElement(e)?e.value=t:e&&(e.bar&&(e.bar.value=t),e.text&&(e.text.innerHTML=t))}}function Se(e,t){if(t){isNaN(e)&&(e=0),He.secs=parseInt(e%60),He.mins=parseInt(e/60%60),He.hours=parseInt(e/60/60%60);var n=parseInt(ce()/60/60%60)>0;He.secs=("0"+He.secs).slice(-2),He.mins=("0"+He.mins).slice(-2),t.innerHTML=(n?He.hours+":":"")+He.mins+":"+He.secs}}function _e(){if(He.supported.full){var e=ce()||0;!He.duration&&v.displayDuration&&He.media.paused&&Se(e,He.currentTime),He.duration&&Se(e,He.duration),Fe()}}function Ee(e){Se(He.media.currentTime,He.currentTime),e&&"timeupdate"===e.type&&He.media.seeking||xe(e)}function Ce(e){P.number(e)||(e=0);var t=ce(),n=w(e,t);He.progress&&He.progress.played&&(He.progress.played.value=n),He.buttons&&He.buttons.seek&&(He.buttons.seek.value=n)}function Fe(e){var t=ce();if(v.tooltips.seek&&He.progress.container&&0!==t){var n=He.progress.container.getBoundingClientRect(),r=0,s=v.classes.tooltip+"--visible";if(e)r=100/n.width*(e.pageX-n.left);else{if(!f(He.progress.tooltip,s))return;r=He.progress.tooltip.style.left.replace("%","")}0>r?r=0:r>100&&(r=100),Se(t/100*r,He.progress.tooltip),He.progress.tooltip.style.left=r+"%",e&&a(["mouseenter","mouseleave"],e.type)&&m(He.progress.tooltip,s,"mouseenter"===e.type)}}function Ae(t){if(v.hideControls&&"audio"!==He.type){var n=0,r=!1,s=t,o=f(He.container,v.classes.loading);if(P["boolean"](t)||(t&&t.type?(r="enterfullscreen"===t.type,s=a(["mousemove","touchstart","mouseenter","focus"],t.type),a(["mousemove","touchmove"],t.type)&&(n=2e3),"focus"===t.type&&(n=3e3)):s=f(He.container,v.classes.hideControls)),e.clearTimeout(We.hover),s||He.media.paused||o){if(m(He.container,v.classes.hideControls,!1),He.media.paused||o)return;He.browser.isTouch&&(n=3e3)}s&&He.media.paused||(We.hover=e.setTimeout(function(){(!He.controls.pressed&&!He.controls.hover||r)&&m(He.container,v.classes.hideControls,!0)},n))}}function Ie(e){if(!P.undefined(e))return void Ne(e);var t;switch(He.type){case"youtube":t=He.embed.getVideoUrl();break;case"vimeo":He.embed.getVideoUrl.then(function(e){t=e});break;case"soundcloud":He.embed.getCurrentSound(function(e){t=e.permalink_url});break;default:t=He.media.currentSrc}return t||""}function Ne(e){function n(){if(He.embed=null,l(He.media),"video"===He.type&&He.videoContainer&&l(He.videoContainer),He.container&&He.container.removeAttribute("class"),"type"in e&&(He.type=e.type,"video"===He.type)){var n=e.sources[0];"type"in n&&a(v.types.embed,n.type)&&(He.type=n.type)}switch(He.supported=E(He.type),He.type){case"video":He.media=t.createElement("video");break;case"audio":He.media=t.createElement("audio");break;case"youtube":case"vimeo":case"soundcloud":He.media=t.createElement("div"),He.embedId=e.sources[0].src}u(He.container,He.media),P["boolean"](e.autoplay)&&(v.autoplay=e.autoplay),a(v.types.html5,He.type)&&(v.crossorigin&&He.media.setAttribute("crossorigin",""),v.autoplay&&He.media.setAttribute("autoplay",""),"poster"in e&&He.media.setAttribute("poster",e.poster),v.loop&&He.media.setAttribute("loop","")),m(He.container,v.classes.fullscreen.active,He.isFullscreen),m(He.container,v.classes.captions.active,He.captionsEnabled),J(),a(v.types.html5,He.type)&&B("source",e.sources),Q(),a(v.types.html5,He.type)&&("tracks"in e&&B("track",e.tracks),He.media.load()),(a(v.types.html5,He.type)||a(v.types.embed,He.type)&&!He.supported.full)&&(qe(),Re()),v.title=e.title,G()}return P.object(e)&&"sources"in e&&e.sources.length?(m(He.container,v.classes.ready,!1),ae(),Ce(),Te(),Oe(),void je(n,!1)):void Xe("Invalid source format")}function Pe(e){"video"===He.type&&He.media.setAttribute("poster",e)}function Me(){function n(){var e=oe(),t=He.buttons[e?"play":"pause"],n=He.buttons[e?"pause":"play"];if(n=n&&n.length>1?n[n.length-1]:n[0]){var r=f(t,v.classes.tabFocus);setTimeout(function(){n.focus(),r&&(m(t,v.classes.tabFocus,!1),m(n,v.classes.tabFocus,!0))},100)}}function r(){var e=t.activeElement;return e=e&&e!==t.body?t.querySelector(":focus"):null}function s(e){return e.keyCode?e.keyCode:e.which}function o(e){for(var t in He.buttons){var n=He.buttons[t];if(P.nodeList(n))for(var r=0;r0)&&(t?ge(n):ve(n)),(e.deltaY>0||e.deltaX<0)&&(t?ve(n):ge(n))})}function Le(){if(g(He.media,"timeupdate seeking",Ee),g(He.media,"timeupdate",q),g(He.media,"durationchange loadedmetadata",_e),g(He.media,"ended",function(){"video"===He.type&&v.showPosterOnEnd&&("video"===He.type&&V(),ue(),He.media.load())}),g(He.media,"progress playing",xe),g(He.media,"volumechange",he),g(He.media,"play pause ended",pe),g(He.media,"waiting canplay seeked",we),v.clickToPlay&&"audio"!==He.type){var e=H("."+v.classes.videoWrapper);if(!e)return;e.style.cursor="pointer",g(e,"click",function(){v.hideControls&&He.browser.isTouch&&!He.media.paused||(He.media.paused?se():He.media.ended?(ue(),se()):ae())})}v.disableContextMenu&&g(He.media,"contextmenu",function(e){e.preventDefault()}),g(He.media,v.events.concat(["keyup","keydown"]).join(" "),function(e){S(He.container,e.type,!0)})}function Oe(){if(a(v.types.html5,He.type)){for(var e=He.media.querySelectorAll("source"),t=0;t