@flowplayer/player 3.14.1 → 3.15.0-rc.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/core/events.d.ts +575 -68
  2. package/core/events.js +286 -34
  3. package/core.js +1 -1
  4. package/default.js +1 -1
  5. package/embed.js +2 -2
  6. package/flowplayer.css +1 -1
  7. package/index.d.ts +1480 -91
  8. package/package.json +1 -1
  9. package/plugins/ads.d.ts +3744 -112
  10. package/plugins/ads.js +1 -1
  11. package/plugins/airplay.d.ts +1440 -116
  12. package/plugins/airplay.js +1 -1
  13. package/plugins/analytics.d.ts +1409 -82
  14. package/plugins/analytics.js +1 -1
  15. package/plugins/asel.d.ts +1409 -82
  16. package/plugins/asel.js +1 -1
  17. package/plugins/audio.d.ts +1409 -82
  18. package/plugins/audio.js +1 -1
  19. package/plugins/chapters.d.ts +1409 -82
  20. package/plugins/chapters.js +1 -1
  21. package/plugins/chromecast.d.ts +1464 -80
  22. package/plugins/chromecast.js +1 -1
  23. package/plugins/comscore.d.ts +1409 -82
  24. package/plugins/consent.d.ts +1409 -82
  25. package/plugins/consent.js +1 -1
  26. package/plugins/context-menu.d.ts +1443 -116
  27. package/plugins/cuepoints.d.ts +1443 -116
  28. package/plugins/cuepoints.js +1 -1
  29. package/plugins/dash.d.ts +1445 -115
  30. package/plugins/dash.js +1 -1
  31. package/plugins/drm.d.ts +1409 -82
  32. package/plugins/drm.js +1 -1
  33. package/plugins/endscreen.d.ts +1442 -115
  34. package/plugins/endscreen.js +1 -1
  35. package/plugins/fas.d.ts +1409 -82
  36. package/plugins/float-on-scroll.d.ts +1443 -116
  37. package/plugins/float-on-scroll.js +1 -1
  38. package/plugins/ga4.d.ts +1409 -82
  39. package/plugins/gemius.d.ts +1439 -112
  40. package/plugins/google-analytics.d.ts +1409 -82
  41. package/plugins/health.d.ts +1435 -107
  42. package/plugins/health.js +1 -1
  43. package/plugins/hls.d.ts +1431 -104
  44. package/plugins/hls.js +1 -1
  45. package/plugins/id3.d.ts +1409 -82
  46. package/plugins/id3.js +1 -1
  47. package/plugins/iframe.d.ts +1440 -116
  48. package/plugins/iframe.js +1 -1
  49. package/plugins/keyboard.d.ts +1409 -82
  50. package/plugins/media-session.d.ts +1409 -82
  51. package/plugins/message.d.ts +1409 -82
  52. package/plugins/message.js +1 -1
  53. package/plugins/ovp.d.ts +1435 -110
  54. package/plugins/ovp.js +1 -1
  55. package/plugins/playlist.d.ts +1409 -82
  56. package/plugins/playlist.js +1 -1
  57. package/plugins/preview.d.ts +1409 -82
  58. package/plugins/preview.js +1 -1
  59. package/plugins/qsel.d.ts +1409 -82
  60. package/plugins/qsel.js +1 -1
  61. package/plugins/qul.d.ts +1441 -114
  62. package/plugins/qul.js +1 -1
  63. package/plugins/rts.d.ts +1409 -82
  64. package/plugins/rts.js +1 -1
  65. package/plugins/share.d.ts +1409 -82
  66. package/plugins/share.js +1 -1
  67. package/plugins/speed.d.ts +1434 -107
  68. package/plugins/speed.js +1 -1
  69. package/plugins/ssai.d.ts +1412 -82
  70. package/plugins/ssai.js +1 -1
  71. package/plugins/subtitles.d.ts +1426 -102
  72. package/plugins/thumbnails.d.ts +1434 -107
  73. package/plugins/thumbnails.js +1 -1
  74. package/plugins/tizen.d.ts +1409 -82
  75. package/plugins/tizen.js +1 -1
  76. package/plugins/vtsel.d.ts +1409 -82
  77. package/plugins/vtsel.js +1 -1
  78. package/plugins/webos.d.ts +1409 -82
  79. package/plugins/webos.js +1 -1
  80. package/util/loader.d.ts +1436 -101
  81. package/util/loader.js +13 -2
