UNPKG

@flowplayer/player

Version:
2 lines (1 loc) 2.95 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.airplay=t())}(this,(function(){"use strict";const e=(e,t)=>new(((e,t)=>{const n=e.get(t);if(!n)throw new Error(`no flowplayer component with the name ${t} exists`);const i=window.customElements.get(t);if(!i)throw new Error(`no default flowplayer component with the name ${t} exists`);const r=window.customElements.get(n);return"function"!=typeof r?i:r})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}class FlowplayerIcon extends FlowplayerComponent{constructor(e,t){super(e),this.classList.add("fp-icon",t.name),t.title&&this.setAttribute("title",t.title),t.title&&this.setAttribute("aria-label",t.title),t.translation_key&&this.setAttribute("aria-label",e.i18n(t.translation_key)),this.setAttribute("tabindex","0"),this.setAttribute("focusable","true")}}var t=Object.freeze({__proto__:null,START:"airplay:start",STOP:"airplay:stop"});const n={name:"fp-airplay"};var i;const r=((i=class Airplay{static unsupported(){return!("WebKitPlaybackTargetAvailabilityEvent"in window)}static update(e,t){const n=t.availability===i.AVAILABLE&&!!e.currentSrc&&0!==e.currentSrc.indexOf("blob");e.setState(i.AVAILABLE_CLASS,n)}static render(t){var n;const i=e(t,"flowplayer-airplay-icon");null===(n=function(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}(t,"flowplayer-header-right-zone"))||void 0===n||n.prepend(i)}constructor(e){((e,t,n)=>{window.customElements.get(t)||window.customElements.define(t,n),e.customElements.get(t)||e.customElements.set(t,t)})(e,"flowplayer-airplay-icon",class extends FlowplayerIcon{constructor(e){super(e,n),this.addEventListener("click",(function(){e.webkitShowPlaybackTargetPicker()}))}})}init({airplay:e,hls:t},n,r){i.unsupported()||!1===e||(r.setOpts({hls:Object.assign({},{native:!0},t)}),i.render(r),r.setAttribute("x-webkit-airplay","allow"),r.on(i.AVAILABILITY_CHANGE,(function(e){i.update(r,e)})),r.on(i.WIRELESS_CHANGE,(function(){return r.emit(r.webkitCurrentPlaybackTargetIsWireless?i.events.START:i.events.STOP),r.setState(i.ACTIVE_CLASS,r.webkitCurrentPlaybackTargetIsWireless)})))}}).pluginName="airplay",i.ACTIVE_CLASS="is-airplay",i.AVAILABLE_CLASS="is-airplay-available",i.AVAILABILITY_CHANGE="webkitplaybacktargetavailabilitychanged",i.WIRELESS_CHANGE="webkitcurrentplaybacktargetiswirelesschanged",i.AVAILABLE="available",i.events=t,i);return function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;if(null===document.currentScript)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;return"function"==typeof n?(n(t),t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t),t)}(window,r)}));