diff --git a/dist/plyr.js b/dist/plyr.js index 742142db..943fa90e 100644 --- a/dist/plyr.js +++ b/dist/plyr.js @@ -1,3 +1,3 @@ -!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}()}); +!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.volume=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)}}},p={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)?p.ready.call(this,t):(n.loadScript(this.config.urls.youtube.api),window.onYouTubeReadyCallbacks=window.onYouTubeReadyCallbacks||[],window.onYouTubeReadyCallbacks.push(function(){p.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,Object.defineProperty(t.media,"playbackRate",{get:function(){return i.getPlaybackRate()},set:function(e){i.setPlaybackRate(e)}}),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.lastBuffered1&&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);t<.1&&(t=.1),t>2&&(t=2),this.config.speed.options.includes(t)?this.media.playbackRate=t:this.warn("Unsupported speed ("+t+")")},get:function(){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 diff --git a/dist/plyr.js.map b/dist/plyr.js.map index 3892ea38..605810f2 100644 --- a/dist/plyr.js.map +++ b/dist/plyr.js.map @@ -1 +1 @@ -{"version":3,"file":"plyr.js","sources":["src/js/storage.js","src/js/defaults.js","src/js/types.js","src/js/utils.js","src/js/support.js","src/js/controls.js","src/js/captions.js","src/js/fullscreen.js","src/js/listeners.js","src/js/ui.js","src/js/plugins/youtube.js","src/js/plugins/vimeo.js","src/js/media.js","src/js/source.js","src/js/plyr.js"],"sourcesContent":["// ==========================================================================\n// Plyr storage\n// ==========================================================================\n\nimport support from './support';\nimport utils from './utils';\n\n// Save a value back to local storage\nfunction set(value) {\n // Bail if we don't have localStorage support or it's disabled\n if (!support.storage || !this.config.storage.enabled) {\n return;\n }\n\n // Update the working copy of the values\n utils.extend(this.storage, value);\n\n // Update storage\n window.localStorage.setItem(this.config.storage.key, JSON.stringify(this.storage));\n}\n\n// Setup localStorage\nfunction setup() {\n let value = null;\n let storage = {};\n\n // Bail if we don't have localStorage support or it's disabled\n if (!support.storage || !this.config.storage.enabled) {\n return storage;\n }\n\n // Clean up old volume\n // https://github.com/sampotts/plyr/issues/171\n window.localStorage.removeItem('plyr-volume');\n\n // load value from the current key\n value = window.localStorage.getItem(this.config.storage.key);\n\n if (!value) {\n // Key wasn't set (or had been cleared), move along\n } else if (/^\\d+(\\.\\d+)?$/.test(value)) {\n // If value is a number, it's probably volume from an older\n // version of this. See: https://github.com/sampotts/plyr/pull/313\n // Update the key to be JSON\n set({\n volume: parseFloat(value),\n });\n } else {\n // Assume it's JSON from this or a later version of plyr\n storage = JSON.parse(value);\n }\n\n return storage;\n}\n\nexport default { setup, set };\n","// Default config\nconst defaults = {\n // Disable\n enabled: true,\n\n // Custom media title\n title: '',\n\n // Logging to console\n debug: false,\n\n // Auto play (if supported)\n autoplay: false,\n\n // Default time to skip when rewind/fast forward\n seekTime: 10,\n\n // Default volume\n volume: 1,\n muted: false,\n\n // Display the media duration\n displayDuration: true,\n\n // Click video to play\n clickToPlay: true,\n\n // Auto hide the controls\n hideControls: true,\n\n // Revert to poster on finish (HTML5 - will cause reload)\n showPosterOnEnd: false,\n\n // Disable the standard context menu\n disableContextMenu: true,\n\n // Sprite (for icons)\n loadSprite: true,\n iconPrefix: 'plyr',\n iconUrl: 'https://cdn.plyr.io/2.0.10/plyr.svg',\n\n // Blank video (used to prevent errors on source change)\n blankVideo: 'https://cdn.plyr.io/static/blank.mp4',\n\n // Pass a custom duration\n duration: null,\n\n // Quality default\n quality: {\n default: 'default',\n options: ['hd2160', 'hd1440', 'hd1080', 'hd720', 'large', 'medium', 'small', 'tiny', 'default'],\n },\n\n // Set loops\n loop: {\n active: false,\n start: null,\n end: null,\n },\n\n // Speed default and options to display\n speed: {\n default: 1,\n options: [0.5, 0.75, 1, 1.25, 1.5, 1.75, 2],\n },\n\n // Keyboard shortcut settings\n keyboard: {\n focused: true,\n global: false,\n },\n\n // Display tooltips\n tooltips: {\n controls: false,\n seek: true,\n },\n\n // Captions settings\n captions: {\n active: false,\n language: window.navigator.language.split('-')[0],\n },\n\n // Fullscreen settings\n fullscreen: {\n enabled: true, // Allow fullscreen?\n fallback: true, // Fallback for vintage browsers\n },\n\n // Local storage\n storage: {\n enabled: true,\n key: 'plyr',\n },\n\n // Default controls\n controls: [\n 'play-large',\n 'play',\n 'progress',\n 'current-time',\n 'mute',\n 'volume',\n 'captions',\n 'settings',\n 'pip',\n 'airplay',\n 'fullscreen',\n ],\n settings: ['captions', 'quality', 'speed', 'loop'],\n\n // Localisation\n i18n: {\n restart: 'Restart',\n rewind: 'Rewind {seektime} secs',\n play: 'Play',\n pause: 'Pause',\n forward: 'Forward {seektime} secs',\n seek: 'Seek',\n played: 'Played',\n buffered: 'Buffered',\n currentTime: 'Current time',\n duration: 'Duration',\n volume: 'Volume',\n toggleMute: 'Toggle Mute',\n toggleCaptions: 'Toggle Captions',\n toggleFullscreen: 'Toggle Fullscreen',\n frameTitle: 'Player for {title}',\n captions: 'Captions',\n settings: 'Settings',\n speed: 'Speed',\n quality: 'Quality',\n loop: 'Loop',\n start: 'Start',\n end: 'End',\n all: 'All',\n reset: 'Reset',\n none: 'None',\n disabled: 'Disabled',\n },\n\n // URLs\n urls: {\n vimeo: {\n api: 'https://player.vimeo.com/api/player.js',\n },\n youtube: {\n api: 'https://www.youtube.com/iframe_api',\n },\n },\n\n // Custom control listeners\n listeners: {\n seek: null,\n play: null,\n pause: null,\n restart: null,\n rewind: null,\n forward: null,\n mute: null,\n volume: null,\n captions: null,\n fullscreen: null,\n pip: null,\n airplay: null,\n speed: null,\n quality: null,\n loop: null,\n language: null,\n },\n\n // Events to watch and bubble\n events: [\n // Events to watch on HTML5 media elements and bubble\n // https://developer.mozilla.org/en/docs/Web/Guide/Events/Media_events\n 'ended',\n 'progress',\n 'stalled',\n 'playing',\n 'waiting',\n 'canplay',\n 'canplaythrough',\n 'loadstart',\n 'loadeddata',\n 'loadedmetadata',\n 'timeupdate',\n 'volumechange',\n 'play',\n 'pause',\n 'error',\n 'seeking',\n 'seeked',\n 'emptied',\n 'ratechange',\n 'cuechange',\n\n // Custom events\n 'enterfullscreen',\n 'exitfullscreen',\n 'captionsenabled',\n 'captionsdisabled',\n 'captionchange',\n 'controlshidden',\n 'controlsshown',\n 'ready',\n\n // YouTube\n 'statechange',\n 'qualitychange',\n 'qualityrequested',\n ],\n\n // Selectors\n // Change these to match your template if using custom HTML\n selectors: {\n editable: 'input, textarea, select, [contenteditable]',\n container: '.plyr',\n controls: {\n container: null,\n wrapper: '.plyr__controls',\n },\n labels: '[data-plyr]',\n buttons: {\n play: '[data-plyr=\"play\"]',\n pause: '[data-plyr=\"pause\"]',\n restart: '[data-plyr=\"restart\"]',\n rewind: '[data-plyr=\"rewind\"]',\n forward: '[data-plyr=\"fast-forward\"]',\n mute: '[data-plyr=\"mute\"]',\n captions: '[data-plyr=\"captions\"]',\n fullscreen: '[data-plyr=\"fullscreen\"]',\n pip: '[data-plyr=\"pip\"]',\n airplay: '[data-plyr=\"airplay\"]',\n settings: '[data-plyr=\"settings\"]',\n loop: '[data-plyr=\"loop\"]',\n },\n inputs: {\n seek: '[data-plyr=\"seek\"]',\n volume: '[data-plyr=\"volume\"]',\n speed: '[data-plyr=\"speed\"]',\n language: '[data-plyr=\"language\"]',\n quality: '[data-plyr=\"quality\"]',\n },\n display: {\n currentTime: '.plyr__time--current',\n duration: '.plyr__time--duration',\n buffer: '.plyr__progress--buffer',\n played: '.plyr__progress--played',\n loop: '.plyr__progress--loop',\n volume: '.plyr__volume--display',\n },\n progress: '.plyr__progress',\n captions: '.plyr__captions',\n menu: {\n quality: '.js-plyr__menu__list--quality',\n },\n },\n\n // Class hooks added to the player in different states\n classNames: {\n video: 'plyr__video-wrapper',\n embed: 'plyr__video-embed',\n control: 'plyr__control',\n type: 'plyr--{0}',\n stopped: 'plyr--stopped',\n playing: 'plyr--playing',\n muted: 'plyr--muted',\n loading: 'plyr--loading',\n hover: 'plyr--hover',\n tooltip: 'plyr__tooltip',\n hidden: 'plyr__sr-only',\n hideControls: 'plyr--hide-controls',\n isIos: 'plyr--is-ios',\n isTouch: 'plyr--is-touch',\n uiSupported: 'plyr--full-ui',\n menu: {\n value: 'plyr__menu__value',\n badge: 'plyr__badge',\n },\n captions: {\n enabled: 'plyr--captions-enabled',\n active: 'plyr--captions-active',\n },\n fullscreen: {\n enabled: 'plyr--fullscreen-enabled',\n fallback: 'plyr--fullscreen-fallback',\n },\n pip: {\n supported: 'plyr--pip-supported',\n active: 'plyr--pip-active',\n },\n airplay: {\n supported: 'plyr--airplay-supported',\n active: 'plyr--airplay-active',\n },\n tabFocus: 'tab-focus',\n },\n};\n\nexport default defaults;\n","// ==========================================================================\n// Plyr supported types\n// ==========================================================================\n\nconst types = {\n embed: ['youtube', 'vimeo'],\n html5: ['video', 'audio'],\n};\n\nexport default types;\n","// ==========================================================================\n// Plyr utils\n// ==========================================================================\n\nimport support from './support';\n\nconst utils = {\n // Check variable types\n is: {\n object(input) {\n return this.getConstructor(input) === Object;\n },\n number(input) {\n return this.getConstructor(input) === Number && !Number.isNaN(input);\n },\n string(input) {\n return this.getConstructor(input) === String;\n },\n boolean(input) {\n return this.getConstructor(input) === Boolean;\n },\n function(input) {\n return this.getConstructor(input) === Function;\n },\n array(input) {\n return !this.undefined(input) && Array.isArray(input);\n },\n nodeList(input) {\n return !this.undefined(input) && input instanceof NodeList;\n },\n htmlElement(input) {\n return !this.undefined(input) && input instanceof HTMLElement;\n },\n event(input) {\n return !this.undefined(input) && input instanceof Event;\n },\n cue(input) {\n return this.instanceOf(input, window.TextTrackCue) || this.instanceOf(input, window.VTTCue);\n },\n track(input) {\n return (\n !this.undefined(input) && (this.instanceOf(input, window.TextTrack) || typeof input.kind === 'string')\n );\n },\n undefined(input) {\n return input !== null && typeof input === 'undefined';\n },\n empty(input) {\n return (\n input === null ||\n typeof input === 'undefined' ||\n ((this.string(input) || this.array(input) || this.nodeList(input)) && input.length === 0) ||\n (this.object(input) && Object.keys(input).length === 0)\n );\n },\n getConstructor(input) {\n if (input === null || typeof input === 'undefined') {\n return null;\n }\n\n return input.constructor;\n },\n instanceOf(input, constructor) {\n return Boolean(input && constructor && input instanceof constructor);\n },\n },\n\n // Unfortunately, due to mixed support, UA sniffing is required\n getBrowser() {\n return {\n isIE: /* @cc_on!@ */ false || !!document.documentMode,\n isWebkit: 'WebkitAppearance' in document.documentElement.style && !/Edge/.test(navigator.userAgent),\n isIPhone: /(iPhone|iPod)/gi.test(navigator.platform),\n isIos: /(iPad|iPhone|iPod)/gi.test(navigator.platform),\n };\n },\n\n // Load an external script\n loadScript(url) {\n // Check script is not already referenced\n if (document.querySelectorAll(`script[src=\"${url}\"]`).length) {\n return;\n }\n\n const tag = document.createElement('script');\n tag.src = url;\n\n const firstScriptTag = document.getElementsByTagName('script')[0];\n firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);\n },\n\n // Generate a random ID\n generateId(prefix) {\n return `${prefix}-${Math.floor(Math.random() * 10000)}`;\n },\n\n // Determine if we're in an iframe\n inFrame() {\n try {\n return window.self !== window.top;\n } catch (e) {\n return true;\n }\n },\n\n // Wrap an element\n wrap(elements, wrapper) {\n // Convert `elements` to an array, if necessary.\n const targets = elements.length ? elements : [elements];\n\n // Loops backwards to prevent having to clone the wrapper on the\n // first element (see `child` below).\n Array.from(targets)\n .reverse()\n .forEach((element, index) => {\n const child = index > 0 ? wrapper.cloneNode(true) : wrapper;\n\n // Cache the current parent and sibling.\n const parent = element.parentNode;\n const sibling = element.nextSibling;\n\n // Wrap the element (is automatically removed from its current\n // parent).\n child.appendChild(element);\n\n // If the element had a sibling, insert the wrapper before\n // the sibling to maintain the HTML structure; otherwise, just\n // append it to the parent.\n if (sibling) {\n parent.insertBefore(child, sibling);\n } else {\n parent.appendChild(child);\n }\n });\n },\n\n // Remove an element\n removeElement(element) {\n if (!utils.is.htmlElement(element) || !utils.is.htmlElement(element.parentNode)) {\n return null;\n }\n\n element.parentNode.removeChild(element);\n\n return element;\n },\n\n // Inaert an element after another\n insertAfter(element, target) {\n target.parentNode.insertBefore(element, target.nextSibling);\n },\n\n // Create a DocumentFragment\n createElement(type, attributes, text) {\n // Create a new \n const element = document.createElement(type);\n\n // Set all passed attributes\n if (utils.is.object(attributes)) {\n utils.setAttributes(element, attributes);\n }\n\n // Add text node\n if (utils.is.string(text)) {\n element.textContent = text;\n }\n\n // Return built element\n return element;\n },\n\n // Insert a DocumentFragment\n insertElement(type, parent, attributes, text) {\n // Inject the new \n parent.appendChild(utils.createElement(type, attributes, text));\n },\n\n // Remove all child elements\n emptyElement(element) {\n let { length } = element.childNodes;\n\n while (length > 0) {\n element.removeChild(element.lastChild);\n length -= 1;\n }\n },\n\n // Set attributes\n setAttributes(element, attributes) {\n Object.keys(attributes).forEach(key => {\n element.setAttribute(key, attributes[key]);\n });\n },\n\n // Get an attribute object from a string selector\n getAttributesFromSelector(sel, existingAttributes) {\n // For example:\n // '.test' to { class: 'test' }\n // '#test' to { id: 'test' }\n // '[data-test=\"test\"]' to { 'data-test': 'test' }\n\n if (!utils.is.string(sel) || utils.is.empty(sel)) {\n return {};\n }\n\n const attributes = {};\n const existing = existingAttributes;\n\n sel.split(',').forEach(s => {\n // Remove whitespace\n const selector = s.trim();\n const className = selector.replace('.', '');\n const stripped = selector.replace(/[[\\]]/g, '');\n\n // Get the parts and value\n const parts = stripped.split('=');\n const key = parts[0];\n const value = parts.length > 1 ? parts[1].replace(/[\"']/g, '') : '';\n\n // Get the first character\n const start = selector.charAt(0);\n\n switch (start) {\n case '.':\n // Add to existing classname\n if (utils.is.object(existing) && utils.is.string(existing.class)) {\n existing.class += ` ${className}`;\n }\n\n attributes.class = className;\n break;\n\n case '#':\n // ID selector\n attributes.id = selector.replace('#', '');\n break;\n\n case '[':\n // Attribute selector\n attributes[key] = value;\n\n break;\n\n default:\n break;\n }\n });\n\n return attributes;\n },\n\n // Toggle class on an element\n toggleClass(element, className, toggle) {\n if (utils.is.htmlElement(element)) {\n const contains = element.classList.contains(className);\n\n element.classList[toggle ? 'add' : 'remove'](className);\n\n return (toggle && !contains) || (!toggle && contains);\n }\n\n return null;\n },\n\n // Has class name\n hasClass(element, className) {\n return utils.is.htmlElement(element) && element.classList.contains(className);\n },\n\n // Element matches selector\n matches(element, selector) {\n const prototype = { Element };\n\n function match() {\n return Array.from(document.querySelectorAll(selector)).includes(this);\n }\n\n const matches =\n prototype.matches ||\n prototype.webkitMatchesSelector ||\n prototype.mozMatchesSelector ||\n prototype.msMatchesSelector ||\n match;\n\n return matches.call(element, selector);\n },\n\n // Find all elements\n getElements(selector) {\n return this.elements.container.querySelectorAll(selector);\n },\n\n // Find a single element\n getElement(selector) {\n return this.elements.container.querySelector(selector);\n },\n\n // Find the UI controls and store references in custom controls\n // TODO: Allow settings menus with custom controls\n findElements() {\n try {\n this.elements.controls = utils.getElement.call(this, this.config.selectors.controls.wrapper);\n\n // Buttons\n this.elements.buttons = {\n play: utils.getElements.call(this, this.config.selectors.buttons.play),\n pause: utils.getElement.call(this, this.config.selectors.buttons.pause),\n restart: utils.getElement.call(this, this.config.selectors.buttons.restart),\n rewind: utils.getElement.call(this, this.config.selectors.buttons.rewind),\n forward: utils.getElement.call(this, this.config.selectors.buttons.forward),\n mute: utils.getElement.call(this, this.config.selectors.buttons.mute),\n pip: utils.getElement.call(this, this.config.selectors.buttons.pip),\n airplay: utils.getElement.call(this, this.config.selectors.buttons.airplay),\n settings: utils.getElement.call(this, this.config.selectors.buttons.settings),\n captions: utils.getElement.call(this, this.config.selectors.buttons.captions),\n fullscreen: utils.getElement.call(this, this.config.selectors.buttons.fullscreen),\n };\n\n // Progress\n this.elements.progress = utils.getElement.call(this, this.config.selectors.progress);\n\n // Inputs\n this.elements.inputs = {\n seek: utils.getElement.call(this, this.config.selectors.inputs.seek),\n volume: utils.getElement.call(this, this.config.selectors.inputs.volume),\n };\n\n // Display\n this.elements.display = {\n buffer: utils.getElement.call(this, this.config.selectors.display.buffer),\n duration: utils.getElement.call(this, this.config.selectors.display.duration),\n currentTime: utils.getElement.call(this, this.config.selectors.display.currentTime),\n };\n\n // Seek tooltip\n if (utils.is.htmlElement(this.elements.progress)) {\n this.elements.display.seekTooltip = this.elements.progress.querySelector(\n `.${this.config.classNames.tooltip}`\n );\n }\n\n return true;\n } catch (error) {\n // Log it\n this.warn('It looks like there is a problem with your custom controls HTML', error);\n\n // Restore native video controls\n this.toggleNativeControls(true);\n\n return false;\n }\n },\n\n // Get the focused element\n getFocusElement() {\n let focused = document.activeElement;\n\n if (!focused || focused === document.body) {\n focused = null;\n } else {\n focused = document.querySelector(':focus');\n }\n\n return focused;\n },\n\n // Trap focus inside container\n trapFocus() {\n const tabbables = utils.getElements.call(this, 'input:not([disabled]), button:not([disabled])');\n const first = tabbables[0];\n const last = tabbables[tabbables.length - 1];\n\n utils.on(\n this.elements.container,\n 'keydown',\n event => {\n // If it is tab\n if (event.which === 9 && this.fullscreen.active) {\n if (event.target === last && !event.shiftKey) {\n // Move focus to first element that can be tabbed if Shift isn't used\n event.preventDefault();\n first.focus();\n } else if (event.target === first && event.shiftKey) {\n // Move focus to last element that can be tabbed if Shift is used\n event.preventDefault();\n last.focus();\n }\n }\n },\n false\n );\n },\n\n // Bind along with custom handler\n proxy(element, eventName, customListener, defaultListener, passive, capture) {\n utils.on(\n element,\n eventName,\n event => {\n if (customListener) {\n customListener.apply(element, [event]);\n }\n defaultListener.apply(element, [event]);\n },\n passive,\n capture\n );\n },\n\n // Toggle event listener\n toggleListener(elements, event, callback, toggle, passive, capture) {\n // Bail if no elements\n if (elements === null || utils.is.undefined(elements)) {\n return;\n }\n\n // If a nodelist is passed, call itself on each node\n if (elements instanceof NodeList) {\n // Create listener for each node\n Array.from(elements).forEach(element => {\n if (element instanceof Node) {\n utils.toggleListener.call(null, element, event, callback, toggle, passive, capture);\n }\n });\n\n return;\n }\n\n // Allow multiple events\n const events = event.split(' ');\n\n // Build options\n // Default to just capture boolean\n let options = utils.is.boolean(capture) ? capture : false;\n\n // If passive events listeners are supported\n if (support.passiveListeners) {\n options = {\n // Whether the listener can be passive (i.e. default never prevented)\n passive: utils.is.boolean(passive) ? passive : true,\n // Whether the listener is a capturing listener or not\n capture: utils.is.boolean(capture) ? capture : false,\n };\n }\n\n // If a single node is passed, bind the event listener\n events.forEach(type => {\n elements[toggle ? 'addEventListener' : 'removeEventListener'](type, callback, options);\n });\n },\n\n // Bind event handler\n on(element, events, callback, passive, capture) {\n utils.toggleListener(element, events, callback, true, passive, capture);\n },\n\n // Unbind event handler\n off(element, events, callback, passive, capture) {\n utils.toggleListener(element, events, callback, false, passive, capture);\n },\n\n // Trigger event\n dispatchEvent(element, type, bubbles, properties) {\n // Bail if no element\n if (!element || !type) {\n return;\n }\n\n // Create and dispatch the event\n const event = new CustomEvent(type, {\n bubbles: utils.is.boolean(bubbles) ? bubbles : false,\n detail: Object.assign({}, properties, {\n plyr: this instanceof Plyr ? this : null,\n }),\n });\n\n // Dispatch the event\n element.dispatchEvent(event);\n },\n\n // Toggle aria-pressed state on a toggle button\n // http://www.ssbbartgroup.com/blog/how-not-to-misuse-aria-states-properties-and-roles\n toggleState(target, state) {\n // Bail if no target\n if (!target) {\n return null;\n }\n\n // Get state\n const newState = utils.is.boolean(state) ? state : !target.getAttribute('aria-pressed');\n\n // Set the attribute on target\n target.setAttribute('aria-pressed', newState);\n\n return newState;\n },\n\n // Get percentage\n getPercentage(current, max) {\n if (current === 0 || max === 0 || Number.isNaN(current) || Number.isNaN(max)) {\n return 0;\n }\n return (current / max * 100).toFixed(2);\n },\n\n // Deep extend/merge destination object with N more objects\n // http://andrewdupont.net/2009/08/28/deep-extending-objects-in-javascript/\n // Removed call to arguments.callee (used explicit function name instead)\n extend(...objects) {\n const { length } = objects;\n\n // Bail if nothing to merge\n if (!length) {\n return null;\n }\n\n // Return first if specified but nothing to merge\n if (length === 1) {\n return objects[0];\n }\n\n // First object is the destination\n let destination = Array.prototype.shift.call(objects);\n if (!utils.is.object(destination)) {\n destination = {};\n }\n\n // Loop through all objects to merge\n objects.forEach(source => {\n if (!utils.is.object(source)) {\n return;\n }\n\n Object.keys(source).forEach(property => {\n if (source[property] && source[property].constructor && source[property].constructor === Object) {\n destination[property] = destination[property] || {};\n utils.extend(destination[property], source[property]);\n } else {\n destination[property] = source[property];\n }\n });\n });\n\n return destination;\n },\n\n // Parse YouTube ID from URL\n parseYouTubeId(url) {\n const regex = /^.*(youtu.be\\/|v\\/|u\\/\\w\\/|embed\\/|watch\\?v=|&v=)([^#&?]*).*/;\n return url.match(regex) ? RegExp.$2 : url;\n },\n\n // Parse Vimeo ID from URL\n parseVimeoId(url) {\n if (utils.is.number(Number(url))) {\n return url;\n }\n\n const regex = /^.*(vimeo.com\\/|video\\/)(\\d+).*/;\n return url.match(regex) ? RegExp.$2 : url;\n },\n\n // Convert object to URL parameters\n buildUrlParameters(input) {\n if (!utils.is.object(input)) {\n return '';\n }\n\n return Object.keys(input)\n .map(key => `${encodeURIComponent(key)}=${encodeURIComponent(input[key])}`)\n .join('&');\n },\n\n // Remove HTML from a string\n stripHTML(source) {\n const fragment = document.createDocumentFragment();\n const element = document.createElement('div');\n fragment.appendChild(element);\n element.innerHTML = source;\n return fragment.firstChild.innerText;\n },\n\n // Load an SVG sprite\n loadSprite(url, id) {\n if (typeof url !== 'string') {\n return;\n }\n\n const prefix = 'cache-';\n const hasId = typeof id === 'string';\n let isCached = false;\n\n function updateSprite(data) {\n // Inject content\n this.innerHTML = data;\n\n // Inject the SVG to the body\n document.body.insertBefore(this, document.body.childNodes[0]);\n }\n\n // Only load once\n if (!hasId || !document.querySelectorAll(`#${id}`).length) {\n // Create container\n const container = document.createElement('div');\n container.setAttribute('hidden', '');\n\n if (hasId) {\n container.setAttribute('id', id);\n }\n\n // Check in cache\n if (support.storage) {\n const cached = window.localStorage.getItem(prefix + id);\n isCached = cached !== null;\n\n if (isCached) {\n const data = JSON.parse(cached);\n updateSprite.call(container, data.content);\n }\n }\n\n // ReSharper disable once InconsistentNaming\n const xhr = new XMLHttpRequest();\n\n // XHR for Chrome/Firefox/Opera/Safari\n if ('withCredentials' in xhr) {\n xhr.open('GET', url, true);\n } else {\n return;\n }\n\n // Once loaded, inject to container and body\n xhr.onload = () => {\n if (support.storage) {\n window.localStorage.setItem(\n prefix + id,\n JSON.stringify({\n content: xhr.responseText,\n })\n );\n }\n\n updateSprite.call(container, xhr.responseText);\n };\n\n xhr.send();\n }\n },\n\n // Get the transition end event\n transitionEnd: (() => {\n const element = document.createElement('span');\n\n const events = {\n WebkitTransition: 'webkitTransitionEnd',\n MozTransition: 'transitionend',\n OTransition: 'oTransitionEnd otransitionend',\n transition: 'transitionend',\n };\n\n const type = Object.keys(events).find(event => element.style[event] !== undefined);\n\n return typeof type === 'string' ? type : false;\n })(),\n};\n\nexport default utils;\n","// ==========================================================================\n// Plyr support checks\n// ==========================================================================\n\nimport utils from './utils';\n\n// Check for feature support\nconst support = {\n // Basic support\n audio: 'canPlayType' in document.createElement('audio'),\n video: 'canPlayType' in document.createElement('video'),\n\n // Check for support\n // Basic functionality vs full UI\n check(type, inline) {\n let api = false;\n let ui = false;\n const browser = utils.getBrowser();\n const playsInline = browser.isIPhone && inline && support.inline;\n\n switch (type) {\n case 'video':\n api = support.video;\n ui = api && support.rangeInput && (!browser.isIPhone || playsInline);\n break;\n\n case 'audio':\n api = support.audio;\n ui = api && support.rangeInput;\n break;\n\n case 'youtube':\n api = true;\n ui = support.rangeInput && (!browser.isIPhone || playsInline);\n break;\n\n case 'vimeo':\n api = true;\n ui = support.rangeInput && !browser.isIPhone;\n break;\n\n default:\n api = support.audio && support.video;\n ui = api && support.rangeInput;\n }\n\n return {\n api,\n ui,\n };\n },\n\n // Local storage\n // We can't assume if local storage is present that we can use it\n storage: (() => {\n if (!('localStorage' in window)) {\n return false;\n }\n\n // Try to use it (it might be disabled, e.g. user is in private/porn mode)\n // see: https://github.com/sampotts/plyr/issues/131\n const test = '___test';\n try {\n window.localStorage.setItem(test, test);\n window.localStorage.removeItem(test);\n return true;\n } catch (e) {\n return false;\n }\n })(),\n\n // Picture-in-picture support\n // Safari only currently\n pip: (() => {\n const browser = utils.getBrowser();\n return !browser.isIPhone && utils.is.function(utils.createElement('video').webkitSetPresentationMode);\n })(),\n\n // Airplay support\n // Safari only currently\n airplay: utils.is.function(window.WebKitPlaybackTargetAvailabilityEvent),\n\n // Inline playback support\n // https://webkit.org/blog/6784/new-video-policies-for-ios/\n inline: 'playsInline' in document.createElement('video'),\n\n // Check for mime type support against a player instance\n // Credits: http://diveintohtml5.info/everything.html\n // Related: http://www.leanbackplayer.com/test/h5mt.html\n mime(player, type) {\n const media = { player };\n\n try {\n // Bail if no checking function\n if (!utils.is.function(media.canPlayType)) {\n return false;\n }\n\n // Type specific checks\n if (player.type === 'video') {\n switch (type) {\n case 'video/webm':\n return media.canPlayType('video/webm; codecs=\"vp8, vorbis\"').replace(/no/, '');\n case 'video/mp4':\n return media.canPlayType('video/mp4; codecs=\"avc1.42E01E, mp4a.40.2\"').replace(/no/, '');\n case 'video/ogg':\n return media.canPlayType('video/ogg; codecs=\"theora\"').replace(/no/, '');\n default:\n return false;\n }\n } else if (player.type === 'audio') {\n switch (type) {\n case 'audio/mpeg':\n return media.canPlayType('audio/mpeg;').replace(/no/, '');\n case 'audio/ogg':\n return media.canPlayType('audio/ogg; codecs=\"vorbis\"').replace(/no/, '');\n case 'audio/wav':\n return media.canPlayType('audio/wav; codecs=\"1\"').replace(/no/, '');\n default:\n return false;\n }\n }\n } catch (e) {\n return false;\n }\n\n // If we got this far, we're stuffed\n return false;\n },\n\n // Check for textTracks support\n textTracks: 'textTracks' in document.createElement('video'),\n\n // Check for passive event listener support\n // https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md\n // https://www.youtube.com/watch?v=NPM6172J22g\n passiveListeners: (() => {\n // Test via a getter in the options object to see if the passive property is accessed\n let supported = false;\n try {\n const options = Object.defineProperty({}, 'passive', {\n get() {\n supported = true;\n return null;\n },\n });\n window.addEventListener('test', null, options);\n } catch (e) {\n // Do nothing\n }\n\n return supported;\n })(),\n\n // Sliders\n rangeInput: (() => {\n const range = document.createElement('input');\n range.type = 'range';\n return range.type === 'range';\n })(),\n\n // Touch\n // Remember a device can be moust + touch enabled\n touch: 'ontouchstart' in document.documentElement,\n\n // Detect transitions support\n transitions: utils.transitionEnd !== false,\n\n // Reduced motion iOS & MacOS setting\n // https://webkit.org/blog/7551/responsive-design-for-motion/\n reducedMotion: 'matchMedia' in window && window.matchMedia('(prefers-reduced-motion)').matches,\n};\n\nexport default support;\n","// ==========================================================================\n// Plyr controls\n// ==========================================================================\n\nimport support from './support';\nimport utils from './utils';\n\nconst controls = {\n // Webkit polyfill for lower fill range\n updateRangeFill(target) {\n // WebKit only\n if (!this.browser.isWebkit) {\n return;\n }\n\n // Get range from event if event passed\n const range = utils.is.event(target) ? target.target : target;\n\n // Needs to be a valid \n if (!utils.is.htmlElement(range) || range.getAttribute('type') !== 'range') {\n return;\n }\n\n // Inject the stylesheet if needed\n if (!utils.is.htmlElement(this.elements.styleSheet)) {\n this.elements.styleSheet = utils.createElement('style');\n this.elements.container.appendChild(this.elements.styleSheet);\n }\n\n const styleSheet = this.elements.styleSheet.sheet;\n const percentage = range.value / range.max * 100;\n const selector = `#${range.id}::-webkit-slider-runnable-track`;\n const styles = `{ background-image: linear-gradient(to right, currentColor ${percentage}%, transparent ${percentage}%) }`;\n\n // Find old rule if it exists\n const index = Array.from(styleSheet.rules).findIndex(rule => rule.selectorText === selector);\n\n // Remove old rule\n if (index !== -1) {\n styleSheet.deleteRule(index);\n }\n\n // Insert new one\n styleSheet.insertRule([selector, styles].join(' '));\n },\n\n // Get icon URL\n getIconUrl() {\n return {\n url: this.config.iconUrl,\n absolute: this.config.iconUrl.indexOf('http') === 0 || this.browser.isIE,\n };\n },\n\n // Create icon\n createIcon(type, attributes) {\n const namespace = 'http://www.w3.org/2000/svg';\n const iconUrl = controls.getIconUrl.call(this);\n const iconPath = `${!iconUrl.absolute ? iconUrl.url : ''}#${this.config.iconPrefix}`;\n\n // Create \n const icon = document.createElementNS(namespace, 'svg');\n utils.setAttributes(\n icon,\n utils.extend(attributes, {\n role: 'presentation',\n })\n );\n\n // Create the to reference sprite\n const use = document.createElementNS(namespace, 'use');\n use.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', `${iconPath}-${type}`);\n\n // Add to \n icon.appendChild(use);\n\n return icon;\n },\n\n // Create hidden text label\n createLabel(type) {\n let text = this.config.i18n[type];\n\n switch (type) {\n case 'pip':\n text = 'PIP';\n break;\n\n case 'airplay':\n text = 'AirPlay';\n break;\n\n default:\n break;\n }\n\n return utils.createElement(\n 'span',\n {\n class: this.config.classNames.hidden,\n },\n text\n );\n },\n\n // Create a badge\n createBadge(text) {\n const badge = utils.createElement('span', {\n class: this.config.classNames.menu.value,\n });\n\n badge.appendChild(\n utils.createElement(\n 'span',\n {\n class: this.config.classNames.menu.badge,\n },\n text\n )\n );\n\n return badge;\n },\n\n // Create a