@@ -1 +1 @@
1
- !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.chromecast=t())}(this,(function(){"use strict";function e(e){const t=document.createElement("a");t.href=e;const n=t.pathname&&t.pathname.split(".");return n.length>1&&n[n.length-1]}function t(e){switch(e){case"video/mpd":return"application/dash+xml";case"video/m3u8":return"application/x-mpegurl";default:return e}}const n=n=>{var{src:r}=n,o=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(n,["src"]);return[Object.assign({src:r,type:r?t("video/"+e(r)):""},o)]};function r(e){return n({src:e})}class Pipe{constructor(e){this.data=e}static of(e){return new Pipe(e)}static maybe(e,t,...n){return null==e?e:t.apply(e,[e,...n])}tap(e,...t){return e.apply(this,[this.data,...t]),new Pipe(this.data)}fmap(e,...t){const n=e.apply(this,[this.data,...t]);return new Pipe(n)}unwrap(){return this.data}}const o="chromecast:idle";var a=Object.freeze({__proto__:null,CAST_AVAILABLE:"chromecast:available",CAST_UNAVAILABLE:"chromecast:unavailable",CAST_START_CASTING:"chromecast:start",CAST_IDLE:o,CAST_STATE_CHANGED:"chromecast:state:changed",CAST_SESSION_CHANGED:"chromecast:session:changed",CAST_FIELD_UPDATE:"chromecast:field:update",CAST_MEDIA_LOAD_REQUEST:"chromecast:media"});const s=/(video\/mp4)|(application\/x-mpegurl)|(video\/mpd)|(application\/dash\+xml)/;function i(){var e;return(null===(e=f())||void 0===e?void 0:e.getCurrentSession())||null}function c(e){return p(e).unwrap().shift()}function l(){var e;return(null===(e=i())||void 0===e?void 0:e.getMediaSession())||null}function u(e){var t,n;const r=p(e).unwrap().map((function(e){return null==e?void 0:e.src})),o=null===(n=null===(t=l())||void 0===t?void 0:t.media)||void 0===n?void 0:n.contentId;return!!o&&!!~r.indexOf(o)}function d(e){var t;return(null===(t=e.type)||void 0===t?void 0:t.match(s))||!1}function m(e,t){if(!t.opts.src)return e;const n=(Array.isArray(t.opts.src)?t.opts.src:[t.opts.src]).map(e=>"string"==typeof e?r(e)[0]:e);return e.map(e=>{const t=n.find(t=>t.src===e.src);return t&&t.drm?Object.assign(Object.assign({},e),{drm:t.drm}):e})}function p(e){return Pipe.of(e).fmap(()=>e.original_src||[]).fmap((function(e){return"string"==typeof e?r(e):e})).fmap(m,e).fmap((function(e){return e.filter(d)}))}function f(){var e,t,n;return null===(n=null===(t=null===(e=window.cast)||void 0===e?void 0:e.framework)||void 0===t?void 0:t.CastContext)||void 0===n?void 0:n.getInstance()}function v(e){return e.filter((function(e){return u(e)}))}function h(e){return e.filter((function(e){return!u(e)}))}function y(e,t,n){v(e).forEach((function(e){e.emit(t,n)}))}function S(e,t,n){h(e).forEach((function(e){e.emit(t,n)}))}function g(e,t,n){e.forEach((function(e){e.emit(t,n)}))}const E={PAUSED:"isPaused",CURRENT_TIME:"currentTime",DURATION:"duration",CONNECTED:"isConnected",PLAYER_STATE:"playerState",SAVED_STATE:"savedPlayerState",DISPLAY_NAME:"displayName",STATUS:"statusText",LIVE_RANGES:"liveSeekableRange"},w={player:void 0,controller:void 0,listener:void 0};function _(e){w.controller&&w.listener&&w.controller.removeEventListener(cast.framework.RemotePlayerEventType.ANY_CHANGE,w.listener),w.player=new cast.framework.RemotePlayer,w.controller=new cast.framework.RemotePlayerController(w.player),w.listener=T.bind(null,e),w.controller.addEventListener(cast.framework.RemotePlayerEventType.ANY_CHANGE,w.listener)}function T(e,t){if("IDLE"===t.value)return S(e,o);y(e,"chromecast:field:update",t)}function b(e){return Array.from(e.textTracks).filter(e=>["subtitles","captions"].includes(e.kind))}function A(e){return b(e).flatMap((t,n)=>{try{const r=e.querySelector("#"+t.id);if(!(r instanceof HTMLTrackElement&&r.lang))return[];const o=new chrome.cast.media.Track(n+1e3,chrome.cast.media.TrackType.TEXT);return o.trackContentType="text/vtt",o.subtype=chrome.cast.media.TextTrackType.SUBTITLES,o.trackContentId=r.src,o.name=r.label,o.language=r.lang,o}catch(e){return[]}})}function C(e){var t;const n=new chrome.cast.media.EditTracksInfoRequest(e);null===(t=l())||void 0===t||t.editTracksInfo(n,console.debug,console.error)}var k=Object.freeze({__proto__:null,getCurrentSession:i,getMedia:c,getMediaSession:l,isSame:u,is_supported_media:d,injectDRMConfiguration:m,normalizeSrc:p,getCastContext:f,casting_players:v,idle_players:h,broadcast_to_active:y,broadcast_to_idle:S,broadcast:g,FIELDS:E,SINGLETONS:w,refresh_singletons:_,onremotechange:T,tracks:b,cast_tracks:A,editTracks:C});function O(e,t,n,r){var a,s,l,u,d;const m=i();if(!m)return;const p=c(e);if(!p||!p.src)return;const f=new chrome.cast.media.MediaInfo(p.src,p.type||"");f.metadata=new chrome.cast.media.GenericMediaMetadata;const v={health:e.health,text_tracks:A(e),active_tracks:{active_audio:(null===(s=null===(a=null==e?void 0:e.asel)||void 0===a?void 0:a.active_track)||void 0===s?void 0:s.name)||(null===(u=null===(l=null==e?void 0:e.asel)||void 0===l?void 0:l.active_track)||void 0===u?void 0:u.lang),active_text:null===(d=b(e).find(e=>e.is_active))||void 0===d?void 0:d.label}};p.drm&&(v.drm=p.drm),localStorage.__fpChromecastDebug&&(v.debug=!0),e.opt("ads")&&(v.ads=e.opt("ads")),f.customData=v;const h=new chrome.cast.media.LoadRequest(f);isNaN(e.currentTime)||(h.currentTime=e.currentSessionTime),h.customData=e.opt("chromecast",{}),h.customData.metadata=e.opt("metadata"),e.emit("chromecast:media",{request:h}),console.debug("cast:request(%o)",h),m.loadMedia(h).then((function(){_(t),S(t,o)}),r)}function I(){return!!l()}function L(){return!!i()}function N(){var e;return(null===(e=null==k?void 0:i())||void 0===e?void 0:e.getMediaSession()).getEstimatedLiveSeekableRange()}function D(){var e;return null===(e=l())||void 0===e?void 0:e.media.duration}function P(){var e;return null===(e=l())||void 0===e?void 0:e.playerState}function x(e){var t;return e?R(e):null===(t=l())||void 0===t?void 0:t.getEstimatedTime()}function R(e){const t=l();if(!t)return e;const n=new chrome.cast.media.SeekRequest;return n.currentTime=e,t.seek(n,console.debug,console.error),e}function M(){var e;return null===(e=l())||void 0===e?void 0:e.play(new chrome.cast.media.PlayRequest,console.debug,console.error)}function j(){var e;return null===(e=l())||void 0===e?void 0:e.pause(new chrome.cast.media.PauseRequest,console.debug,console.error)}var q=Object.freeze({__proto__:null,load:O,has_media:I,exists:L,device_name:function(){var e;return null===(e=i())||void 0===e?void 0:e.getCastDevice().friendlyName},seekable_ranges:N,duration:D,state:P,currentTime:x,seek:R,play:M,pause:j});class Sender{constructor(e){this.video=e}static of(e){return e.sender||(e.sender=new Sender(e)),e.sender}static maybe(e,t){e.sender&&t(e.sender,e)}static getEstimatedTime(){var e;return null===(e=l())||void 0===e?void 0:e.getEstimatedTime()}static load(e,t){O(e,t,console.debug,console.error)}static destroy(e){e.video=void 0}}var G="audio:update";var U=Object.freeze({__proto__:null,STABLE:"940D4BE4",CANARY:"6F71FA7C",LOCAL:"5258CA32"});const H="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1";function F(e,t,n){if(document.querySelector("script[src='"+H+"']"))return V(n);!function(){const e=document.createElement("script");e.async=!0,e.src=H,document.head.appendChild(e)}(),window.__onGCastApiAvailable=function(){!function(e,t,n){var r;if(!B())return;const o=(null===(r=e.chromecast)||void 0===r?void 0:r.app)||"940D4BE4",a=f();if(!a)return;a.setOptions({receiverApplicationId:o,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}),a.addEventListener(cast.framework.CastContextEventType.CAST_STATE_CHANGED,(function(e){g(n,"chromecast:state:changed",e)})),a.addEventListener(cast.framework.CastContextEventType.SESSION_STATE_CHANGED,(function(e){_(n),g(n,"chromecast:session:changed",e)}))}(e,0,n),V(n)}}function B(){return"object"==typeof window.cast&&"object"==typeof chrome.cast}function V(e){if(B())return g(e,"chromecast:available");g(e,"chromecast:unavailable")}function Y(e,t){const n={play:function(){return new Promise(n=>u(e)?n(M()):I()?n(Sender.load(e,t)):(Sender.load(e,t),void n()))},pause:function(){return u(e)?j():HTMLMediaElement.prototype.pause.call(e)}};n.currentTime={get:x,set:x},n.seekable={get:()=>{const e=N();return{start:()=>(null==e?void 0:e.start)||0,end:()=>(null==e?void 0:e.end)||0,length:1}}},n.duration={get:D},n.paused={get:function(){return"PAUSED"===P()}},n.playing={get:function(){return"PLAYING"===P()}},Object.keys(n).forEach((function(t){if("object"==typeof n[t])return Object.defineProperty(e,t,{get:function(){var r,o;return u(e)?n[t].get():null===(o=null===(r=Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype,t))||void 0===r?void 0:r.get)||void 0===o?void 0:o.call(this)},set:function(r){var o,a;return u(e)?n[t].set(r):null===(a=null===(o=Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype,t))||void 0===o?void 0:o.set)||void 0===a?void 0:a.call(this,r)}});const r=e[t];e[t]=function(){const o=[].slice.apply(arguments);return L()?n[t].apply(e,o):r.apply(e,o)}}))}const z=(e,t)=>new(((e,t)=>{const n=e.get(t);if(!n)throw new Error(`no flowplayer component with the name ${t} exists`);const r=window.customElements.get(t);if(!r)throw new Error(`no default flowplayer component with the name ${t} exists`);const o=window.customElements.get(n);return"function"!=typeof o?r:o})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}class FlowplayerChromecastIcon extends FlowplayerComponent{constructor(e){super(e),this.classList.add("fp-cast-button"),this.setAttribute("tabindex","-1"),this.setAttribute("role","button"),this.setAttribute("aria-hidden","true"),this.append(this.cast_launcher(e)),this.addEventListener("click",(function(t){var n;const r=i();if(r)return r.endSession(!0);e.emit("chromecast:start"),t.target===this&&(null===(n=this.querySelector("google-cast-launcher"))||void 0===n||n.dispatchEvent(new Event("click")))})),e.on("chromecast:state:changed",t=>{const n=t.detail.castState;n&&(this.setAttribute("tabindex",n===cast.framework.CastState.NO_DEVICES_AVAILABLE?"-1":"0"),this.setAttribute("aria-hidden",(n===cast.framework.CastState.NO_DEVICES_AVAILABLE)+""),this.setAttribute("aria-label",n===cast.framework.CastState.NOT_CONNECTED?e.i18n("chromecast.start","start casting"):e.i18n("chromecast.stop","stop casting")))})}cast_launcher(e){const t=document.createElement("google-cast-launcher");return t.setAttribute("tabindex","-1"),t.setAttribute("aria-hidden","true"),e.on("chromecast:available",()=>{var e;const n=null===(e=t.shadowRoot)||void 0===e?void 0:e.querySelector("svg");null==n||n.setAttribute("aria-hidden","true"),null==n||n.setAttribute("focusable","false")}),t}}function J(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}class ChromecastPlugin{constructor(e){var t,n,r;this.flowplayer=e,t=e,n="flowplayer-chromecast-icon",r=FlowplayerChromecastIcon,window.customElements.get(n)||window.customElements.define(n,r),t.customElements.get(n)||t.customElements.set(n,n)}init(e,t,n){if("https:"!==location.protocol&&"localhost"!==location.hostname&&"127.0.0.1"!==location.hostname)return console.warn("Secure URL required to enable Chromecast");F(e,0,this.flowplayer.instances);const r={pending:void 0};n.on("reap",(function(){Sender.maybe(n,Sender.destroy)})),n.on("mount",(function(){const t=J(n,"flowplayer-middle");t&&function(e,t){const n=document.createElement("div");n.className="fp-chromecast";const r=document.createElement("p");t.poster&&(n.style.backgroundImage=["url(",t.poster,")"].join("")),n.append(r),e.prepend(n)}(t,{poster:e.poster});const r=J(n,"flowplayer-header-right-zone");r&&r.prepend(z(n,"flowplayer-chromecast-icon"))})),n.on("chromecast:available",()=>{n.setState("is-cast-available",!0),Sender.of(n),Y(n,this.flowplayer.instances)}),n.on("chromecast:unavailable",(function(){n.setState("is-cast-available",!1),Sender.maybe(n,Sender.destroy)})),n.on("chromecast:start",()=>{if(this.flowplayer.instances.forEach(e=>{e.togglePlay(!1),e.currentSessionTime=e.hasState("is-ended")?0:e.currentTime}),I())return Sender.load(n,this.flowplayer.instances);r.pending=!0}),n.on("tracks:text:updated",(function(e){var t;if(I())return e.data?void C((null===(t=l())||void 0===t?void 0:t.media.tracks.filter(e=>"TEXT"===e.type).filter(e=>{var t;return e.name===(null===(t=b(n).find(e=>e.is_active))||void 0===t?void 0:t.label)}).map(e=>e.trackId))||[]):C([])})),n.on(G,()=>{I()&&setTimeout(()=>{var e,t,r;const o=null===(e=null==n?void 0:n.asel)||void 0===e?void 0:e.active_track,a=null===(r=null===(t=l())||void 0===t?void 0:t.media.tracks.filter(e=>"AUDIO"===e.type).find(e=>void 0!==e.name?e.name===(null==o?void 0:o.name):e.language===(null==o?void 0:o.lang)))||void 0===r?void 0:r.trackId;"number"==typeof a&&C([a])},0)}),n.on(o,()=>{this.reset_state(n);const e=n.opt("duration");"number"==typeof e&&Math.abs(e-n.currentSessionTime)<=1&&(n.currentSessionTime=0,n.setState("is-paused",!1),n.emit("ended"))}),n.on("chromecast:field:update",(function(e){if(!e.data)return;const{field:t,value:r}=e.data;switch(t){case E.CURRENT_TIME:{Math.abs(r-n.currentSessionTime)>=1.5&&n.emit("seeked"),n.currentSessionTime=r,n.emit("timeupdate",r);const e=N();if(e){n.opts.live||n.setOpts({live:!0});const t=e.end,r=e.start;if("number"!=typeof r||"number"!=typeof t)return;n.emit("dvr/window",t-r)}return}case E.PLAYER_STATE:return"PLAYING"==r?n.emit("playing"):"PAUSED"==r?n.emit("pause"):void 0;case"videoInfo":var o=(r||{}).fake_session||q;return function(e,t){if(!e.root)return;const n=e.root.querySelector(".fp-chromecast p");if(!n)return;let r="";r=e.i18n("chromecast.message","{{state}} on {{device}}").replace("{{device}}",(null==t?void 0:t.device)||"chromecast"),r=r.replace("{{state}}",((null==t?void 0:t.state)||"").toLowerCase()),n.textContent=r}(n,{device:o.device_name(),state:o.state()}),o.hide_controls&&n.setState("no-chromecast-controls",!0),n.setState("is-starting",!1),n.hasState("is-loaded")||-1===n.duration||n.setOpts({duration:n.duration}),n.setState("is-chromecast-playing",!0)}})),n.on("chromecast:session:changed",e=>{if(e.data)switch(e.detail.sessionState){case cast.framework.SessionState.SESSION_ENDED:return n.emit("remotesession:ended",{currentTime:n.currentSessionTime}),n.setState("is-casting",!1),this.reset_state(n);case cast.framework.SessionState.SESSION_RESUMED:case cast.framework.SessionState.SESSION_STARTED:r.pending&&(r.pending=!1,Sender.load(n,this.flowplayer.instances),n.emit("remotesession:started"),n.setState("is-casting",!0))}})}reset_state(e){e.setState("is-chromecast-playing",!1),e.setState("is-playing",!1),e.setState("is-paused",!0),e.setState("is-starting",!0)}}return ChromecastPlugin.apps=U,ChromecastPlugin.events=a,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,ChromecastPlugin)}));
1
+ !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.chromecast=t())}(this,(function(){"use strict";function e(e){const t=document.createElement("a");t.href=e;const n=t.pathname&&t.pathname.split(".");return n.length>1&&n[n.length-1]}function t(e){switch(e){case"video/mpd":return"application/dash+xml";case"video/m3u8":return"application/x-mpegurl";default:return e}}const n=n=>{var{src:r}=n,o=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(n,["src"]);return[Object.assign({src:r,type:r?t("video/"+e(r)):""},o)]};function r(e){return n({src:e})}class Pipe{constructor(e){this.data=e}static of(e){return new Pipe(e)}static maybe(e,t,...n){return null==e?e:t.apply(e,[e,...n])}tap(e,...t){return e.apply(this,[this.data,...t]),new Pipe(this.data)}fmap(e,...t){const n=e.apply(this,[this.data,...t]);return new Pipe(n)}unwrap(){return this.data}}const o="chromecast:idle";var a=Object.freeze({__proto__:null,CAST_AVAILABLE:"chromecast:available",CAST_UNAVAILABLE:"chromecast:unavailable",CAST_START_CASTING:"chromecast:start",CAST_IDLE:o,CAST_STATE_CHANGED:"chromecast:state:changed",CAST_SESSION_CHANGED:"chromecast:session:changed",CAST_FIELD_UPDATE:"chromecast:field:update",CAST_MEDIA_LOAD_REQUEST:"chromecast:media"});const s=/(video\/mp4)|(application\/x-mpegurl)|(video\/mpd)|(application\/dash\+xml)/;function i(){var e;return(null===(e=f())||void 0===e?void 0:e.getCurrentSession())||null}function c(e){return p(e).unwrap().shift()}function l(){var e;return(null===(e=i())||void 0===e?void 0:e.getMediaSession())||null}function u(e){var t,n;const r=p(e).unwrap().map((function(e){return null==e?void 0:e.src})),o=null===(n=null===(t=l())||void 0===t?void 0:t.media)||void 0===n?void 0:n.contentId;return!!o&&!!~r.indexOf(o)}function d(e){var t;return(null===(t=e.type)||void 0===t?void 0:t.match(s))||!1}function m(e,t){if(!t.opts.src)return e;const n=(Array.isArray(t.opts.src)?t.opts.src:[t.opts.src]).map(e=>"string"==typeof e?r(e)[0]:e);return e.map(e=>{const t=n.find(t=>t.src===e.src);return t&&t.drm?Object.assign(Object.assign({},e),{drm:t.drm}):e})}function p(e){return Pipe.of(e).fmap(()=>e.original_src||[]).fmap((function(e){return"string"==typeof e?r(e):e})).fmap(m,e).fmap((function(e){return e.filter(d)}))}function f(){var e,t,n;return null===(n=null===(t=null===(e=window.cast)||void 0===e?void 0:e.framework)||void 0===t?void 0:t.CastContext)||void 0===n?void 0:n.getInstance()}function v(e){return e.filter((function(e){return u(e)}))}function h(e){return e.filter((function(e){return!u(e)}))}function y(e,t,n){v(e).forEach((function(e){e.emit(t,n)}))}function S(e,t,n){h(e).forEach((function(e){e.emit(t,n)}))}function E(e,t,n){e.forEach((function(e){e.emit(t,n)}))}const g={PAUSED:"isPaused",CURRENT_TIME:"currentTime",DURATION:"duration",CONNECTED:"isConnected",PLAYER_STATE:"playerState",SAVED_STATE:"savedPlayerState",DISPLAY_NAME:"displayName",STATUS:"statusText",VOLUME:"volumeLevel",MUTE:"isMuted",LIVE_RANGES:"liveSeekableRange"},w={player:void 0,controller:void 0,listener:void 0};function _(e){w.controller&&w.listener&&w.controller.removeEventListener(cast.framework.RemotePlayerEventType.ANY_CHANGE,w.listener),w.player=new cast.framework.RemotePlayer,w.controller=new cast.framework.RemotePlayerController(w.player),w.listener=T.bind(null,e),w.controller.addEventListener(cast.framework.RemotePlayerEventType.ANY_CHANGE,w.listener)}function T(e,t){if("IDLE"===t.value)return S(e,o);y(e,"chromecast:field:update",t)}function b(e){return Array.from(e.textTracks).filter(e=>["subtitles","captions"].includes(e.kind))}function A(e){return b(e).flatMap((t,n)=>{try{const r=e.querySelector("#"+t.id);if(!(r instanceof HTMLTrackElement&&r.lang))return[];const o=new chrome.cast.media.Track(n+1e3,chrome.cast.media.TrackType.TEXT);return o.trackContentType="text/vtt",o.subtype=chrome.cast.media.TextTrackType.SUBTITLES,o.trackContentId=r.src,o.name=r.label,o.language=r.lang,o}catch(e){return[]}})}function C(e){var t;const n=new chrome.cast.media.EditTracksInfoRequest(e);null===(t=l())||void 0===t||t.editTracksInfo(n,console.debug,console.error)}var k=Object.freeze({__proto__:null,getCurrentSession:i,getMedia:c,getMediaSession:l,isSame:u,is_supported_media:d,injectDRMConfiguration:m,normalizeSrc:p,getCastContext:f,casting_players:v,idle_players:h,broadcast_to_active:y,broadcast_to_idle:S,broadcast:E,FIELDS:g,SINGLETONS:w,refresh_singletons:_,onremotechange:T,tracks:b,cast_tracks:A,editTracks:C});function O(e,t,n,r){var a,s,l,u,d;const m=i();if(!m)return;const p=c(e);if(!p||!p.src)return;const f=new chrome.cast.media.MediaInfo(p.src,p.type||"");f.metadata=new chrome.cast.media.GenericMediaMetadata;const v={health:e.health,text_tracks:A(e),active_tracks:{active_audio:(null===(s=null===(a=null==e?void 0:e.asel)||void 0===a?void 0:a.active_track)||void 0===s?void 0:s.name)||(null===(u=null===(l=null==e?void 0:e.asel)||void 0===l?void 0:l.active_track)||void 0===u?void 0:u.lang),active_text:null===(d=b(e).find(e=>e.is_active))||void 0===d?void 0:d.label}};p.drm&&(v.drm=p.drm),localStorage.__fpChromecastDebug&&(v.debug=!0),e.opt("ads")&&(v.ads=e.opt("ads")),f.customData=v;const h=new chrome.cast.media.LoadRequest(f);isNaN(e.currentTime)||(h.currentTime=e.currentSessionTime),h.customData=e.opt("chromecast",{}),h.customData.metadata=e.opt("metadata"),e.emit("chromecast:media",{request:h}),console.debug("cast:request(%o)",h),m.loadMedia(h).then((function(){_(t);const n=w.player;n&&(e.volume=n.volumeLevel,e.muted=n.isMuted),S(t,o)}),r)}function L(){return!!l()}function I(){return!!i()}function N(){var e;return(null===(e=null==k?void 0:i())||void 0===e?void 0:e.getMediaSession()).getEstimatedLiveSeekableRange()}function D(){var e;return null===(e=l())||void 0===e?void 0:e.media.duration}function P(){var e;return null===(e=l())||void 0===e?void 0:e.playerState}function x(e){var t;return e?M(e):null===(t=l())||void 0===t?void 0:t.getEstimatedTime()}function M(e){const t=l();if(!t)return e;const n=new chrome.cast.media.SeekRequest;return n.currentTime=e,t.seek(n,console.debug,console.error),e}function R(){var e;return null===(e=l())||void 0===e?void 0:e.play(new chrome.cast.media.PlayRequest,console.debug,console.error)}function j(){var e;return null===(e=l())||void 0===e?void 0:e.pause(new chrome.cast.media.PauseRequest,console.debug,console.error)}var U=Object.freeze({__proto__:null,load:O,has_media:L,exists:I,device_name:function(){var e;return null===(e=i())||void 0===e?void 0:e.getCastDevice().friendlyName},seekable_ranges:N,duration:D,state:P,currentTime:x,seek:M,play:R,pause:j});class Sender{constructor(e){this.video=e}static of(e){return e.sender||(e.sender=new Sender(e)),e.sender}static maybe(e,t){e.sender&&t(e.sender,e)}static getEstimatedTime(){var e;return null===(e=l())||void 0===e?void 0:e.getEstimatedTime()}static load(e,t){O(e,t,console.debug,console.error)}static destroy(e){e.video=void 0}}var G="audio:update";var q=Object.freeze({__proto__:null,STABLE:"940D4BE4",CANARY:"6F71FA7C",LOCAL:"5258CA32"});const H="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1";function V(e,t,n){if(document.querySelector("script[src='"+H+"']"))return B(n);!function(){const e=document.createElement("script");e.async=!0,e.src=H,document.head.appendChild(e)}(),window.__onGCastApiAvailable=function(){!function(e,t,n){var r;if(!F())return;const o=(null===(r=e.chromecast)||void 0===r?void 0:r.app)||"940D4BE4",a=f();if(!a)return;a.setOptions({receiverApplicationId:o,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}),a.addEventListener(cast.framework.CastContextEventType.CAST_STATE_CHANGED,(function(e){E(n,"chromecast:state:changed",e)})),a.addEventListener(cast.framework.CastContextEventType.SESSION_STATE_CHANGED,(function(e){_(n),E(n,"chromecast:session:changed",e)}))}(e,0,n),B(n)}}function F(){return"object"==typeof window.cast&&"object"==typeof chrome.cast}function B(e){if(F())return E(e,"chromecast:available");E(e,"chromecast:unavailable")}function Y(e,t){const n={play:function(){return new Promise(n=>u(e)?n(R()):L()?n(Sender.load(e,t)):(Sender.load(e,t),void n()))},pause:function(){return u(e)?j():HTMLMediaElement.prototype.pause.call(e)}};n.currentTime={get:x,set:x},n.seekable={get:()=>{const e=N();return{start:()=>(null==e?void 0:e.start)||0,end:()=>(null==e?void 0:e.end)||0,length:1}}},n.duration={get:D},n.paused={get:function(){return"PAUSED"===P()}},n.playing={get:function(){return"PLAYING"===P()}},Object.keys(n).forEach((function(t){if("object"==typeof n[t])return Object.defineProperty(e,t,{get:function(){var r,o;return u(e)?n[t].get():null===(o=null===(r=Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype,t))||void 0===r?void 0:r.get)||void 0===o?void 0:o.call(this)},set:function(r){var o,a;return u(e)?n[t].set(r):null===(a=null===(o=Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype,t))||void 0===o?void 0:o.set)||void 0===a?void 0:a.call(this,r)}});const r=e[t];e[t]=function(){const o=[].slice.apply(arguments);return I()?n[t].apply(e,o):r.apply(e,o)}}))}const z=(e,t)=>new(((e,t)=>{const n=e.get(t);if(!n)throw new Error(`no flowplayer component with the name ${t} exists`);const r=window.customElements.get(t);if(!r)throw new Error(`no default flowplayer component with the name ${t} exists`);const o=window.customElements.get(n);return"function"!=typeof o?r:o})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}class FlowplayerChromecastIcon extends FlowplayerComponent{constructor(e){super(e),this.classList.add("fp-cast-button"),this.setAttribute("tabindex","-1"),this.setAttribute("role","button"),this.setAttribute("aria-hidden","true"),this.cast_launcher=document.createElement("google-cast-launcher"),this.cast_launcher.setAttribute("inert","true"),this.append(this.cast_launcher),this.addEventListener("click",t=>{const n=i();if(n)return n.endSession(!0);e.emit("chromecast:start"),t.target===this&&this.cast_launcher.click()}),e.on("chromecast:state:changed",t=>{const n=t.detail.castState;n&&(this.setAttribute("tabindex",n===cast.framework.CastState.NO_DEVICES_AVAILABLE?"-1":"0"),this.setAttribute("aria-hidden",(n===cast.framework.CastState.NO_DEVICES_AVAILABLE)+""),this.setAttribute("aria-label",n===cast.framework.CastState.NOT_CONNECTED?e.i18n("chromecast.start","start casting"):e.i18n("chromecast.stop","stop casting")))})}}function J(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}class ChromecastPlugin{constructor(e){var t,n,r;this.flowplayer=e,t=e,n="flowplayer-chromecast-icon",r=FlowplayerChromecastIcon,window.customElements.get(n)||window.customElements.define(n,r),t.customElements.get(n)||t.customElements.set(n,n)}init(e,t,n){if("https:"!==location.protocol&&"localhost"!==location.hostname&&"127.0.0.1"!==location.hostname)return console.warn("Secure URL required to enable Chromecast");V(e,0,this.flowplayer.instances);const r={pending:void 0};n.on("reap",(function(){Sender.maybe(n,Sender.destroy)})),n.on("mount",(function(){const t=J(n,"flowplayer-middle");t&&function(e,t){const n=document.createElement("div");n.className="fp-chromecast";const r=document.createElement("p");t.poster&&(n.style.backgroundImage=["url(",t.poster,")"].join("")),n.append(r),e.prepend(n)}(t,{poster:e.poster});const r=J(n,"flowplayer-header-right-zone");r&&r.prepend(z(n,"flowplayer-chromecast-icon"))})),n.on("chromecast:available",()=>{n.setState("is-cast-available",!0),Sender.of(n),Y(n,this.flowplayer.instances)}),n.on("chromecast:unavailable",(function(){n.setState("is-cast-available",!1),Sender.maybe(n,Sender.destroy)})),n.on("chromecast:start",()=>{if(this.flowplayer.instances.forEach(e=>{e.togglePlay(!1),e.currentSessionTime=e.hasState("is-ended")?0:e.currentTime}),L())return Sender.load(n,this.flowplayer.instances);r.pending=!0}),n.on("volumechange",()=>{const e=w.player,t=w.controller;if(!L()||!e||!t)return;const r=n.volume,o=n.muted;r!==e.volumeLevel&&(e.volumeLevel=r,t.setVolumeLevel()),o!==e.isMuted&&t.muteOrUnmute()}),n.on("tracks:text:updated",(function(e){var t;if(L())return e.data?void C((null===(t=l())||void 0===t?void 0:t.media.tracks.filter(e=>"TEXT"===e.type).filter(e=>{var t;return e.name===(null===(t=b(n).find(e=>e.is_active))||void 0===t?void 0:t.label)}).map(e=>e.trackId))||[]):C([])})),n.on(G,()=>{L()&&setTimeout(()=>{var e,t,r;const o=null===(e=null==n?void 0:n.asel)||void 0===e?void 0:e.active_track,a=null===(r=null===(t=l())||void 0===t?void 0:t.media.tracks.filter(e=>"AUDIO"===e.type).find(e=>void 0!==e.name?e.name===(null==o?void 0:o.name):e.language===(null==o?void 0:o.lang)))||void 0===r?void 0:r.trackId;"number"==typeof a&&C([a])},0)}),n.on(o,()=>{this.reset_state(n);const e=n.opt("duration");"number"==typeof e&&Math.abs(e-n.currentSessionTime)<=1&&(n.currentSessionTime=0,n.setState("is-paused",!1),n.emit("ended"))}),n.on("chromecast:field:update",(function(e){if(!e.data)return;const{field:t,value:r}=e.data;switch(t){case g.MUTE:return n.muted=r;case g.VOLUME:return n.volume=r;case g.CURRENT_TIME:{Math.abs(r-n.currentSessionTime)>=1.5&&n.emit("seeked"),n.currentSessionTime=r,n.emit("timeupdate",r);const e=N();if(e){n.opts.live||n.setOpts({live:!0});const t=e.end,r=e.start;if("number"!=typeof r||"number"!=typeof t)return;n.emit("dvr/window",t-r)}return}case g.PLAYER_STATE:return"PLAYING"==r?n.emit("playing"):"PAUSED"==r?n.emit("pause"):void 0;case"videoInfo":var o=(r||{}).fake_session||U;return function(e,t){if(!e.root)return;const n=e.root.querySelector(".fp-chromecast p");if(!n)return;let r="";r=e.i18n("chromecast.message","{{state}} on {{device}}").replace("{{device}}",(null==t?void 0:t.device)||"chromecast"),r=r.replace("{{state}}",((null==t?void 0:t.state)||"").toLowerCase()),n.textContent=r}(n,{device:o.device_name(),state:o.state()}),o.hide_controls&&n.setState("no-chromecast-controls",!0),n.setState("is-starting",!1),n.hasState("is-loaded")||-1===n.duration||n.setOpts({duration:n.duration}),n.setState("is-chromecast-playing",!0)}})),n.on("chromecast:session:changed",e=>{if(e.data)switch(e.detail.sessionState){case cast.framework.SessionState.SESSION_ENDED:return n.emit("remotesession:ended",{currentTime:n.currentSessionTime}),n.setState("is-casting",!1),this.reset_state(n);case cast.framework.SessionState.SESSION_RESUMED:case cast.framework.SessionState.SESSION_STARTED:r.pending&&(r.pending=!1,Sender.load(n,this.flowplayer.instances),n.emit("remotesession:started"),n.setState("is-casting",!0))}})}reset_state(e){e.setState("is-chromecast-playing",!1),e.setState("is-playing",!1),e.setState("is-paused",!0),e.setState("is-starting",!0)}}ChromecastPlugin.apps=q,ChromecastPlugin.events=a;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,ChromecastPlugin)}));