@flowplayer/player 3.14.1 → 3.15.0-rc.2
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.
- package/core.js +1 -1
- package/default.js +1 -1
- package/embed.js +2 -2
- package/package.json +1 -1
- package/plugins/ads.d.ts +164 -3
- package/plugins/ads.js +1 -1
- package/plugins/airplay.d.ts +7 -7
- package/plugins/airplay.js +1 -1
- package/plugins/analytics.d.ts +6 -3
- package/plugins/analytics.js +1 -1
- package/plugins/asel.d.ts +6 -3
- package/plugins/asel.js +1 -1
- package/plugins/audio.d.ts +6 -3
- package/plugins/chapters.d.ts +6 -3
- package/plugins/chapters.js +1 -1
- package/plugins/chromecast.d.ts +6 -3
- package/plugins/chromecast.js +1 -1
- package/plugins/comscore.d.ts +6 -3
- package/plugins/consent.d.ts +5 -2
- package/plugins/consent.js +1 -1
- package/plugins/context-menu.d.ts +6 -3
- package/plugins/cuepoints.d.ts +6 -3
- package/plugins/cuepoints.js +1 -1
- package/plugins/dash.d.ts +6 -4
- package/plugins/dash.js +1 -1
- package/plugins/drm.d.ts +6 -3
- package/plugins/drm.js +1 -1
- package/plugins/endscreen.d.ts +6 -3
- package/plugins/endscreen.js +1 -1
- package/plugins/fas.d.ts +6 -3
- package/plugins/float-on-scroll.d.ts +6 -3
- package/plugins/float-on-scroll.js +1 -1
- package/plugins/ga4.d.ts +6 -3
- package/plugins/gemius.d.ts +6 -3
- package/plugins/google-analytics.d.ts +6 -3
- package/plugins/health.d.ts +1 -4
- package/plugins/health.js +1 -1
- package/plugins/hls.d.ts +7 -4
- package/plugins/hls.js +1 -1
- package/plugins/id3.d.ts +6 -3
- package/plugins/id3.js +1 -1
- package/plugins/iframe.d.ts +2 -2
- package/plugins/iframe.js +1 -1
- package/plugins/keyboard.d.ts +6 -3
- package/plugins/media-session.d.ts +6 -3
- package/plugins/message.d.ts +6 -3
- package/plugins/message.js +1 -1
- package/plugins/playlist.d.ts +6 -3
- package/plugins/playlist.js +1 -1
- package/plugins/preview.d.ts +6 -3
- package/plugins/preview.js +1 -1
- package/plugins/qsel.d.ts +6 -3
- package/plugins/qsel.js +1 -1
- package/plugins/qul.d.ts +6 -3
- package/plugins/qul.js +1 -1
- package/plugins/rts.d.ts +6 -3
- package/plugins/rts.js +1 -1
- package/plugins/share.d.ts +6 -3
- package/plugins/share.js +1 -1
- package/plugins/speed.d.ts +6 -3
- package/plugins/speed.js +1 -1
- package/plugins/ssai.d.ts +6 -3
- package/plugins/ssai.js +1 -1
- package/plugins/thumbnails.d.ts +6 -3
- package/plugins/thumbnails.js +1 -1
- package/plugins/tizen.d.ts +6 -3
- package/plugins/tizen.js +1 -1
- package/plugins/vtsel.d.ts +6 -3
- package/plugins/vtsel.js +1 -1
- package/plugins/webos.d.ts +6 -3
- package/plugins/webos.js +1 -1
package/plugins/asel.d.ts
CHANGED
|
@@ -6,6 +6,12 @@ infer Current,
|
|
|
6
6
|
...infer Remaining
|
|
7
7
|
] ? Current & ArrayToIntersection<Remaining> : unknown;
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
declare const Asel: PluginCtor<KeyValue, KeyValue>;
|
|
13
|
+
export default Asel;
|
|
14
|
+
|
|
9
15
|
/* Excluded from this release type: AselProperties */
|
|
10
16
|
|
|
11
17
|
/* Excluded from this release type: AudioTrack */
|
|
@@ -83,9 +89,6 @@ declare interface Config {
|
|
|
83
89
|
|
|
84
90
|
declare type ConfigWith<T> = Config & T;
|
|
85
91
|
|
|
86
|
-
declare const _default: PluginCtor<KeyValue, KeyValue>;
|
|
87
|
-
export default _default;
|
|
88
|
-
|
|
89
92
|
declare type DeviceId = string;
|
|
90
93
|
|
|
91
94
|
declare type DRM_KEYSYSTEM = "com.widevine.alpha" | "com.microsoft.playready" | "org.w3.clearkey" | "com.apple.fps.1_0";
|
package/plugins/asel.js
CHANGED
|
@@ -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.asel=t())}(this,(function(){"use strict";var e={SET:"audio:set",SWITCH:"audio:update",TRACKS:"audio:tracks"};function t(e,t,n){const s=function(e){return Array.isArray(e)?e.slice(0):e.split(".")}(t);for(;s.length;){if(null==e)return n;const t=s.shift();if("string"!=typeof t)return n;e=e[t]}return null==e?n:e}const n=navigator.languages||[navigator.language];function s(t,n){t.emit(e.SET,n),n.autoselect&&t._storage.setItem("@flowplayer/audio/track",n.lang)}function i(e){return e.toLowerCase()}function o(e,s,o){s=s.slice(0);const a={},r=e.getItem("@flowplayer/audio/track");let l=function(){try{return n.reduce((e,t)=>~t.indexOf("-")?e.concat(t,t.split("-")[0]):e.concat(t),[])}catch(e){return[]}}().map(i),c=-1;if("number"==typeof o)return o;for("string"==typeof o&&(o=o.toLowerCase(),~l.indexOf(o)&&l.splice(l.indexOf(o),1),l.unshift(i(o))),Array.isArray(o)&&(l=o.map(i));s.length;){++c;const e=s.shift();if(null==e?void 0:e.autoselect){if(r==e.lang)return console.debug("restoring lang from previous session: ",r),c;if(e.default&&(a.fallback=[c,e]),e.lang&&~l.indexOf(e.lang.toLowerCase())){const n=l.indexOf(e.lang);if(n<t(a,"by_lang.2",1/0)&&(a.by_lang=[c,e,n]),0===n)break}}}return t(a,"by_lang.0",t(a,"fallback.0",void 0))}const a=(e,t)=>new(((e,t)=>{const n=e.get(t);if(!n)throw new Error(`no flowplayer component with the name ${t} exists`);const s=window.customElements.get(t);if(!s)throw new Error(`no default flowplayer component with the name ${t} exists`);const i=window.customElements.get(n);return"function"!=typeof i?s:i})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}const r="fp-on",l="fp-invis";class FlowplayerMenu extends FlowplayerComponent{constructor(e){super(e),this.player=e,this.menuContainer=document.createElement("details"),this.summaryEle=document.createElement("summary"),this.menuHeader=document.createElement("div"),this.menuTitle=document.createElement("h3"),this.olEle=document.createElement("ol"),this.olEle.id=u(),this.menu=document.createElement("div"),this.closeEle=document.createElement("span"),this.menuHeader.classList.add("fp-menu-header"),this.menuHeader.append(this.menuTitle,this.closeEle),this.menu.classList.add("fp-menu"),this.menu.append(this.menuHeader,this.olEle),this.closeEle.classList.add("fp-close"),this.closeEle.textContent="×",this.menuContainer.classList.add("fp-menu-container"),this.menuContainer.append(this.summaryEle,this.menu),this.menuContainer.addEventListener("click",t=>{if(t.defaultPrevented)return;t.preventDefault();const n=this.menuContainer.open;n||(c(),document.active_menu=this.menuContainer),this.menuContainer.open=!n,e.root.classList.toggle("has-menu-opened",!n),this.summaryEle.setAttribute("aria-expanded",n?"false":"true")}),this.addEventListener("focusin",e=>{const t=e.target;t instanceof HTMLLIElement&&t.setAttribute("aria-selected","true")}),this.addEventListener("focusout",e=>{const t=e.target;t instanceof HTMLLIElement&&t.setAttribute("aria-selected","false")}),this.append(this.menuContainer),this.olEle.setAttribute("aria-labelledby",this.summaryEle.id),this.olEle.setAttribute("role","menu"),this.summaryEle.setAttribute("aria-haspopup","true"),this.summaryEle.setAttribute("aria-controls",this.olEle.id),this.summaryEle.setAttribute("tabindex","0"),this.summaryEle.setAttribute("aria-expanded","false"),this.summaryEle.setAttribute("role","button")}get options(){return this.olEle.querySelectorAll("li")}setMenuAttrs(e){if(this.className=e.class,this.toggle_visibility(!0),this.summaryEle.id||(this.summaryEle.id=e.id||u()),this.summaryEle.setAttribute("aria-label",e.menuTitle||"Menu"),e.summaryTitle&&(this.summaryEle.textContent=e.summaryTitle),e.summaryIcon){const t=a(this.player,e.summaryIcon);t.setAttribute("tabindex",""),this.summaryEle.append(t)}e.menuTitle&&(this.menuTitle.textContent=e.menuTitle),this.menu.classList.toggle("fp-icons",!!e.icons),this.addEventListener(e.options_event,e=>{this.render(e.data)}),e.item_selected_event&&this.addEventListener(e.item_selected_event,e=>{void 0!==e.data&&this.select_item(e.data.selected_index)})}render(e){this.olEle&&(this.olEle.innerHTML="",e&&e.forEach(this.menuOption,this),this.toggle_visibility(!(null==e?void 0:e.length)))}menuOption(e,t){const n=document.createElement("li");n.setAttribute("role","menuitem"),n.setAttribute("aria-selected","false"),n.setAttribute("tabindex","0"),e.icon&&n.append(e.icon);const s=document.createElement("span");s.textContent=e.text,n.append(s),n.addEventListener("click",()=>{this.select_item(t),"function"==typeof e.onclick&&e.onclick()}),this.olEle.appendChild(n),e.selected&&this.select_item(t)}select_item(e){this.options.forEach((t,n)=>{t.classList.toggle(r,n===e)})}unselect_item(){this.options.forEach(e=>{e.classList.remove(r)})}toggle_visibility(e){this.classList.toggle(l,e),this.menu.style.setProperty("display",e?"none":"flex")}}function c(){Array.from(document.querySelectorAll(".fp-engine")).forEach(e=>{var t;const n=e.root.querySelector("details[open].fp-menu-container");n&&(n.open=!1,null===(t=n.querySelector("summary"))||void 0===t||t.removeAttribute("aria-expanded"),e.root.classList.toggle("has-menu-opened",!1))})}function u(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function d(e,t,n){const s=function(e,t){const n=new CustomEvent(e,{detail:t,cancelable:!0});return t&&Object.defineProperty(n,"data",{get:()=>t}),n}(t,n);return e.dispatchEvent(s),e}document.addEventListener("click",(function(e){this.active_menu&&!e.composedPath().includes(this.active_menu)&&(c(),this.active_menu=void 0)})),function(){let e=!1;try{const t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("testPassive",null,t),window.removeEventListener("testPassive",null,t)}catch(e){}}();class Asel{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-audio-menu",FlowplayerMenu)}init(n,i,r){if(!1===n.asel)return;let l=[];const c=a(r,"flowplayer-audio-menu");c instanceof FlowplayerMenu&&c.setMenuAttrs({summaryTitle:r.i18n("audio.button_txt"),menuTitle:r.i18n("audio.menu_title"),class:"fp-asel",options_event:Asel.events.TRACKS,item_selected_event:Asel.events.SWITCH});const u=function(t){const n={tracks:[],events:e};return Object.assign(n,{set:function(s){if(!("number"!=typeof s||s<0||s>n.tracks.length-1))return t.emit(e.SET,n.tracks[s]),n},get:function(e){if("number"==typeof e)return n.tracks[e]}}),n}(r);r.asel=u,r.on("mount",(function(){var e;null===(e=function(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}(r,r.hasState("is-tv")?"flowplayer-tv-menu":"flowplayer-control"))||void 0===e||e.append(c)})),r.on("src",()=>{u.tracks=[],u.active_track=void 0,d(c,Asel.events.TRACKS,[])}),r.on(e.TRACKS,(function(e){if(!Array.isArray(e.data)||e.data.length===l.length&&e.data.every((e,t)=>e===l[t]))return;l=e.data,u.tracks=l.slice();const i=t(n,"asel.sort");"function"==typeof i&&u.tracks.sort(i),d(c,Asel.events.TRACKS,Array.from({length:u.tracks.length}).map((e,t)=>{const n=u.tracks[t];return{text:n.name||n.label||n.lang,onclick:s.bind(0,r,n)}})),u.active_track=u.tracks.find(e=>e.enabled),u.active_track&&d(c,Asel.events.SWITCH,{selected_index:u.tracks.indexOf(u.active_track)});const a=o(r._storage,u.tracks,t(n,"asel.default_lang",!1));return c instanceof FlowplayerMenu&&c.toggle_visibility(e.data.length<2),void 0!==a?u.set(a):void 0})),r.on(e.SWITCH,(function(e){r.asel.tracks.find((t,n)=>{var s,i;t!==e.detail&&t.id!==(null!==(i=null===(s=e.detail)||void 0===s?void 0:s.id)&&void 0!==i?i:-1)||(r.asel.active_track=t,d(c,Asel.events.SWITCH,{selected_index:n}))})})),r.audioTracks&&(r.audioTracks.addEventListener("addtrack",(function(){r.hls||r.emit(e.TRACKS,Array.from(r.audioTracks))})),r.on(e.SET,(function(e){if(r.hls)return;const t=e.detail;u.active_track=t,t&&Array.from(r.audioTracks).forEach(e=>{e.enabled=t.id===e.id,e.enabled&&d(c,Asel.events.SWITCH,{selected_index:u.tracks.indexOf(t)})})})))}}
|
|
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.asel=t())}(this,(function(){"use strict";var e={SET:"audio:set",SWITCH:"audio:update",TRACKS:"audio:tracks"};function t(e,t,n){const s=function(e){return Array.isArray(e)?e.slice(0):e.split(".")}(t);for(;s.length;){if(null==e)return n;const t=s.shift();if("string"!=typeof t)return n;e=e[t]}return null==e?n:e}const n=navigator.languages||[navigator.language];function s(t,n){t.emit(e.SET,n),n.autoselect&&t._storage.setItem("@flowplayer/audio/track",n.lang)}function i(e){return e.toLowerCase()}function o(e,s,o){s=s.slice(0);const a={},r=e.getItem("@flowplayer/audio/track");let l=function(){try{return n.reduce((e,t)=>~t.indexOf("-")?e.concat(t,t.split("-")[0]):e.concat(t),[])}catch(e){return[]}}().map(i),c=-1;if("number"==typeof o)return o;for("string"==typeof o&&(o=o.toLowerCase(),~l.indexOf(o)&&l.splice(l.indexOf(o),1),l.unshift(i(o))),Array.isArray(o)&&(l=o.map(i));s.length;){++c;const e=s.shift();if(null==e?void 0:e.autoselect){if(r==e.lang)return console.debug("restoring lang from previous session: ",r),c;if(e.default&&(a.fallback=[c,e]),e.lang&&~l.indexOf(e.lang.toLowerCase())){const n=l.indexOf(e.lang);if(n<t(a,"by_lang.2",1/0)&&(a.by_lang=[c,e,n]),0===n)break}}}return t(a,"by_lang.0",t(a,"fallback.0",void 0))}const a=(e,t)=>new(((e,t)=>{const n=e.get(t);if(!n)throw new Error(`no flowplayer component with the name ${t} exists`);const s=window.customElements.get(t);if(!s)throw new Error(`no default flowplayer component with the name ${t} exists`);const i=window.customElements.get(n);return"function"!=typeof i?s:i})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}const r="fp-on",l="fp-invis";class FlowplayerMenu extends FlowplayerComponent{constructor(e){super(e),this.player=e,this.menuContainer=document.createElement("details"),this.summaryEle=document.createElement("summary"),this.menuHeader=document.createElement("div"),this.menuTitle=document.createElement("h3"),this.olEle=document.createElement("ol"),this.olEle.id=u(),this.menu=document.createElement("div"),this.closeEle=document.createElement("span"),this.menuHeader.classList.add("fp-menu-header"),this.menuHeader.append(this.menuTitle,this.closeEle),this.menu.classList.add("fp-menu"),this.menu.append(this.menuHeader,this.olEle),this.closeEle.classList.add("fp-close"),this.closeEle.textContent="×",this.menuContainer.classList.add("fp-menu-container"),this.menuContainer.append(this.summaryEle,this.menu),this.menuContainer.addEventListener("click",t=>{if(t.defaultPrevented)return;t.preventDefault();const n=this.menuContainer.open;n||(c(),document.active_menu=this.menuContainer),this.menuContainer.open=!n,e.root.classList.toggle("has-menu-opened",!n),this.summaryEle.setAttribute("aria-expanded",n?"false":"true")}),this.addEventListener("focusin",e=>{const t=e.target;t instanceof HTMLLIElement&&t.setAttribute("aria-selected","true")}),this.addEventListener("focusout",e=>{const t=e.target;t instanceof HTMLLIElement&&t.setAttribute("aria-selected","false")}),this.append(this.menuContainer),this.olEle.setAttribute("aria-labelledby",this.summaryEle.id),this.olEle.setAttribute("role","menu"),this.summaryEle.setAttribute("aria-haspopup","true"),this.summaryEle.setAttribute("aria-controls",this.olEle.id),this.summaryEle.setAttribute("tabindex","0"),this.summaryEle.setAttribute("aria-expanded","false"),this.summaryEle.setAttribute("role","button")}get options(){return this.olEle.querySelectorAll("li")}setMenuAttrs(e){if(this.className=e.class,this.toggle_visibility(!0),this.summaryEle.id||(this.summaryEle.id=e.id||u()),this.summaryEle.setAttribute("aria-label",e.menuTitle||"Menu"),e.summaryTitle&&(this.summaryEle.textContent=e.summaryTitle),e.summaryIcon){const t=a(this.player,e.summaryIcon);t.setAttribute("tabindex",""),this.summaryEle.append(t)}e.menuTitle&&(this.menuTitle.textContent=e.menuTitle),this.menu.classList.toggle("fp-icons",!!e.icons),this.addEventListener(e.options_event,e=>{this.render(e.data)}),e.item_selected_event&&this.addEventListener(e.item_selected_event,e=>{void 0!==e.data&&this.select_item(e.data.selected_index)})}render(e){this.olEle&&(this.olEle.innerHTML="",e&&e.forEach(this.menuOption,this),this.toggle_visibility(!(null==e?void 0:e.length)))}menuOption(e,t){const n=document.createElement("li");n.setAttribute("role","menuitem"),n.setAttribute("aria-selected","false"),n.setAttribute("tabindex","0"),e.icon&&n.append(e.icon);const s=document.createElement("span");s.textContent=e.text,n.append(s),n.addEventListener("click",()=>{this.select_item(t),"function"==typeof e.onclick&&e.onclick()}),this.olEle.appendChild(n),e.selected&&this.select_item(t)}select_item(e){this.options.forEach((t,n)=>{t.classList.toggle(r,n===e)})}unselect_item(){this.options.forEach(e=>{e.classList.remove(r)})}toggle_visibility(e){this.classList.toggle(l,e),this.menu.style.setProperty("display",e?"none":"flex")}}function c(){Array.from(document.querySelectorAll(".fp-engine")).forEach(e=>{var t;const n=e.root.querySelector("details[open].fp-menu-container");n&&(n.open=!1,null===(t=n.querySelector("summary"))||void 0===t||t.removeAttribute("aria-expanded"),e.root.classList.toggle("has-menu-opened",!1))})}function u(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function d(e,t,n){const s=function(e,t){const n=new CustomEvent(e,{detail:t,cancelable:!0});return t&&Object.defineProperty(n,"data",{get:()=>t}),n}(t,n);return e.dispatchEvent(s),e}document.addEventListener("click",(function(e){this.active_menu&&!e.composedPath().includes(this.active_menu)&&(c(),this.active_menu=void 0)})),function(){let e=!1;try{const t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("testPassive",null,t),window.removeEventListener("testPassive",null,t)}catch(e){}}();var m;const f=((m=class Asel{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-audio-menu",FlowplayerMenu)}init(n,i,r){if(!1===n.asel)return;let l=[];const c=a(r,"flowplayer-audio-menu");c instanceof FlowplayerMenu&&c.setMenuAttrs({summaryTitle:r.i18n("audio.button_txt"),menuTitle:r.i18n("audio.menu_title"),class:"fp-asel",options_event:Asel.events.TRACKS,item_selected_event:Asel.events.SWITCH});const u=function(t){const n={tracks:[],events:e};return Object.assign(n,{set:function(s){if(!("number"!=typeof s||s<0||s>n.tracks.length-1))return t.emit(e.SET,n.tracks[s]),n},get:function(e){if("number"==typeof e)return n.tracks[e]}}),n}(r);r.asel=u,r.on("mount",(function(){var e;null===(e=function(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}(r,r.hasState("is-tv")?"flowplayer-tv-menu":"flowplayer-control"))||void 0===e||e.append(c)})),r.on("src",()=>{u.tracks=[],u.active_track=void 0,d(c,Asel.events.TRACKS,[])}),r.on(e.TRACKS,(function(e){if(!Array.isArray(e.data)||e.data.length===l.length&&e.data.every((e,t)=>e===l[t]))return;l=e.data,u.tracks=l.slice();const i=t(n,"asel.sort");"function"==typeof i&&u.tracks.sort(i),d(c,Asel.events.TRACKS,Array.from({length:u.tracks.length}).map((e,t)=>{const n=u.tracks[t];return{text:n.name||n.label||n.lang,onclick:s.bind(0,r,n)}})),u.active_track=u.tracks.find(e=>e.enabled),u.active_track&&d(c,Asel.events.SWITCH,{selected_index:u.tracks.indexOf(u.active_track)});const a=o(r._storage,u.tracks,t(n,"asel.default_lang",!1));return c instanceof FlowplayerMenu&&c.toggle_visibility(e.data.length<2),void 0!==a?u.set(a):void 0})),r.on(e.SWITCH,(function(e){r.asel.tracks.find((t,n)=>{var s,i;t!==e.detail&&t.id!==(null!==(i=null===(s=e.detail)||void 0===s?void 0:s.id)&&void 0!==i?i:-1)||(r.asel.active_track=t,d(c,Asel.events.SWITCH,{selected_index:n}))})})),r.audioTracks&&(r.audioTracks.addEventListener("addtrack",(function(){r.hls||r.emit(e.TRACKS,Array.from(r.audioTracks))})),r.on(e.SET,(function(e){if(r.hls)return;const t=e.detail;u.active_track=t,t&&Array.from(r.audioTracks).forEach(e=>{e.enabled=t.id===e.id,e.enabled&&d(c,Asel.events.SWITCH,{selected_index:u.tracks.indexOf(t)})})})))}}).events={TRACKS:e.TRACKS,SWITCH:e.SWITCH},m);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,f)}));
|
package/plugins/audio.d.ts
CHANGED
|
@@ -5,6 +5,12 @@ infer Current,
|
|
|
5
5
|
...infer Remaining
|
|
6
6
|
] ? Current & ArrayToIntersection<Remaining> : unknown;
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
declare const AudioPlugin: PluginCtor<KeyValue, KeyValue>;
|
|
12
|
+
export default AudioPlugin;
|
|
13
|
+
|
|
8
14
|
declare type Autoplay = BitOpts | boolean;
|
|
9
15
|
|
|
10
16
|
declare enum AutoplayOpts {
|
|
@@ -78,9 +84,6 @@ declare interface Config {
|
|
|
78
84
|
|
|
79
85
|
declare type ConfigWith<T> = Config & T;
|
|
80
86
|
|
|
81
|
-
declare const _default: PluginCtor<KeyValue, KeyValue>;
|
|
82
|
-
export default _default;
|
|
83
|
-
|
|
84
87
|
declare type DeviceId = string;
|
|
85
88
|
|
|
86
89
|
declare type DRM_KEYSYSTEM = "com.widevine.alpha" | "com.microsoft.playready" | "org.w3.clearkey" | "com.apple.fps.1_0";
|
package/plugins/chapters.d.ts
CHANGED
|
@@ -15,6 +15,12 @@ declare enum AutoplayOpts {
|
|
|
15
15
|
|
|
16
16
|
declare type BitOpts = number;
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
declare const Chapters: PluginCtor<ChaptersConfig, KeyValue>;
|
|
22
|
+
export default Chapters;
|
|
23
|
+
|
|
18
24
|
declare type ChaptersConfig = ConfigWith<{
|
|
19
25
|
chapters?: ChaptersConfigurationObject | ChaptersConfigurationObject[];
|
|
20
26
|
}>;
|
|
@@ -87,9 +93,6 @@ declare interface Config {
|
|
|
87
93
|
|
|
88
94
|
declare type ConfigWith<T> = Config & T;
|
|
89
95
|
|
|
90
|
-
declare const _default: PluginCtor<ChaptersConfig, KeyValue>;
|
|
91
|
-
export default _default;
|
|
92
|
-
|
|
93
96
|
declare type DeviceId = string;
|
|
94
97
|
|
|
95
98
|
declare type DRM_KEYSYSTEM = "com.widevine.alpha" | "com.microsoft.playready" | "org.w3.clearkey" | "com.apple.fps.1_0";
|
package/plugins/chapters.js
CHANGED
|
@@ -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.chapters=t())}(this,(function(){"use strict";function e(){}var t;function n(e,n){if(function(e){return Object.values(t).includes(e)}(n=n||t.Anonymous))return e instanceof HTMLVideoElement&&(e.poster="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="),"crossOrigin"in e?e.crossOrigin=n:e.setAttribute("crossorigin",n),e}function r(e){const t=document.createElement("a");return t.href=e,t.origin}function i(t,i){const s=document.createElement("track");s.className="fp-track renderable",s.kind=i.kind||"captions",s.label=i.label||i.lang||"",s.lang=i.lang||"",s.id=["fp",i.lang].join("-");const o=s.track;return o.removeCue=e,"string"!=typeof i.crossorigin&&function(e,t){try{return e.src.startsWith("blob:"),r(e.src)!==r(t)}catch(e){return console.error(e),!0}}(t,i.src)&&(n(t),i.crossorigin=t.getAttribute("crossorigin")),"crossorigin"in i&&n(t,i.crossorigin),Object.keys(i).forEach(e=>{"default"!==e&&(s[e]=i[e])}),o.mode=i.default?"hidden":"disabled",t.appendChild(s),s}!function(e){e.Anonymous="anonymous",e.UseCredentials="use-credentials",e.Empty=""}(t||(t={}));var s=Object.freeze({__proto__:null,CHAPTER_CHANGED:"chapter:changed",CHAPTERS_NEW:"chapters:new"});function o(e,t,n){const r=function(e,t){const n=new CustomEvent(e,{detail:t,cancelable:!0});return t&&Object.defineProperty(n,"data",{get:()=>t}),n}(t,n);return e.dispatchEvent(r),e}function a(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}function c(...e){const t=document.createElement("div");return 0==e.length||t.classList.add(...e),t}!function(){let e=!1;try{const t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("testPassive",null,t),window.removeEventListener("testPassive",null,t)}catch(e){}}();const l="flowplayer-timeline-bar",u="is-source-processing";class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}document.addEventListener("click",(function(e){this.active_menu&&!e.composedPath().includes(this.active_menu)&&(Array.from(document.querySelectorAll(".fp-engine")).forEach(e=>{var t;const n=e.root.querySelector("details[open].fp-menu-container");n&&(n.open=!1,null===(t=n.querySelector("summary"))||void 0===t||t.removeAttribute("aria-expanded"),e.root.classList.toggle("has-menu-opened",!1))}),this.active_menu=void 0)}));const d={passive:!0};var h;function p(t,n){let r=0,i=-1,s=-1;const o=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5),a=t.classList;t.id=o,a.remove(h.GRABBING),a.remove(h.TOUCHING);const c=n.onseek||e,l=n.onstart||e,u=n.onend||e,p=n.onmouse||e,_=n.ontouch||e,v=n.ontouchend||e;function g(e){!function(){const e=t.getBoundingClientRect();r=e.left,i=e.width}();let n=(function(e){return"function"==typeof window.TouchEvent&&e instanceof TouchEvent}(e)?e.changedTouches[0].pageX:e.pageX)-r;return n>i&&(n=i),n<0&&(n=0),n/i*100}function y(e){const n=g(e);n!=s&&(c(t,n),s=n)}return t.addEventListener("touchstart",(function(e){f(t,e)&&(a.add(h.TOUCHING),m(t.parentElement)&&(a.add(h.GRABBING),_(t,g(e)),l(t,g(e)),y(e)))}),d),t.addEventListener("touchmove",(function(e){y(e),p(t,g(e))}),d),t.addEventListener("touchend",(function(e){setTimeout((function(){a.remove(h.TOUCHING)}),500),f(t,e)&&(a.remove(h.GRABBING),v(t,g(e)),u(t,g(e)),i=0)}),d),t.addEventListener("touchcancel",(function(){a.remove(h.GRABBING,h.TOUCHING),i=0}),d),t.addEventListener("mousedown",(function(e){a.contains(h.TOUCHING)||(document.addEventListener("mousemove",y),a.add(h.GRABBING),l(t,g(e)),e.preventDefault(),y(e))})),t.addEventListener("mousemove",(function(e){a.contains(h.TOUCHING)||p(t,g(e))})),document.addEventListener("mouseup",(function(e){a.contains(h.TOUCHING)||(document.removeEventListener("mousemove",y),a.contains(h.GRABBING)&&(a.remove(h.GRABBING),u(t,g(e)),i=0))})),t}function f(e,t){const n=t.target;return!!n&&(n&&!n.closest(e.id)||!m(e.parentElement)||!e.classList.contains(h.TOUCHING))}function m(e){if(!e)return!1;const t=window.getComputedStyle(e);return"0"!==t.width&&"0"!==t.height&&"0"!==t.opacity&&"none"!==t.display&&"hidden"!==t.visibility}function _(e){const t="number"==typeof e?e:parseInt(e,10);return(t>9?"":"0")+t}function v(e){if(isNaN(e)||e>=Number.MAX_SAFE_INTEGER)return"";const t=e<0?"-":"";e=Math.round(Math.abs(e));const n=Math.floor(e/3600);let r=Math.floor(e/60);return e-=60*r,n>=1?(r-=60*n,t+n+":"+_(r)+":"+_(e)):t+_(r)+":"+_(e)}function g(e,t){if(!e.parentElement)return;const n=e.clientWidth/e.parentElement.clientWidth*100/2;e.style.left=t-n+"%",e.style.display="block"}function y(e,t){if(isNaN(e.duration))return;const n=e.buffered;n.length&&(t.style.width=Math.min(n.end(n.length-1)/e.duration*100,100)+"%")}function E(e,t){e.style.width="0",t.style.display="none"}!function(e){e.GRABBING="has-grab",e.TOUCHING="has-touch"}(h||(h={}));function b(e,t){const n=e.seekable;if("object"!=typeof e.opts||0==n.length)return{head:0,tail:0};const r=function(e){var t;const n=e.seekable;return n.length?e.hasState("is-chromecast-playing")||!(null===(t=e.hls)||void 0===t?void 0:t.liveSyncPosition)?n.end(n.length-1):e.hls.liveSyncPosition:0}(e),i=t||e.live_state.dvr_window;return{head:r,tail:"number"!=typeof i||r-i<0?n.start(0):r-i}}function A(e,t,n){if(!t.seekable||0==t.seekable.length)return;g(n,e);const r=b(t),i=(100-Math.max(0,Math.min(e,100)))/100*(r.head-r.tail);n.innerText="-"+v(i)}function w(e,t){e/=100,t.currentTime=function(e,t){if(t>1||t<0)return console.warn("cannot calculate a percent outside of range(0..1)"),0;const n=b(e);return n.tail+t*(n.head-n.tail)}(t,e)}function k(e,t){e.style.width="0",t.style.display="none"}class FlowplayerTimelineBar extends FlowplayerComponent{constructor(e){let t;super(e),this.bufferEle=c("fp-buffer"),this.progress=c("fp-progress","fp-color"),this.tooltipEle=c("fp-timestamp"),this.proposedSeekBar=c("fp-hover"),this.dragger=c("fp-dragger","fp-color"),this.classList.add("fp-timeline","fp-bar"),this.tooltipEle.style.display="none",this.setAttribute("role","slider"),this.setAttribute("tabindex","0"),this.setAttribute("aria-label",e.i18n("core.timeline_aria_label","Seek slider")),this.setAttribute("aria-valuenow","0"),this.progress.append(this.dragger),this.append(this.bufferEle,this.progress,this.proposedSeekBar,this.tooltipEle);const n=requestAnimationFrame;let r=void 0;const i=()=>{var n;0==e.reaper||t.live||(n=e,this.progress.style.width=n.currentTime/n.duration*100+"%",r=void 0,e.paused||this.classList.contains(h.GRABBING)||r||(r=setTimeout(i,200)))},s=()=>!!this.player.opt("seekable",!0)&&!isNaN(this.player.duration);p(this,{onseek:(n,r)=>{if(s())switch(!!t.live){case!0:A(r,e,this.tooltipEle);break;case!1:!function(e,t,n){const r=t.duration*(e/100);if(t.disabled&&r>t.currentTime)return!1;n.style.width=e+"%",t.currentTime=r}(r,e,this.progress),g(this.tooltipEle,r)}},onstart:()=>{s()&&(e.emit("timeline/gesture/start"),!e.hasState("is-casting")&&e.setState("is-seeking",!0),t.live||function(e){e.style.display="block"}(this.tooltipEle))},onend:function(r,s){n(i),0!=t.seekable&&t.live&&w(s,e)},ontouchend:()=>{t.live?k(this.proposedSeekBar,this.tooltipEle):E(this.proposedSeekBar,this.tooltipEle),setTimeout(()=>e.emit("timeline/gesture/end"),0)},onmouse:(n,r)=>{if(s()&&(e.emit("timeline/gesture/move",{percent:r}),!this.classList.contains(h.GRABBING)))switch(!!t.live){case!0:!function(e,t){t.style.width=e+"%"}(r,this.proposedSeekBar),A(r,e,this.tooltipEle);break;case!1:!function(e,t){t.style.width=e+"%"}(r,this.proposedSeekBar),function(e,t,n){if(isNaN(e)||isNaN(t.duration))return;g(n,e),n.innerHTML="";const r=document.createElement("span");r.innerText=v(e/100*t.duration),n.append(r)}(r,e,this.tooltipEle)}}}),e.on("config",(function(e){e.data&&(t=e.data)})),e.on("playing",()=>n(i)),e.on("progress",()=>{0==e.reaper||t.live||y(e,this.bufferEle)}),e.on("dvr",e=>{this.progress.style.width=e.detail+"%"}),e.on("timeupdate",()=>{0!=e.reaper&&(n(i),this.setAttribute("aria-valuenow",e.currentTime+""),this.setAttribute("aria-valuetext",Math.round(e.currentTime)+" "+e.i18n("core.seconds","Seconds")),t.live||y(e,this.bufferEle))}),e.on("loadedmetadata",()=>{0!=e.reaper&&(t.live||y(e,this.bufferEle))}),e.on("durationchange",t=>{if(0==e.reaper)return;const n=function(e){return e.opt("live",!1)||e.duration>=Number.MAX_SAFE_INTEGER}(e)?function(e){return isFinite(e.duration)?e.duration:0==e.seekable.length?0:b(e).head}(e):t.data||e.duration;isNaN(n)||(this.setAttribute("aria-valuemax",n+""),this.setAttribute("aria-valuemin","0"))}),this.addEventListener("mouseleave",()=>{e.emit("timeline/gesture/end"),t.live?k(this.proposedSeekBar,this.tooltipEle):E(this.proposedSeekBar,this.tooltipEle)})}}class FlowplayerChaptersTimelineBar extends FlowplayerTimelineBar{constructor(e){super(e),this.handleChapters(e)}handleChapters(e){const t=document.createElement("div");let n;this.addEventListener("chapters:new",e=>{t.innerText="",this.querySelectorAll(".fp-chapter").forEach(e=>this.removeChild(e)),e.data&&e.data.forEach(e=>{const r=document.createElement("div");r.className="fp-chapter",r.style.left=e.left,r.style.bottom=r.style.top="0",r.style.width=e.width,r.title=e.title,r.onmouseover=()=>{t.innerText=e.title},r.onmouseleave=()=>{t.innerText=n||""},this.appendChild(r)})}),this.addEventListener("chapter:changed",r=>{var i;const s=r.data;s&&(t.parentNode||(null===(i=a(e,"flowplayer-control"))||void 0===i||i.insertAdjacentElement("beforebegin",t),t.classList.toggle("fp-togglable",!0),t.classList.toggle("fp-chapter-info",!0)),n=s,t.innerText=s)})}}class Chapters{constructor(t){this._track_added_handler=e,this._cue_changed_handler=e,this.chapters=[],this.render=this.render.bind(this),t.customElements.get(l)===l&&(((e,t,n)=>{window.customElements.get(t)||window.customElements.define(t,n),e.customElements.get(t)||e.customElements.set(t,t)})(t,"flowplayer-chapters-timeline-bar",FlowplayerChaptersTimelineBar),t.customElements.set(l,"flowplayer-chapters-timeline-bar"))}init(e,t,n){this._root=t,this._player=n,this._timeline=a(n,l),this._track_added_handler=this.track_added.bind(this,n),this._cue_changed_handler=this.cue_changed.bind(this,n),n.textTracks.addEventListener("addtrack",this._track_added_handler),this.wireup(n,e),n.chapters=this,n.on("config",e=>{e.data&&this.wireup(n,e.data)}),n.on(["playlist/advance","src"],e=>{n.currentSrc&&("src"===e.type&&["is-playlist",u].some(e=>n.root.classList.contains(e))||(this._current_chapters_src=void 0,delete n.opts.chapters,this.wiredown(n)))}),n.on("reap",()=>{this.wiredown(n),n.textTracks.removeEventListener("addtrack",this._track_added_handler),n.off("durationchange",this.render)}),n.on("durationchange",this.render)}track_added(e,t){}cue_changed(e,t){var n;this._current_chapters_track&&(this.current_cue=this._current_chapters_track.track.activeCues?this._current_chapters_track.track.activeCues[0]:void 0,this._timeline&&o(this._timeline,"chapter:changed",null===(n=this.current_cue)||void 0===n?void 0:n.text))}set_chapters(e){this.chapters=e,this.render()}jump(e){this._player&&this.chapters[e]&&(this._player.currentTime=this.chapters[e].start)}current(){if(this.current_cue)return this.chapters.find(e=>e.cue==this.current_cue)}render(){if(!this._root||!this._player||!this._timeline)return;const e=this._player.duration;isFinite(e)&&(o(this._timeline,"chapters:new",this.chapters.map(t=>({title:t.label,left:t.start/e*100+"%",width:(t.end-t.start)/e*100+"%"}))),this._root.classList.toggle("has-chapters",!!this.chapters.length))}wireup(e,t){const n=Array.isArray(t.chapters)?t.chapters[0]:t.chapters;n&&n.src!==this._current_chapters_src&&(this._current_chapters_track=i(e,Object.assign(Object.assign({},n),{kind:"chapters",default:!0})),this._current_chapters_track.onload=()=>{var e;(null===(e=this._current_chapters_track)||void 0===e?void 0:e.track.cues)&&this.set_chapters(Array.from(this._current_chapters_track.track.cues).filter(e=>e instanceof VTTCue).map(e=>{const t=e;return{start:e.startTime,end:e.endTime,cue:t,label:t.text}}))},this._current_chapters_src=n.src,this._current_chapters_track.addEventListener("cuechange",this._cue_changed_handler))}wiredown(e){this.set_chapters([]),this._current_chapters_track&&(this._current_chapters_track.removeEventListener("cuechange",this._cue_changed_handler),e.removeChild(this._current_chapters_track),this._current_chapters_track=void 0)}}return Chapters.events=s,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,Chapters)}));
|
|
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.chapters=t())}(this,(function(){"use strict";function e(){}var t;function n(e,n){if(function(e){return Object.values(t).includes(e)}(n=n||t.Anonymous))return e instanceof HTMLVideoElement&&(e.poster="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="),"crossOrigin"in e?e.crossOrigin=n:e.setAttribute("crossorigin",n),e}function r(e){const t=document.createElement("a");return t.href=e,t.origin}function i(t,i){const s=document.createElement("track");s.className="fp-track renderable",s.kind=i.kind||"captions",s.label=i.label||i.lang||"",s.lang=i.lang||"",s.id=["fp",i.lang].join("-");const o=s.track;return o.removeCue=e,"string"!=typeof i.crossorigin&&function(e,t){try{return e.src.startsWith("blob:"),r(e.src)!==r(t)}catch(e){return console.error(e),!0}}(t,i.src)&&(n(t),i.crossorigin=t.getAttribute("crossorigin")),"crossorigin"in i&&n(t,i.crossorigin),Object.keys(i).forEach(e=>{"default"!==e&&(s[e]=i[e])}),o.mode=i.default?"hidden":"disabled",t.appendChild(s),s}!function(e){e.Anonymous="anonymous",e.UseCredentials="use-credentials",e.Empty=""}(t||(t={}));var s=Object.freeze({__proto__:null,CHAPTER_CHANGED:"chapter:changed",CHAPTERS_NEW:"chapters:new"});function o(e,t,n){const r=function(e,t){const n=new CustomEvent(e,{detail:t,cancelable:!0});return t&&Object.defineProperty(n,"data",{get:()=>t}),n}(t,n);return e.dispatchEvent(r),e}function a(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}function c(...e){const t=document.createElement("div");return 0==e.length||t.classList.add(...e),t}!function(){let e=!1;try{const t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("testPassive",null,t),window.removeEventListener("testPassive",null,t)}catch(e){}}();const l="flowplayer-timeline-bar",u="is-source-processing";class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}document.addEventListener("click",(function(e){this.active_menu&&!e.composedPath().includes(this.active_menu)&&(Array.from(document.querySelectorAll(".fp-engine")).forEach(e=>{var t;const n=e.root.querySelector("details[open].fp-menu-container");n&&(n.open=!1,null===(t=n.querySelector("summary"))||void 0===t||t.removeAttribute("aria-expanded"),e.root.classList.toggle("has-menu-opened",!1))}),this.active_menu=void 0)}));const d={passive:!0};var h;function p(t,n){let r=0,i=-1,s=-1;const o=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5),a=t.classList;t.id=o,a.remove(h.GRABBING),a.remove(h.TOUCHING);const c=n.onseek||e,l=n.onstart||e,u=n.onend||e,p=n.onmouse||e,_=n.ontouch||e,v=n.ontouchend||e;function g(e){!function(){const e=t.getBoundingClientRect();r=e.left,i=e.width}();let n=(function(e){return"function"==typeof window.TouchEvent&&e instanceof TouchEvent}(e)?e.changedTouches[0].pageX:e.pageX)-r;return n>i&&(n=i),n<0&&(n=0),n/i*100}function y(e){const n=g(e);n!=s&&(c(t,n),s=n)}return t.addEventListener("touchstart",(function(e){f(t,e)&&(a.add(h.TOUCHING),m(t.parentElement)&&(a.add(h.GRABBING),_(t,g(e)),l(t,g(e)),y(e)))}),d),t.addEventListener("touchmove",(function(e){y(e),p(t,g(e))}),d),t.addEventListener("touchend",(function(e){setTimeout((function(){a.remove(h.TOUCHING)}),500),f(t,e)&&(a.remove(h.GRABBING),v(t,g(e)),u(t,g(e)),i=0)}),d),t.addEventListener("touchcancel",(function(){a.remove(h.GRABBING,h.TOUCHING),i=0}),d),t.addEventListener("mousedown",(function(e){a.contains(h.TOUCHING)||(document.addEventListener("mousemove",y),a.add(h.GRABBING),l(t,g(e)),e.preventDefault(),y(e))})),t.addEventListener("mousemove",(function(e){a.contains(h.TOUCHING)||p(t,g(e))})),document.addEventListener("mouseup",(function(e){a.contains(h.TOUCHING)||(document.removeEventListener("mousemove",y),a.contains(h.GRABBING)&&(a.remove(h.GRABBING),u(t,g(e)),i=0))})),t}function f(e,t){const n=t.target;return!!n&&(n&&!n.closest(e.id)||!m(e.parentElement)||!e.classList.contains(h.TOUCHING))}function m(e){if(!e)return!1;const t=window.getComputedStyle(e);return"0"!==t.width&&"0"!==t.height&&"0"!==t.opacity&&"none"!==t.display&&"hidden"!==t.visibility}function _(e){const t="number"==typeof e?e:parseInt(e,10);return(t>9?"":"0")+t}function v(e){if(isNaN(e)||e>=Number.MAX_SAFE_INTEGER)return"";const t=e<0?"-":"";e=Math.round(Math.abs(e));const n=Math.floor(e/3600);let r=Math.floor(e/60);return e-=60*r,n>=1?(r-=60*n,t+n+":"+_(r)+":"+_(e)):t+_(r)+":"+_(e)}function g(e,t){if(!e.parentElement)return;const n=e.clientWidth/e.parentElement.clientWidth*100/2;e.style.left=t-n+"%",e.style.display="block"}function y(e,t){if(isNaN(e.duration))return;const n=e.buffered;n.length&&(t.style.width=Math.min(n.end(n.length-1)/e.duration*100,100)+"%")}function E(e,t){e.style.width="0",t.style.display="none"}!function(e){e.GRABBING="has-grab",e.TOUCHING="has-touch"}(h||(h={}));function b(e,t){const n=e.seekable;if("object"!=typeof e.opts||0==n.length)return{head:0,tail:0};const r=function(e){var t;const n=e.seekable;return n.length?e.hasState("is-chromecast-playing")||!(null===(t=e.hls)||void 0===t?void 0:t.liveSyncPosition)?n.end(n.length-1):e.hls.liveSyncPosition:0}(e),i=t||e.live_state.dvr_window;return{head:r,tail:"number"!=typeof i||r-i<0?n.start(0):r-i}}function A(e,t,n){if(!t.seekable||0==t.seekable.length)return;g(n,e);const r=b(t),i=(100-Math.max(0,Math.min(e,100)))/100*(r.head-r.tail);n.innerText="-"+v(i)}function w(e,t){e/=100,t.currentTime=function(e,t){if(t>1||t<0)return console.warn("cannot calculate a percent outside of range(0..1)"),0;const n=b(e);return n.tail+t*(n.head-n.tail)}(t,e)}function k(e,t){e.style.width="0",t.style.display="none"}class FlowplayerTimelineBar extends FlowplayerComponent{constructor(e){let t;super(e),this.bufferEle=c("fp-buffer"),this.progress=c("fp-progress","fp-color"),this.tooltipEle=c("fp-timestamp"),this.proposedSeekBar=c("fp-hover"),this.dragger=c("fp-dragger","fp-color"),this.classList.add("fp-timeline","fp-bar"),this.tooltipEle.style.display="none",this.setAttribute("role","slider"),this.setAttribute("tabindex","0"),this.setAttribute("aria-label",e.i18n("core.timeline_aria_label","Seek slider")),this.setAttribute("aria-valuenow","0"),this.progress.append(this.dragger),this.append(this.bufferEle,this.progress,this.proposedSeekBar,this.tooltipEle);const n=requestAnimationFrame;let r=void 0;const i=()=>{var n;0==e.reaper||t.live||(n=e,this.progress.style.width=n.currentTime/n.duration*100+"%",r=void 0,e.paused||this.classList.contains(h.GRABBING)||r||(r=setTimeout(i,200)))},s=()=>!!this.player.opt("seekable",!0)&&!isNaN(this.player.duration);p(this,{onseek:(n,r)=>{if(s())switch(!!t.live){case!0:A(r,e,this.tooltipEle);break;case!1:!function(e,t,n){const r=t.duration*(e/100);if(t.disabled&&r>t.currentTime)return!1;n.style.width=e+"%",t.currentTime=r}(r,e,this.progress),g(this.tooltipEle,r)}},onstart:()=>{s()&&(e.emit("timeline/gesture/start"),!e.hasState("is-casting")&&e.setState("is-seeking",!0),t.live||function(e){e.style.display="block"}(this.tooltipEle))},onend:function(r,s){n(i),0!=t.seekable&&t.live&&w(s,e)},ontouchend:()=>{t.live?k(this.proposedSeekBar,this.tooltipEle):E(this.proposedSeekBar,this.tooltipEle),setTimeout(()=>e.emit("timeline/gesture/end"),0)},onmouse:(n,r)=>{if(s()&&(e.emit("timeline/gesture/move",{percent:r}),!this.classList.contains(h.GRABBING)))switch(!!t.live){case!0:!function(e,t){t.style.width=e+"%"}(r,this.proposedSeekBar),A(r,e,this.tooltipEle);break;case!1:!function(e,t){t.style.width=e+"%"}(r,this.proposedSeekBar),function(e,t,n){if(isNaN(e)||isNaN(t.duration))return;g(n,e),n.innerHTML="";const r=document.createElement("span");r.innerText=v(e/100*t.duration),n.append(r)}(r,e,this.tooltipEle)}}}),e.on("config",(function(e){e.data&&(t=e.data)})),e.on("playing",()=>n(i)),e.on("progress",()=>{0==e.reaper||t.live||y(e,this.bufferEle)}),e.on("dvr",e=>{this.progress.style.width=e.detail+"%"}),e.on("timeupdate",()=>{0!=e.reaper&&(n(i),this.setAttribute("aria-valuenow",e.currentTime+""),this.setAttribute("aria-valuetext",Math.round(e.currentTime)+" "+e.i18n("core.seconds","Seconds")),t.live||y(e,this.bufferEle))}),e.on("loadedmetadata",()=>{0!=e.reaper&&(t.live||y(e,this.bufferEle))}),e.on("durationchange",t=>{if(0==e.reaper)return;const n=function(e){return e.opt("live",!1)||e.duration>=Number.MAX_SAFE_INTEGER}(e)?function(e){return isFinite(e.duration)?e.duration:0==e.seekable.length?0:b(e).head}(e):t.data||e.duration;isNaN(n)||(this.setAttribute("aria-valuemax",n+""),this.setAttribute("aria-valuemin","0"))}),this.addEventListener("mouseleave",()=>{e.emit("timeline/gesture/end"),t.live?k(this.proposedSeekBar,this.tooltipEle):E(this.proposedSeekBar,this.tooltipEle)})}}class FlowplayerChaptersTimelineBar extends FlowplayerTimelineBar{constructor(e){super(e),this.handleChapters(e)}handleChapters(e){const t=document.createElement("div");let n;this.addEventListener("chapters:new",e=>{t.innerText="",this.querySelectorAll(".fp-chapter").forEach(e=>this.removeChild(e)),e.data&&e.data.forEach(e=>{const r=document.createElement("div");r.className="fp-chapter",r.style.left=e.left,r.style.bottom=r.style.top="0",r.style.width=e.width,r.title=e.title,r.onmouseover=()=>{t.innerText=e.title},r.onmouseleave=()=>{t.innerText=n||""},this.appendChild(r)})}),this.addEventListener("chapter:changed",r=>{var i;const s=r.data;s&&(t.parentNode||(null===(i=a(e,"flowplayer-control"))||void 0===i||i.insertAdjacentElement("beforebegin",t),t.classList.toggle("fp-togglable",!0),t.classList.toggle("fp-chapter-info",!0)),n=s,t.innerText=s)})}}var T;const N=((T=class Chapters{constructor(t){this._track_added_handler=e,this._cue_changed_handler=e,this.chapters=[],this.render=this.render.bind(this),t.customElements.get(l)===l&&(((e,t,n)=>{window.customElements.get(t)||window.customElements.define(t,n),e.customElements.get(t)||e.customElements.set(t,t)})(t,"flowplayer-chapters-timeline-bar",FlowplayerChaptersTimelineBar),t.customElements.set(l,"flowplayer-chapters-timeline-bar"))}init(e,t,n){this._root=t,this._player=n,this._timeline=a(n,l),this._track_added_handler=this.track_added.bind(this,n),this._cue_changed_handler=this.cue_changed.bind(this,n),n.textTracks.addEventListener("addtrack",this._track_added_handler),this.wireup(n,e),n.chapters=this,n.on("config",e=>{e.data&&this.wireup(n,e.data)}),n.on(["playlist/advance","src"],e=>{n.currentSrc&&("src"===e.type&&["is-playlist",u].some(e=>n.root.classList.contains(e))||(this._current_chapters_src=void 0,delete n.opts.chapters,this.wiredown(n)))}),n.on("reap",()=>{this.wiredown(n),n.textTracks.removeEventListener("addtrack",this._track_added_handler),n.off("durationchange",this.render)}),n.on("durationchange",this.render)}track_added(e,t){}cue_changed(e,t){var n;this._current_chapters_track&&(this.current_cue=this._current_chapters_track.track.activeCues?this._current_chapters_track.track.activeCues[0]:void 0,this._timeline&&o(this._timeline,"chapter:changed",null===(n=this.current_cue)||void 0===n?void 0:n.text))}set_chapters(e){this.chapters=e,this.render()}jump(e){this._player&&this.chapters[e]&&(this._player.currentTime=this.chapters[e].start)}current(){if(this.current_cue)return this.chapters.find(e=>e.cue==this.current_cue)}render(){if(!this._root||!this._player||!this._timeline)return;const e=this._player.duration;isFinite(e)&&(o(this._timeline,"chapters:new",this.chapters.map(t=>({title:t.label,left:t.start/e*100+"%",width:(t.end-t.start)/e*100+"%"}))),this._root.classList.toggle("has-chapters",!!this.chapters.length))}wireup(e,t){const n=Array.isArray(t.chapters)?t.chapters[0]:t.chapters;n&&n.src!==this._current_chapters_src&&(this._current_chapters_track=i(e,Object.assign(Object.assign({},n),{kind:"chapters",default:!0})),this._current_chapters_track.onload=()=>{var e;(null===(e=this._current_chapters_track)||void 0===e?void 0:e.track.cues)&&this.set_chapters(Array.from(this._current_chapters_track.track.cues).filter(e=>e instanceof VTTCue).map(e=>{const t=e;return{start:e.startTime,end:e.endTime,cue:t,label:t.text}}))},this._current_chapters_src=n.src,this._current_chapters_track.addEventListener("cuechange",this._cue_changed_handler))}wiredown(e){this.set_chapters([]),this._current_chapters_track&&(this._current_chapters_track.removeEventListener("cuechange",this._cue_changed_handler),e.removeChild(this._current_chapters_track),this._current_chapters_track=void 0)}}).events=s,T);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,N)}));
|
package/plugins/chromecast.d.ts
CHANGED
|
@@ -15,6 +15,12 @@ declare enum AutoplayOpts {
|
|
|
15
15
|
|
|
16
16
|
declare type BitOpts = number;
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
declare const Chromecast: PluginCtor<KeyValue, KeyValue>;
|
|
22
|
+
export default Chromecast;
|
|
23
|
+
|
|
18
24
|
declare type Component = {
|
|
19
25
|
onrender?: (config: Config, root: PlayerRoot, player: Player) => void;
|
|
20
26
|
onremove?: (config: Config, root: PlayerRoot, player: Player) => void;
|
|
@@ -78,9 +84,6 @@ declare interface Config {
|
|
|
78
84
|
|
|
79
85
|
declare type ConfigWith<T> = Config & T;
|
|
80
86
|
|
|
81
|
-
declare const _default: PluginCtor<KeyValue, KeyValue>;
|
|
82
|
-
export default _default;
|
|
83
|
-
|
|
84
87
|
declare type DeviceId = string;
|
|
85
88
|
|
|
86
89
|
declare type DRM_KEYSYSTEM = "com.widevine.alpha" | "com.microsoft.playready" | "org.w3.clearkey" | "com.apple.fps.1_0";
|
package/plugins/chromecast.js
CHANGED
|
@@ -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 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)}}ChromecastPlugin.apps=U,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)}));
|
package/plugins/comscore.d.ts
CHANGED
|
@@ -26,6 +26,12 @@ declare interface Components {
|
|
|
26
26
|
put(key: string, args: Component): void;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
declare const Comscore: PluginCtor<KeyValue, KeyValue>;
|
|
33
|
+
export default Comscore;
|
|
34
|
+
|
|
29
35
|
declare interface Config {
|
|
30
36
|
src?: UnsafeSource;
|
|
31
37
|
preload?: "none" | "metadata" | "auto";
|
|
@@ -78,9 +84,6 @@ declare interface Config {
|
|
|
78
84
|
|
|
79
85
|
declare type ConfigWith<T> = Config & T;
|
|
80
86
|
|
|
81
|
-
declare const _default: PluginCtor<KeyValue, KeyValue>;
|
|
82
|
-
export default _default;
|
|
83
|
-
|
|
84
87
|
declare type DeviceId = string;
|
|
85
88
|
|
|
86
89
|
declare type DRM_KEYSYSTEM = "com.widevine.alpha" | "com.microsoft.playready" | "org.w3.clearkey" | "com.apple.fps.1_0";
|
package/plugins/consent.d.ts
CHANGED
|
@@ -78,8 +78,11 @@ declare interface Config {
|
|
|
78
78
|
|
|
79
79
|
declare type ConfigWith<T> = Config & T;
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
/**
|
|
82
|
+
* @public
|
|
83
|
+
*/
|
|
84
|
+
declare const Consent: PluginCtor<KeyValue, KeyValue>;
|
|
85
|
+
export default Consent;
|
|
83
86
|
|
|
84
87
|
declare type DeviceId = string;
|
|
85
88
|
|
package/plugins/consent.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((t="undefined"!=typeof globalThis?globalThis:t||self).flowplayer=t.flowplayer||{},t.flowplayer.consent=e())}(this,(function(){"use strict";class PlayerStorage{constructor(t,e){this.implementation=t,e&&e.keys().forEach(t=>{"string"==typeof e.implementation[t]&&this.implementation.setItem(t,e.implementation[t])})}keys(){var t;const e=[];for(var n=0;n<this.implementation.length;n++)(null===(t=this.implementation.key(n))||void 0===t?void 0:t.startsWith("flowplayer/"))&&e.push(this.implementation.key(n));return e}removeItem(t){try{this.implementation.removeItem("flowplayer/"+t)}catch(t){}}getItem(t){try{return this.implementation.getItem("flowplayer/"+t)}catch(t){return null}}setItem(t,e){try{this.implementation.setItem("flowplayer/"+t,e)}catch(t){}}clear(){try{this.keys().forEach(t=>this.implementation.removeItem(t))}catch(t){}}get length(){try{return this.keys().length}catch(t){return 0}}key(t){try{return this.implementation.key(t)}catch(t){return null}}}var t,e;!function(t){t[t.ALL=1]="ALL",t[t.NONE=2]="NONE"}(
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((t="undefined"!=typeof globalThis?globalThis:t||self).flowplayer=t.flowplayer||{},t.flowplayer.consent=e())}(this,(function(){"use strict";class PlayerStorage{constructor(t,e){this.implementation=t,e&&e.keys().forEach(t=>{"string"==typeof e.implementation[t]&&this.implementation.setItem(t,e.implementation[t])})}keys(){var t;const e=[];for(var n=0;n<this.implementation.length;n++)(null===(t=this.implementation.key(n))||void 0===t?void 0:t.startsWith("flowplayer/"))&&e.push(this.implementation.key(n));return e}removeItem(t){try{this.implementation.removeItem("flowplayer/"+t)}catch(t){}}getItem(t){try{return this.implementation.getItem("flowplayer/"+t)}catch(t){return null}}setItem(t,e){try{this.implementation.setItem("flowplayer/"+t,e)}catch(t){}}clear(){try{this.keys().forEach(t=>this.implementation.removeItem(t))}catch(t){}}get length(){try{return this.keys().length}catch(t){return 0}}key(t){try{return this.implementation.key(t)}catch(t){return null}}}var t,e,n;!function(t){t[t.ALL=1]="ALL",t[t.NONE=2]="NONE"}(e||(e={})),function(t){t[t.ALL=8]="ALL",t[t.NONE=16]="NONE"}(n||(n={}));const s=((t=class ConsentPlugin{constructor(t,s){const o=s._storage.getItem("consent"),r=this.current_value=o&&!isNaN(Number(o))?Number(s._storage.getItem("consent")):e.NONE|n.NONE;this.player=s,this.adapt(Object.assign({consent:r},s.opts))}init(t,e,n){this.adapt(t),n.on("config",t=>{this.adapt(t.detail)});const s=t=>{n.setOpts({consent:t.detail})};document.addEventListener("flowplayer/consent",s),n.on("reap",()=>document.removeEventListener("flowplayer/consent",s))}adapt(t){const s=void 0===t.consent?this.current_value:t.consent;n.ALL&s?this.setStorage(n.ALL):n.NONE&s&&this.setStorage(n.NONE),e.ALL&s?this.setTracking(e.ALL):e.NONE&s&&this.setTracking(e.NONE),this.player._storage.setItem("consent",s.toString())}setStorage(t){try{const e=this.player._storage;switch(this.player.setState("consent-no-storage",t===n.NONE),t){case n.ALL:this.player._storage=new PlayerStorage(localStorage,this.player._storage);break;case n.NONE:this.player._storage=new PlayerStorage(sessionStorage,e),e.clear()}}catch(t){console.debug(t)}}setTracking(t){var n,s;switch(this.player.setState("consent-no-tracking",t===e.NONE),t){case e.ALL:null===(n=this.player.health)||void 0===n||n.toggle(!0);break;case e.NONE:null===(s=this.player.health)||void 0===s||s.toggle(!1)}}}).tracking=e,t.storage=n,t);return function(t,e){if("object"==typeof exports&&"undefined"!=typeof module)return e;if(null===document.currentScript)return e;"flowplayer"in t||(t.flowplayer={extensions:[]});const n=t.flowplayer;return"function"==typeof n?(n(e),e):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(e)||n.extensions.push(e),e)}(window,s)}));
|
|
@@ -78,6 +78,12 @@ declare interface Config {
|
|
|
78
78
|
|
|
79
79
|
declare type ConfigWith<T> = Config & T;
|
|
80
80
|
|
|
81
|
+
/**
|
|
82
|
+
* @public
|
|
83
|
+
*/
|
|
84
|
+
declare const ContextMenu: PluginCtor<ContextMenuConfig, KeyValue>;
|
|
85
|
+
export default ContextMenu;
|
|
86
|
+
|
|
81
87
|
/**
|
|
82
88
|
* @public
|
|
83
89
|
*/
|
|
@@ -85,9 +91,6 @@ export declare type ContextMenuConfig = {
|
|
|
85
91
|
context_menu?: LinkOpts[];
|
|
86
92
|
};
|
|
87
93
|
|
|
88
|
-
declare const _default: PluginCtor<ContextMenuConfig, KeyValue>;
|
|
89
|
-
export default _default;
|
|
90
|
-
|
|
91
94
|
declare type DeviceId = string;
|
|
92
95
|
|
|
93
96
|
declare type DRM_KEYSYSTEM = "com.widevine.alpha" | "com.microsoft.playready" | "org.w3.clearkey" | "com.apple.fps.1_0";
|
package/plugins/cuepoints.d.ts
CHANGED
|
@@ -93,6 +93,12 @@ export declare type CueAttrs = {
|
|
|
93
93
|
*/
|
|
94
94
|
export declare type CuepointList = Array<CueAttrs>;
|
|
95
95
|
|
|
96
|
+
/**
|
|
97
|
+
* @public
|
|
98
|
+
*/
|
|
99
|
+
declare const Cuepoints: PluginCtor<CuepointsConfig, KeyValue>;
|
|
100
|
+
export default Cuepoints;
|
|
101
|
+
|
|
96
102
|
/**
|
|
97
103
|
* @public
|
|
98
104
|
*/
|
|
@@ -101,9 +107,6 @@ export declare type CuepointsConfig = {
|
|
|
101
107
|
draw_cuepoints?: boolean;
|
|
102
108
|
};
|
|
103
109
|
|
|
104
|
-
declare const _default: PluginCtor<CuepointsConfig, KeyValue>;
|
|
105
|
-
export default _default;
|
|
106
|
-
|
|
107
110
|
declare type DeviceId = string;
|
|
108
111
|
|
|
109
112
|
declare type DRM_KEYSYSTEM = "com.widevine.alpha" | "com.microsoft.playready" | "org.w3.clearkey" | "com.apple.fps.1_0";
|
package/plugins/cuepoints.js
CHANGED
|
@@ -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.cuepoints=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 o=window.customElements.get(t);if(!o)throw new Error(`no default flowplayer component with the name ${t} exists`);const r=window.customElements.get(n);return"function"!=typeof r?o:r})(e._customElements,t))(e);function t(e,t,n){const o=function(e,t){const n=new CustomEvent(e,{detail:t,cancelable:!0});return t&&Object.defineProperty(n,"data",{get:()=>t}),n}(t,n);return e.dispatchEvent(o),e}function n(e){const t=e._customElements.get("flowplayer-cue");t&&Array.from(e.root.querySelectorAll(t)).forEach(e=>{e.remove()})}function o(n,o){var r;const i=function(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}(n,"flowplayer-timeline-bar"),s=n.duration,
|
|
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.cuepoints=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 o=window.customElements.get(t);if(!o)throw new Error(`no default flowplayer component with the name ${t} exists`);const r=window.customElements.get(n);return"function"!=typeof r?o:r})(e._customElements,t))(e);function t(e,t,n){const o=function(e,t){const n=new CustomEvent(e,{detail:t,cancelable:!0});return t&&Object.defineProperty(n,"data",{get:()=>t}),n}(t,n);return e.dispatchEvent(o),e}function n(e){const t=e._customElements.get("flowplayer-cue");t&&Array.from(e.root.querySelectorAll(t)).forEach(e=>{e.remove()})}function o(n,o){var r;const i=function(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}(n,"flowplayer-timeline-bar"),s=n.duration,c=null===(r=null==n?void 0:n.opts)||void 0===r?void 0:r.draw_cuepoints;i&&!n.hasState("is-live")&&isFinite(s)&&Array.isArray(o)&&c&&o.forEach(o=>{if(void 0===o.startTime||o.startTime<0||!o.endTime||o.startTime===o.endTime)return;const r=Math.round(o.startTime/s*1e3)/10;if(r>100||r<0)return;const c=o.endTime-o.startTime,u=e(n,"flowplayer-cue");t(u,"cue:attributes",{left:r+"%",width:c/s*100+"%"}),i.append(u)})}!function(){let e=!1;try{const t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("testPassive",null,t),window.removeEventListener("testPassive",null,t)}catch(e){}}();class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}class CueComponent extends FlowplayerComponent{constructor(e){super(e),this.className="fp-cuepoint",this.addEventListener("cue:attributes",e=>{this.style.setProperty("left",e.detail.left),this.style.setProperty("width",e.detail.width)})}}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,class Cuepoints{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-cue",CueComponent)}init(e,t,r){if(!r.reaper)return;const i=r.addTextTrack("metadata","fp-cuepoints");i.removeCue=function(e){this===Cuepoints&&TextTrack.prototype.removeCue.call(i,e)},r.reaper.set("cuepoints",[]),r.on("config",(function(t){var n;if(!r.reaper)return;(null===(n=t.data)||void 0===n?void 0:n.cuepoints)!==r.reaper.get("cuepoints")&&r.emit("cuepoints",{cuepoints:e.cuepoints})})),r.on("durationchange",()=>{r.reaper&&(n(r),o(r,r.reaper.get("cuepoints")))}),r.on("cuepoints",e=>{var t;if(!r.reaper)return;const s=(null===(t=e.data)||void 0===t?void 0:t.cuepoints)||[];r.reaper.set("cuepoints",s),Array.from(i.cues||{length:0}).forEach(e=>i.removeCue.call(this.constructor,e)),n(r),s.map((function(e){return function(e,t){try{const n=new VTTCue(t.startTime,t.endTime,t.text||"");return n.id=t.id||"",n.onenter=e.emit.bind(e,"cuepointstart",{cuepoint:t}),n.onexit=e.emit.bind(e,"cuepointend",{cuepoint:t}),n}catch(e){if(t.startTime===t.endTime)return console.warn("Cue(:error)> startTime cannot equal endTime on this platform");throw e}}(r,e)})).forEach((function(e){e&&i.addCue(e)})),o(r,s)})}})}));
|
package/plugins/dash.d.ts
CHANGED
|
@@ -94,7 +94,11 @@ declare interface Config {
|
|
|
94
94
|
|
|
95
95
|
declare type ConfigWith<T> = Config & T;
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
/**
|
|
98
|
+
* @public
|
|
99
|
+
*/
|
|
100
|
+
declare const Dash: PluginCtor<DashConfig, DashPlayerAPI> & DashAPI;
|
|
101
|
+
export default Dash;
|
|
98
102
|
|
|
99
103
|
/**
|
|
100
104
|
* @public
|
|
@@ -133,6 +137,7 @@ export declare type DashConfig = {
|
|
|
133
137
|
*/
|
|
134
138
|
export declare type DashEvents = typeof allEvents;
|
|
135
139
|
|
|
140
|
+
/* Excluded from this release type: DashInstance */
|
|
136
141
|
export { DashJS }
|
|
137
142
|
|
|
138
143
|
/* Excluded from this release type: DashPlayer */
|
|
@@ -147,9 +152,6 @@ export declare type DashPlayerAPI = {
|
|
|
147
152
|
|
|
148
153
|
/* Excluded from this release type: DashSettings */
|
|
149
154
|
|
|
150
|
-
declare const _default: PluginCtor<DashConfig, DashPlayerAPI> & DashAPI;
|
|
151
|
-
export default _default;
|
|
152
|
-
|
|
153
155
|
declare type DeviceId = string;
|
|
154
156
|
|
|
155
157
|
declare type DRM_KEYSYSTEM = "com.widevine.alpha" | "com.microsoft.playready" | "org.w3.clearkey" | "com.apple.fps.1_0";
|