!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define("Plyr",t):e.Plyr=t()}(this,function(){"use strict";function e(e){s.storage&&this.config.storage.enabled&&(n.extend(this.storage,e),window.localStorage.setItem(this.config.storage.key,JSON.stringify(this.storage)))}var t={enabled:!0,title:"",debug:!1,autoplay:!1,seekTime:10,volume:1,muted:!1,displayDuration:!0,clickToPlay:!0,hideControls:!0,showPosterOnEnd:!1,disableContextMenu:!0,loadSprite:!0,iconPrefix:"plyr",iconUrl:"https://cdn.plyr.io/2.0.10/plyr.svg",blankVideo:"https://cdn.plyr.io/static/blank.mp4",duration:null,quality:{default:"default",options:["hd2160","hd1440","hd1080","hd720","large","medium","small","tiny","default"]},loop:{active:!1,start:null,end:null},speed:{default:1,options:[.5,.75,1,1.25,1.5,1.75,2]},keyboard:{focused:!0,global:!1},tooltips:{controls:!1,seek:!0},captions:{active:!1,language:window.navigator.language.split("-")[0]},fullscreen:{enabled:!0,fallback:!0},storage:{enabled:!0,key:"plyr"},controls:["play-large","play","progress","current-time","mute","volume","captions","settings","pip","airplay","fullscreen"],settings:["captions","quality","speed","loop"],i18n:{restart:"Restart",rewind:"Rewind {seektime} secs",play:"Play",pause:"Pause",forward:"Forward {seektime} secs",seek:"Seek",played:"Played",buffered:"Buffered",currentTime:"Current time",duration:"Duration",volume:"Volume",toggleMute:"Toggle Mute",toggleCaptions:"Toggle Captions",toggleFullscreen:"Toggle Fullscreen",frameTitle:"Player for {title}",captions:"Captions",settings:"Settings",speed:"Speed",quality:"Quality",loop:"Loop",start:"Start",end:"End",all:"All",reset:"Reset",none:"None",disabled:"Disabled"},urls:{vimeo:{api:"https://player.vimeo.com/api/player.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,pip:null,airplay:null,speed:null,quality:null,loop:null,language:null},events:["ended","progress","stalled","playing","waiting","canplay","canplaythrough","loadstart","loadeddata","loadedmetadata","timeupdate","volumechange","play","pause","error","seeking","seeked","emptied","ratechange","cuechange","enterfullscreen","exitfullscreen","captionsenabled","captionsdisabled","captionchange","controlshidden","controlsshown","ready","statechange","qualitychange","qualityrequested"],selectors:{editable:"input, textarea, select, [contenteditable]",container:".plyr",controls:{container:null,wrapper:".plyr__controls"},labels:"[data-plyr]",buttons:{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"]',captions:'[data-plyr="captions"]',fullscreen:'[data-plyr="fullscreen"]',pip:'[data-plyr="pip"]',airplay:'[data-plyr="airplay"]',settings:'[data-plyr="settings"]',loop:'[data-plyr="loop"]'},inputs:{seek:'[data-plyr="seek"]',volume:'[data-plyr="volume"]',speed:'[data-plyr="speed"]',language:'[data-plyr="language"]',quality:'[data-plyr="quality"]'},display:{currentTime:".plyr__time--current",duration:".plyr__time--duration",buffer:".plyr__progress--buffer",played:".plyr__progress--played",loop:".plyr__progress--loop",volume:".plyr__volume--display"},progress:".plyr__progress",captions:".plyr__captions",menu:{quality:".js-plyr__menu__list--quality"}},classNames:{video:"plyr__video-wrapper",embed:"plyr__video-embed",control:"plyr__control",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",hideControls:"plyr--hide-controls",isIos:"plyr--is-ios",isTouch:"plyr--is-touch",uiSupported:"plyr--full-ui",menu:{value:"plyr__menu__value",badge:"plyr__badge"},captions:{enabled:"plyr--captions-enabled",active:"plyr--captions-active"},fullscreen:{enabled:"plyr--fullscreen-enabled",fallback:"plyr--fullscreen-fallback"},pip:{supported:"plyr--pip-supported",active:"plyr--pip-active"},airplay:{supported:"plyr--airplay-supported",active:"plyr--airplay-active"},tabFocus:"tab-focus"}},i={embed:["youtube","vimeo"],html5:["video","audio"]},n={is:{object:function(e){return this.getConstructor(e)===Object},number:function(e){return this.getConstructor(e)===Number&&!Number.isNaN(e)},string:function(e){return this.getConstructor(e)===String},boolean:function(e){return this.getConstructor(e)===Boolean},function:function(e){return this.getConstructor(e)===Function},array:function(e){return!this.undefined(e)&&Array.isArray(e)},nodeList:function(e){return!this.undefined(e)&&e instanceof NodeList},htmlElement:function(e){return!this.undefined(e)&&e instanceof HTMLElement},event:function(e){return!this.undefined(e)&&e instanceof Event},cue:function(e){return this.instanceOf(e,window.TextTrackCue)||this.instanceOf(e,window.VTTCue)},track:function(e){return!this.undefined(e)&&(this.instanceOf(e,window.TextTrack)||"string"==typeof e.kind)},undefined:function(e){return null!==e&&void 0===e},empty:function(e){return null===e||void 0===e||(this.string(e)||this.array(e)||this.nodeList(e))&&0===e.length||this.object(e)&&0===Object.keys(e).length},getConstructor:function(e){return null===e||void 0===e?null:e.constructor},instanceOf:function(e,t){return Boolean(e&&t&&e instanceof t)}},getBrowser:function(){return{isIE:!!document.documentMode,isWebkit:"WebkitAppearance"in document.documentElement.style&&!/Edge/.test(navigator.userAgent),isIPhone:/(iPhone|iPod)/gi.test(navigator.platform),isIos:/(iPad|iPhone|iPod)/gi.test(navigator.platform)}},loadScript:function(e){if(!document.querySelectorAll('script[src="'+e+'"]').length){var t=document.createElement("script");t.src=e;var i=document.getElementsByTagName("script")[0];i.parentNode.insertBefore(t,i)}},generateId:function(e){return e+"-"+Math.floor(1e4*Math.random())},inFrame:function(){try{return window.self!==window.top}catch(e){return!0}},wrap:function(e,t){var i=e.length?e:[e];Array.from(i).reverse().forEach(function(e,i){var n=i>0?t.cloneNode(!0):t,s=e.parentNode,a=e.nextSibling;n.appendChild(e),a?s.insertBefore(n,a):s.appendChild(n)})},removeElement:function(e){return n.is.htmlElement(e)&&n.is.htmlElement(e.parentNode)?(e.parentNode.removeChild(e),e):null},insertAfter:function(e,t){t.parentNode.insertBefore(e,t.nextSibling)},createElement:function(e,t,i){var s=document.createElement(e);return n.is.object(t)&&n.setAttributes(s,t),n.is.string(i)&&(s.textContent=i),s},insertElement:function(e,t,i,s){t.appendChild(n.createElement(e,i,s))},emptyElement:function(e){for(var t=e.childNodes.length;t>0;)e.removeChild(e.lastChild),t-=1},setAttributes:function(e,t){Object.keys(t).forEach(function(i){e.setAttribute(i,t[i])})},getAttributesFromSelector:function(e,t){if(!n.is.string(e)||n.is.empty(e))return{};var i={},s=t;return e.split(",").forEach(function(e){var t=e.trim(),a=t.replace(".",""),l=t.replace(/[[\]]/g,"").split("="),o=l[0],r=l.length>1?l[1].replace(/["']/g,""):"";switch(t.charAt(0)){case".":n.is.object(s)&&n.is.string(s.class)&&(s.class+=" "+a),i.class=a;break;case"#":i.id=t.replace("#","");break;case"[":i[o]=r}}),i},toggleClass:function(e,t,i){if(n.is.htmlElement(e)){var s=e.classList.contains(t);return e.classList[i?"add":"remove"](t),i&&!s||!i&&s}return null},hasClass:function(e,t){return n.is.htmlElement(e)&&e.classList.contains(t)},matches:function(e,t){var i={Element:Element},n=i.matches||i.webkitMatchesSelector||i.mozMatchesSelector||i.msMatchesSelector||function(){return Array.from(document.querySelectorAll(t)).includes(this)};return n.call(e,t)},getElements:function(e){return this.elements.container.querySelectorAll(e)},getElement:function(e){return this.elements.container.querySelector(e)},findElements:function(){try{return this.elements.controls=n.getElement.call(this,this.config.selectors.controls.wrapper),this.elements.buttons={play:n.getElements.call(this,this.config.selectors.buttons.play),pause:n.getElement.call(this,this.config.selectors.buttons.pause),restart:n.getElement.call(this,this.config.selectors.buttons.restart),rewind:n.getElement.call(this,this.config.selectors.buttons.rewind),forward:n.getElement.call(this,this.config.selectors.buttons.forward),mute:n.getElement.call(this,this.config.selectors.buttons.mute),pip:n.getElement.call(this,this.config.selectors.buttons.pip),airplay:n.getElement.call(this,this.config.selectors.buttons.airplay),settings:n.getElement.call(this,this.config.selectors.buttons.settings),captions:n.getElement.call(this,this.config.selectors.buttons.captions),fullscreen:n.getElement.call(this,this.config.selectors.buttons.fullscreen)},this.elements.progress=n.getElement.call(this,this.config.selectors.progress),this.elements.inputs={seek:n.getElement.call(this,this.config.selectors.inputs.seek),volume:n.getElement.call(this,this.config.selectors.inputs.volume)},this.elements.display={buffer:n.getElement.call(this,this.config.selectors.display.buffer),duration:n.getElement.call(this,this.config.selectors.display.duration),currentTime:n.getElement.call(this,this.config.selectors.display.currentTime)},n.is.htmlElement(this.elements.progress)&&(this.elements.display.seekTooltip=this.elements.progress.querySelector("."+this.config.classNames.tooltip)),!0}catch(e){return this.warn("It looks like there is a problem with your custom controls HTML",e),this.toggleNativeControls(!0),!1}},getFocusElement:function(){var e=document.activeElement;return e=e&&e!==document.body?document.querySelector(":focus"):null},trapFocus:function(){var e=this,t=n.getElements.call(this,"input:not([disabled]), button:not([disabled])"),i=t[0],s=t[t.length-1];n.on(this.elements.container,"keydown",function(t){9===t.which&&e.fullscreen.active&&(t.target!==s||t.shiftKey?t.target===i&&t.shiftKey&&(t.preventDefault(),s.focus()):(t.preventDefault(),i.focus()))},!1)},proxy:function(e,t,i,s,a,l){n.on(e,t,function(t){i&&i.apply(e,[t]),s.apply(e,[t])},a,l)},toggleListener:function(e,t,i,a,l,o){if(null!==e&&!n.is.undefined(e))if(e instanceof NodeList)Array.from(e).forEach(function(e){e instanceof Node&&n.toggleListener.call(null,e,t,i,a,l,o)});else{var r=t.split(" "),c=!!n.is.boolean(o)&&o;s.passiveListeners&&(c={passive:!n.is.boolean(l)||l,capture:!!n.is.boolean(o)&&o}),r.forEach(function(t){e[a?"addEventListener":"removeEventListener"](t,i,c)})}},on:function(e,t,i,s,a){n.toggleListener(e,t,i,!0,s,a)},off:function(e,t,i,s,a){n.toggleListener(e,t,i,!1,s,a)},dispatchEvent:function(e,t,i,s){if(e&&t){var a=new CustomEvent(t,{bubbles:!!n.is.boolean(i)&&i,detail:Object.assign({},s,{plyr:this instanceof Plyr?this:null})});e.dispatchEvent(a)}},toggleState:function(e,t){if(!e)return null;var i=n.is.boolean(t)?t:!e.getAttribute("aria-pressed");return e.setAttribute("aria-pressed",i),i},getPercentage:function(e,t){return 0===e||0===t||Number.isNaN(e)||Number.isNaN(t)?0:(e/t*100).toFixed(2)},extend:function(){for(var e=arguments.length,t=Array(e),i=0;i0&&a.setCue.call(this,this.captions.currentTrack))}else"vimeo"===this.type&&this.captions.active&&this.embed.enableTextTrack(this.captions.language);this.config.controls.includes("settings")&&this.config.settings.includes("captions")&&a.setCaptionsMenu.call(this)}}},setCue:function(e){var t=(n.is.event(e)?e.target:e).activeCues[0];n.is.cue(t)?l.set.call(this,t.getCueAsHTML()):l.set.call(this),n.dispatchEvent.call(this,this.media,"cuechange")},set:function(e){if(this.supported.ui)if(n.is.htmlElement(this.elements.captions)){var t=n.createElement("span");n.emptyElement(this.elements.captions);var i=n.is.undefined(e)?"":e;n.is.string(i)?t.textContent=i.trim():t.appendChild(i),this.elements.captions.appendChild(t)}else this.warn("No captions element to render to")},show:function(){if(this.elements.buttons.captions){var e=this.storage.captions;n.is.boolean(e)?this.captions.active=e:e=this.captions.active,e&&(n.toggleClass(this.elements.container,this.config.classNames.captions.active,!0),n.toggleState(this.elements.buttons.captions,!0))}}},o=function(){var e=!1;return n.is.function(document.cancelFullScreen)?e="":["webkit","o","moz","ms","khtml"].some(function(t){return n.is.function(document[t+"CancelFullScreen"])?(e=t,!0):!(!n.is.function(document.msExitFullscreen)||!document.msFullscreenEnabled)&&(e="ms",!0)}),e}(),r={prefix:o,enabled:document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled,eventType:"ms"===o?"MSFullscreenChange":o+"fullscreenchange",isFullScreen:function(e){if(!r.enabled)return!1;var t=n.is.undefined(e)?document.body:e;switch(o){case"":return document.fullscreenElement===t;case"moz":return document.mozFullScreenElement===t;default:return document[o+"FullscreenElement"]===t}},requestFullScreen:function(e){if(!r.enabled)return!1;var t=n.is.undefined(e)?document.body:e;return o.length?t[o+("ms"===o?"RequestFullscreen":"RequestFullScreen")]():t.requestFullScreen()},cancelFullScreen:function(){return!!r.enabled&&(o.length?document[o+("ms"===o?"ExitFullscreen":"CancelFullScreen")]():document.cancelFullScreen())},element:function(){return r.enabled?o.length?document[o+"FullscreenElement"]:document.fullscreenElement:null},setup:function(){if(this.supported.ui&&"audio"!==this.type&&this.config.fullscreen.enabled){var e=r.enabled;e||this.config.fullscreen.fallback&&!n.inFrame()?(this.log((e?"Native":"Fallback")+" fullscreen enabled"),n.toggleClass(this.elements.container,this.config.classNames.fullscreen.enabled,!0)):this.log("Fullscreen not supported and fallback disabled"),this.elements.buttons&&this.elements.buttons.fullscreen&&n.toggleState(this.elements.buttons.fullscreen,!1),n.trapFocus.call(this)}}},c={setup:function(){var t=null,i={};return s.storage&&this.config.storage.enabled?(window.localStorage.removeItem("plyr-volume"),(t=window.localStorage.getItem(this.config.storage.key))&&(/^\d+(\.\d+)?$/.test(t)?e({volume:parseFloat(t)}):i=JSON.parse(t)),i):i},set:e},u={media:function(){var e=this;if(n.on(this.media,"timeupdate seeking",function(t){return d.timeUpdate.call(e,t)}),n.on(this.media,"durationchange loadedmetadata",function(t){return d.displayDuration.call(e,t)}),n.on(this.media,"ended",function(){"video"===e.type&&e.config.showPosterOnEnd&&(e.restart(),e.media.load())}),n.on(this.media,"progress playing",function(t){return d.updateProgress.call(e,t)}),n.on(this.media,"volumechange",function(t){return d.updateVolume.call(e,t)}),n.on(this.media,"play pause ended",function(t){return d.checkPlaying.call(e,t)}),n.on(this.media,"waiting canplay seeked",function(t){return d.checkLoading.call(e,t)}),this.supported.ui&&this.config.clickToPlay&&"audio"!==this.type){var t=n.getElement.call(this,"."+this.config.classNames.video);if(!t)return;t.style.cursor="pointer",n.on(t,"click",function(){e.config.hideControls&&s.touch&&!e.media.paused||(e.media.paused?e.play():e.media.ended?(e.restart(),e.play()):e.pause())})}this.config.disableContextMenu&&n.on(this.media,"contextmenu",function(e){e.preventDefault()},!1),n.on(this.media,"ratechange",function(){a.updateSetting.call(e,"speed"),c.set.call(e,{speed:e.speed})}),n.on(this.media,"qualitychange",function(){a.updateSetting.call(e,"quality"),c.set.call(e,{quality:e.quality})}),n.on(this.media,"captionchange",function(){c.set.call(e,{language:e.captions.language})}),n.on(this.media,"captionsenabled captionsdisabled",function(){a.updateSetting.call(e,"captions"),c.set.call(e,{captions:e.captions.enabled})}),n.on(this.media,this.config.events.concat(["keyup","keydown"]).join(" "),function(t){n.dispatchEvent.call(e,e.elements.container,t.type,!0)})},controls:function(){function e(e){return e.keyCode?e.keyCode:e.which}function t(t){var i=e(t),s="keydown"===t.type,a=s&&i===l;if(n.is.number(i))if(s){var c=[48,49,50,51,52,53,54,56,57,32,75,38,40,77,39,37,70,67,73,76,79];if([38,40].includes(i)){var u=n.getFocusElement();if(n.is.htmlElement(u)&&"radio"===n.getFocusElement().type)return}switch(c.includes(i)&&(t.preventDefault(),t.stopPropagation()),i){case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:a||function(){this.currentTime=this.duration/10*(i-48)}();break;case 32:case 75:a||o();break;case 38:this.increaseVolume(.1);break;case 40:this.decreaseVolume(.1);break;case 77:a||this.toggleMute();break;case 39:this.forward();break;case 37:this.rewind();break;case 70:this.toggleFullscreen();break;case 67:a||this.toggleCaptions();break;case 73:this.setLoop("start");break;case 76:this.setLoop();break;case 79:this.setLoop("end")}!r.enabled&&this.fullscreen.active&&27===i&&this.toggleFullscreen(),l=i}else l=null}var i=this,s=this.browser.isIE?"change":"input",l=null,o=function(){var e=i.togglePlay(),t=i.elements.buttons[e?"pause":"play"];n.is.htmlElement(t)&&t.focus()};this.config.keyboard.focused&&(this.config.keyboard.global&&n.on(window,"keydown keyup",function(s){var a=e(s),l=n.getFocusElement();![48,49,50,51,52,53,54,56,57,75,77,70,67,73,76,79].includes(a)||n.is.htmlElement(l)&&n.matches(l,i.config.selectors.editable)||t(s)},!1),n.on(this.elements.container,"keydown keyup",t,!1)),n.on(this.elements.container,"focusout",function(e){n.toggleClass(e.target,i.config.classNames.tabFocus,!1)}),n.on(this.elements.container,"keydown",function(e){9===e.keyCode&&window.setTimeout(function(){n.toggleClass(n.getFocusElement(),i.config.classNames.tabFocus,!0)},0)});var c=function(e,t,s){n.is.function(t)&&t.call(i,e),n.is.function(s)&&s.call(i,e)};n.proxy(this.elements.buttons.play,"click",this.config.listeners.play,o),n.proxy(this.elements.buttons.playLarge,"click",this.config.listeners.play,o),n.proxy(this.elements.buttons.pause,"click",this.config.listeners.pause,o),n.proxy(this.elements.buttons.restart,"click",this.config.listeners.restart,function(){i.restart()}),n.proxy(this.elements.buttons.rewind,"click",this.config.listeners.rewind,function(){i.rewind()}),n.proxy(this.elements.buttons.forward,"click",this.config.listeners.forward,function(){i.forward()}),n.proxy(this.elements.buttons.mute,"click",this.config.listeners.mute,function(){i.toggleMute()}),n.proxy(this.elements.buttons.captions,"click",this.config.listeners.captions,function(){i.toggleCaptions()}),n.proxy(this.elements.buttons.fullscreen,"click",this.config.listeners.fullscreen,function(){i.toggleFullscreen()}),n.proxy(this.elements.buttons.pip,"click",this.config.listeners.pip,function(){i.togglePictureInPicture()}),n.proxy(this.elements.buttons.airplay,"click",this.config.listeners.airplay,function(){i.airPlay()}),n.on(this.elements.buttons.settings,"click",function(e){a.toggleMenu.call(i,e)}),n.on(document.documentElement,"click",function(e){a.toggleMenu.call(i,e)}),n.on(this.elements.settings.form,"click",function(e){a.showTab.call(i,e),n.matches(e.target,i.config.selectors.inputs.language)?c.call(i,e,i.config.listeners.language,function(){i.toggleCaptions(!0),i.language=e.target.value.toLowerCase()}):n.matches(e.target,i.config.selectors.inputs.quality)?c.call(i,e,i.config.listeners.quality,function(){i.quality=e.target.value}):n.matches(e.target,i.config.selectors.inputs.speed)?c.call(i,e,i.config.listeners.speed,function(){i.speed=parseFloat(e.target.value)}):n.matches(e.target,i.config.selectors.buttons.loop)&&c.call(i,e,i.config.listeners.loop,function(){i.warn("Set loop")})}),n.proxy(this.elements.inputs.seek,s,this.config.listeners.seek,function(e){i.currentTime=e.target.value/e.target.max*i.duration}),n.proxy(this.elements.inputs.volume,s,this.config.listeners.volume,function(e){i.setVolume(e.target.value)}),this.browser.isWebkit&&n.on(n.getElements.call(this,'input[type="range"]'),"input",function(e){a.updateRangeFill.call(i,e.target)}),n.on(this.elements.progress,"mouseenter mouseleave mousemove",function(e){return d.updateSeekTooltip.call(i,e)}),this.config.hideControls&&(n.on(this.elements.container,"mouseenter mouseleave mousemove touchstart touchend touchcancel touchmove enterfullscreen",function(e){i.toggleControls(e)}),n.on(this.elements.controls,"mouseenter mouseleave",function(e){i.elements.controls.hover="mouseenter"===e.type}),n.on(this.elements.controls,"mousedown mouseup touchstart touchend touchcancel",function(e){i.elements.controls.pressed=["mousedown","touchstart"].includes(e.type)}),n.on(this.elements.controls,"focus blur",function(e){i.toggleControls(e)},!0)),n.proxy(this.elements.inputs.volume,"wheel",this.config.listeners.volume,function(e){var t=e.webkitDirectionInvertedFromDevice,n=0;(e.deltaY<0||e.deltaX>0)&&(t?(i.decreaseVolume(.02),n=-1):(i.increaseVolume(.02),n=1)),(e.deltaY>0||e.deltaX<0)&&(t?(i.increaseVolume(.02),n=1):(i.decreaseVolume(.02),n=-1)),(1===n&&i.media.volume<1||-1===n&&i.media.volume>0)&&e.preventDefault()},!1),r.enabled&&n.on(document,r.eventType,function(e){i.toggleFullscreen(e)})}},d={addStyleHook:function(){n.toggleClass(this.elements.container,this.config.selectors.container.replace(".",""),!0),n.toggleClass(this.elements.container,this.config.classNames.uiSupported,this.supported.ui)},toggleNativeControls:function(e){e&&this.isHTML5?this.media.setAttribute("controls",""):this.media.removeAttribute("controls")},build:function(){if(u.media.call(this),!this.supported.ui)return this.warn("Basic support only for "+this.type),n.removeElement.call(this,"controls"),n.removeElement.call(this,"buttons.play"),void d.toggleNativeControls.call(this,!0);n.is.htmlElement(this.elements.controls)||(a.inject.call(this),u.controls.call(this)),n.is.htmlElement(this.elements.controls)&&(d.toggleNativeControls.call(this),r.setup.call(this),l.setup.call(this),this.volume=null,d.updateVolume.call(this),this.speed=null,d.timeUpdate.call(this),d.checkPlaying.call(this),this.ready=!0,n.dispatchEvent.call(this,this.media,"ready"),this.config.autoplay&&this.play())},displayDuration:function(){this.supported.ui&&(!this.elements.display.duration&&this.config.displayDuration&&this.media.paused&&d.updateTimeDisplay.call(this,this.duration,this.elements.display.currentTime),this.elements.display.duration&&d.updateTimeDisplay.call(this,this.duration,this.elements.display.duration),d.updateSeekTooltip.call(this))},setTitle:function(){var e=this.config.i18n.play;if(n.is.string(this.config.title)&&!n.is.empty(this.config.title)&&(e+=", "+this.config.title,this.elements.container.setAttribute("aria-label",this.config.title)),this.supported.ui&&(n.is.htmlElement(this.elements.buttons.play)&&this.elements.buttons.play.setAttribute("aria-label",e),n.is.htmlElement(this.elements.buttons.playLarge)&&this.elements.buttons.playLarge.setAttribute("aria-label",e)),this.isEmbed){var t=n.getElement.call(this,"iframe");if(!n.is.htmlElement(t))return;var i=n.is.empty(this.config.title)?"video":this.config.title;t.setAttribute("title",this.config.i18n.frameTitle.replace("{title}",i))}},checkPlaying:function(){n.toggleClass(this.elements.container,this.config.classNames.playing,!this.media.paused),n.toggleClass(this.elements.container,this.config.classNames.stopped,this.media.paused),this.toggleControls(this.media.paused)},updateVolume:function(){if(this.supported.ui){var e=this.media.muted?0:this.media.volume;this.elements.inputs.volume&&d.setRange.call(this,this.elements.inputs.volume,e)}c.set.call(this,{volume:this.media.volume}),n.toggleClass(this.elements.container,this.config.classNames.muted,this.media.muted),this.supported.ui&&this.elements.buttons.mute&&n.toggleState(this.elements.buttons.mute,this.media.muted)},checkLoading:function(e){var t=this;this.loading="waiting"===e.type,clearTimeout(this.timers.loading),this.timers.loading=setTimeout(function(){n.toggleClass(t.elements.container,t.config.classNames.loading,t.loading),t.toggleControls(t.loading)},this.loading?250:0)},setRange:function(e,t){n.is.htmlElement(e)&&(e.value=t,a.updateRangeFill.call(this,e))},setProgress:function(e,t){var i=n.is.undefined(t)?0:t,s=n.is.undefined(e)?this.elements.display.buffer:e;if(n.is.htmlElement(s)){s.value=i;var a=s.getElementsByTagName("span")[0];n.is.htmlElement(a)&&(a.childNodes[0].nodeValue=i)}},updateProgress:function(e){var t=this;if(this.supported.ui){var i=0;if(e)switch(e.type){case"timeupdate":case"seeking":i=n.getPercentage(this.currentTime,this.duration),"timeupdate"===e.type&&d.setRange.call(this,this.elements.inputs.seek,i);break;case"playing":case"progress":i=function(){var e=t.media.buffered;return e&&e.length?n.getPercentage(e.end(0),t.duration):n.is.number(e)?100*e:0}(),d.setProgress.call(this,this.elements.display.buffer,i)}}},updateTimeDisplay:function(e,t){if(!n.is.htmlElement(t))return null;var i=Number.isNaN(e)?0:e,s=parseInt(i%60,10),a=parseInt(i/60%60,10),l=parseInt(i/60/60%60,10),o=parseInt(this.duration/60/60%60,10)>0;s=("0"+s).slice(-2),a=("0"+a).slice(-2);var r=(o?l+":":"")+a+":"+s;return t.textContent=r,r},timeUpdate:function(e){d.updateTimeDisplay.call(this,this.currentTime,this.elements.display.currentTime),e&&"timeupdate"===e.type&&this.media.seeking||d.updateProgress.call(this,e)},updateSeekTooltip:function(e){if(this.config.tooltips.seek&&n.is.htmlElement(this.elements.inputs.seek)&&n.is.htmlElement(this.elements.display.seekTooltip)&&0!==this.duration){var t=this.elements.inputs.seek.getBoundingClientRect(),i=0,s=this.config.classNames.tooltip+"--visible";if(n.is.event(e))i=100/t.width*(e.pageX-t.left);else{if(!n.hasClass(this.elements.display.seekTooltip,s))return;i=this.elements.display.seekTooltip.style.left.replace("%","")}i<0?i=0:i>100&&(i=100),d.updateTimeDisplay.call(this,this.duration/100*i,this.elements.display.seekTooltip),this.elements.display.seekTooltip.style.left=i+"%",n.is.event(e)&&["mouseenter","mouseleave"].includes(e.type)&&n.toggleClass(this.elements.display.seekTooltip,s,"mouseenter"===e.type)}}},h={setup:function(){var e=this,t=n.parseYouTubeId(this.embedId),i=n.getElements.call(this,'[id^="'+this.type+'-"]');Array.from(i).forEach(n.removeElement),n.toggleClass(this.elements.wrapper,this.config.classNames.embed,!0),this.media.setAttribute("id",n.generateId(this.type)),n.is.object(window.YT)?h.ready.call(this,t):(n.loadScript(this.config.urls.youtube.api),window.onYouTubeReadyCallbacks=window.onYouTubeReadyCallbacks||[],window.onYouTubeReadyCallbacks.push(function(){h.ready.call(e,t)}),window.onYouTubeIframeAPIReady=function(){window.onYouTubeReadyCallbacks.forEach(function(e){e()})})},ready:function(e){var t=this;t.embed=new window.YT.Player(t.media.id,{videoId:e,playerVars:{autoplay:t.config.autoplay?1:0,controls:t.supported.ui?0:1,rel:0,showinfo:0,iv_load_policy:3,modestbranding:1,disablekb:1,playsinline:1,origin:window&&window.location.hostname,widget_referrer:window&&window.location.href},events:{onError:function(e){n.dispatchEvent.call(t,t.media,"error",!0,{code:e.data,embed:e.target})},onPlaybackQualityChange:function(e){var i=e.target;t.media.quality=i.getPlaybackQuality(),n.dispatchEvent.call(t,t.media,"qualitychange")},onPlaybackRateChange:function(e){var i=e.target;t.media.playbackRate=i.getPlaybackRate(),n.dispatchEvent.call(t,t.media,"ratechange")},onReady:function(e){var i=e.target;t.media.play=function(){i.playVideo(),t.media.paused=!1},t.media.pause=function(){i.pauseVideo(),t.media.paused=!0},t.media.stop=function(){i.stopVideo(),t.media.paused=!0},t.media.duration=i.getDuration(),t.media.paused=!0,t.media.muted=i.isMuted(),t.media.currentTime=0,t.config.controls.includes("settings")&&t.config.settings.includes("speed")&&a.setSpeedMenu.call(t,i.getAvailablePlaybackRates()),t.config.title=i.getVideoData().title,t.supported.ui&&t.media.setAttribute("tabindex",-1),d.build.call(t),n.dispatchEvent.call(t,t.media,"timeupdate"),n.dispatchEvent.call(t,t.media,"durationchange"),window.clearInterval(t.timers.buffering),t.timers.buffering=window.setInterval(function(){t.media.buffered=i.getVideoLoadedFraction(),(null===t.media.lastBuffered||t.media.lastBuffered=this.currentTime)return this;this.config.loop.end=this.currentTime;break;case"all":this.config.loop.start=0,this.config.loop.end=this.duration-2,this.config.loop.indicator.start=0,this.config.loop.indicator.end=100;break;case"toggle":this.config.loop.active?(this.config.loop.start=0,this.config.loop.end=null):(this.config.loop.start=0,this.config.loop.end=this.duration-2);break;default:this.config.loop.start=0,this.config.loop.end=null}return this}},{key:"toggleCaptions",value:function(e){if(!this.supported.ui||!this.elements.buttons.captions)return this;var t=n.is.boolean(e)?e:-1===this.elements.container.className.indexOf(this.config.classNames.captions.active);return this.captions.enabled===t?this:(this.captions.enabled=t,n.toggleState(this.elements.buttons.captions,this.captions.enabled),n.toggleClass(this.elements.container,this.config.classNames.captions.active,this.captions.enabled),n.dispatchEvent.call(this,this.media,this.captions.enabled?"captionsenabled":"captionsdisabled"),this)}},{key:"toggleFullscreen",value:function(e){if(r.enabled){if(!n.is.event(e)||e.type!==r.eventType)return this.fullscreen.active?r.cancelFullScreen():r.requestFullScreen(this.elements.container),this.fullscreen.active=r.isFullScreen(this.elements.container),this;this.fullscreen.active=r.isFullScreen(this.elements.container)}else this.fullscreen.active=!this.fullscreen.active,n.toggleClass(this.elements.container,this.config.classNames.fullscreen.fallback,this.fullscreen.active),this.fullscreen.active?b={x:window.pageXOffset||0,y:window.pageYOffset||0}:window.scrollTo(b.x,b.y),document.body.style.overflow=this.fullscreen.active?"hidden":"";return this.elements.buttons&&this.elements.buttons.fullscreen&&n.toggleState(this.elements.buttons.fullscreen,this.fullscreen.active),n.dispatchEvent.call(this,this.media,this.fullscreen.active?"enterfullscreen":"exitfullscreen"),this}},{key:"togglePictureInPicture",value:function(e){var t=this,i={pip:"picture-in-picture",inline:"inline"};if(!s.pip)return t;var a=n.is.boolean(e)?e:this.media.webkitPresentationMode===i.inline;return this.media.webkitSetPresentationMode(a?i.pip:i.inline),this}},{key:"airPlay",value:function(){return s.airplay?(this.media.webkitShowPlaybackTargetPicker(),this):this}},{key:"toggleControls",value:function(e){var t=this,i=this;if(!n.is.htmlElement(this.elements.controls))return i;if(!this.supported.ui||!this.config.hideControls||"audio"===this.type)return i;var l=0,o=e,r=!1,c=n.hasClass(this.elements.container,this.config.classNames.loading);if(n.is.boolean(e)||(n.is.event(e)?(r="enterfullscreen"===e.type,o=["mousemove","touchstart","mouseenter","focus"].includes(e.type),["mousemove","touchmove"].includes(e.type)&&(l=2e3),"focus"===e.type&&(l=3e3)):o=n.hasClass(this.elements.container,this.config.classNames.hideControls)),window.clearTimeout(this.timers.hover),o||this.media.paused||c){if(n.toggleClass(this.elements.container,this.config.classNames.hideControls,!1)&&n.dispatchEvent.call(this,this.media,"controlsshown"),this.media.paused||c)return i;s.touch&&(l=3e3)}return o&&this.media.paused||(this.timers.hover=window.setTimeout(function(){(!t.elements.controls.pressed&&!t.elements.controls.hover||r)&&n.toggleClass(t.elements.container,t.config.classNames.hideControls,!0)&&(n.dispatchEvent.call(t,t.media,"controlshidden"),t.config.controls.includes("settings")&&!n.is.empty(t.config.settings)&&a.toggleMenu.call(t,!1))},l)),this}},{key:"on",value:function(e,t){return n.on(this.elements.container,e,t),this}},{key:"off",value:function(e,t){return n.off(this.elements.container,e,t),this}},{key:"supports",value:function(e){return s.mime(this,e)}},{key:"destroy",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],s=function(){if(document.body.style.overflow="",t.embed=null,i)n.removeElement(t.elements.captions),n.removeElement(t.elements.controls),n.removeElement(t.elements.wrapper),t.elements.captions=null,t.elements.controls=null,t.elements.wrapper=null,n.is.function(e)&&e();else{var s=t.elements.container.parentNode;n.is.htmlElement(s)&&s.replaceChild(t.elements.original,t.elements.container),n.dispatchEvent.call(t,t.elements.original,"destroyed",!0),n.is.function(e)&&e.call(t.elements.original),t.elements=null}};switch(this.type){case"youtube":window.clearInterval(this.timers.buffering),window.clearInterval(this.timers.playing),this.embed.destroy(),s();break;case"vimeo":this.embed.unload().then(s),window.setTimeout(s,200);break;case"video":case"audio":d.toggleNativeControls.call(this,!0),s()}}},{key:"isHTML5",get:function(){return i.html5.includes(this.type)}},{key:"isEmbed",get:function(){return i.embed.includes(this.type)}},{key:"currentTime",set:function(e){var t=0;if(n.is.number(e)&&(t=e),t<0?t=0:t>this.duration&&(t=this.duration),this.isEmbed){var i=this.media.paused;switch(this.type){case"youtube":this.embed.seekTo(t);break;case"vimeo":this.embed.setCurrentTime(t)}i&&this.pause(),this.media.seeking=!0,n.dispatchEvent.call(this,this.media,"seeking")}else this.media.currentTime=t.toFixed(4);this.log("Seeking to "+this.currentTime+" seconds")},get:function(){return Number(this.media.currentTime)}},{key:"duration",get:function(){var e=parseInt(this.config.duration,10),t=Number(this.media.duration);return Number.isNaN(e)?t:e}},{key:"volume",set:function(e){var t=e,i=!n.is.undefined(t);if(n.is.string(t)&&(t=parseFloat(t)),n.is.number(t)||(t=this.storage.volume),n.is.number(t)||(t=this.config.volume),t>1&&(t=1),t<0&&(t=0),this.media.volume=t,this.isEmbed){switch(this.type){case"youtube":this.embed.setVolume(100*this.media.volume);break;case"vimeo":this.embed.setVolume(this.media.volume)}n.dispatchEvent.call(this,this.media,"volumechange")}return 0===t?this.toggleMute(!0):this.media.muted&&i&&this.toggleMute(),this},get:function(){return this.media.volume}},{key:"speed",set:function(e){var t=n.is.number(e)?e:parseFloat(this.storage.speed||this.speed.selected||this.config.speed.default);if(t<.1&&(t=.1),t>2&&(t=2),this.config.speed.options.includes(t))switch(this.type){case"youtube":this.embed.setPlaybackRate(t);break;case"vimeo":t=null,this.warn("Vimeo playback rate change is not supported");break;default:this.media.playbackRate=t}else this.warn("Unsupported speed ("+t+")")},get:function(){switch(this.type){case"youtube":return this.embed.getPlaybackRate();case"vimeo":return this.warn("Vimeo playback rate change is not supported"),null;default:return this.media.playbackRate}}},{key:"quality",set:function(e){var t=n.is.string(e)?e:parseFloat(this.storage.quality||this.config.quality.selected);if(this.config.quality.options.includes(t))switch(this.type){case"youtube":this.utils.dispatchEvent.call(this,this.media,"qualityrequested",!1,{quality:t}),this.embed.setPlaybackQuality(t);break;default:this.warn("Quality options are only available for YouTube")}else this.warn("Unsupported quality option ("+t+")")},get:function(){switch(this.type){case"youtube":return this.embed.getPlaybackQuality();default:return this.warn("Quality options are only available for YouTube"),null}}},{key:"src",set:function(e){g.change.call(this,e)},get:function(){var e=void 0;switch(this.type){case"youtube":e=this.embed.getVideoUrl();break;case"vimeo":this.embed.getVideoUrl.then(function(t){e=t});break;default:e=this.media.currentSrc}return e}},{key:"poster",set:function(e){"video"===this.type?n.is.string(e)&&this.media.setAttribute("poster",e):this.warn("Poster can only be set on HTML5 video")},get:function(){return"video"!==this.type?null:this.media.getAttribute("poster")}},{key:"language",set:function(e){var t=this;if(n.is.empty(e))return this.toggleCaptions(!1),t;var i=e.toLowerCase();return this.captions.language===i?t:(this.toggleCaptions(!0),this.captions.language=i,n.dispatchEvent.call(this,this.media,"captionchange"),l.setCaption.call(this),l.setup.call(this),this)},get:function(){return this.captions.language}}]),e}()}); //# sourceMappingURL=plyr.js.map