@flowplayer/player 3.13.1-rc.0 → 3.14.0-rc
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/events.d.ts +21 -3
- package/core/events.js +57 -2
- package/core.js +1 -1
- package/default.js +1 -1
- package/embed.js +2 -2
- package/flowplayer.css +1 -1
- package/index.d.ts +6 -3
- package/package.json +13 -2
- package/plugins/ads.d.ts +6 -3
- package/plugins/ads.js +2 -2
- package/plugins/airplay.d.ts +31 -4
- package/plugins/airplay.js +1 -1
- package/plugins/analytics.d.ts +6 -3
- package/plugins/analytics.js +1 -1
- package/plugins/asel.d.ts +7 -4
- package/plugins/audio.d.ts +6 -3
- package/plugins/chapters.d.ts +11 -6
- package/plugins/chromecast.d.ts +6 -3
- package/plugins/comscore.d.ts +6 -3
- package/plugins/consent.d.ts +6 -3
- package/plugins/context-menu.d.ts +6 -3
- package/plugins/cuepoints.d.ts +12 -3
- package/plugins/dash.d.ts +6 -3
- package/plugins/drm.d.ts +6 -3
- package/plugins/endscreen.d.ts +24 -4
- package/plugins/fas.d.ts +6 -3
- package/plugins/float-on-scroll.d.ts +9 -3
- package/plugins/ga4.d.ts +6 -3
- package/plugins/gemius.d.ts +9 -3
- package/plugins/google-analytics.d.ts +6 -3
- package/plugins/health.d.ts +12 -3
- package/plugins/health.js +1 -1
- package/plugins/hls.d.ts +11 -5
- package/plugins/id3.d.ts +6 -3
- package/plugins/iframe.d.ts +7 -3
- package/plugins/keyboard.d.ts +6 -3
- package/plugins/media-session.d.ts +6 -3
- package/plugins/message.d.ts +6 -3
- package/plugins/ovp.d.ts +59 -5
- package/plugins/ovp.js +1 -1
- package/plugins/playlist.d.ts +6 -3
- package/plugins/preview.d.ts +6 -3
- package/plugins/qsel.d.ts +6 -3
- package/plugins/qul.d.ts +6 -3
- package/plugins/rts.d.ts +6 -3
- package/plugins/share.d.ts +6 -3
- package/plugins/speed.d.ts +6 -3
- package/plugins/ssai.d.ts +8 -5
- package/plugins/ssai.js +1 -1
- package/plugins/subtitles.d.ts +157 -8
- package/plugins/subtitles.js +1 -1
- package/plugins/thumbnails.d.ts +6 -3
- package/plugins/tizen.d.ts +6 -3
- package/plugins/vtsel.d.ts +6 -3
- package/plugins/webos.d.ts +6 -3
- package/util/loader.d.ts +6 -3
- package/util/loader.js +1 -0
package/plugins/rts.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { MediaKeyFunc } from 'hls.js';
|
|
2
2
|
|
|
3
|
-
declare type ArrayToIntersection<T extends Array<unknown>> = T extends [
|
|
3
|
+
declare type ArrayToIntersection<T extends Array<unknown>> = T extends [
|
|
4
|
+
infer Current,
|
|
5
|
+
...infer Remaining
|
|
6
|
+
] ? Current & ArrayToIntersection<Remaining> : unknown;
|
|
4
7
|
|
|
5
8
|
declare type Autoplay = BitOpts | boolean;
|
|
6
9
|
|
|
@@ -225,11 +228,11 @@ declare type PlayerState = string;
|
|
|
225
228
|
|
|
226
229
|
declare type PlayerWith<T> = T & Player;
|
|
227
230
|
|
|
228
|
-
declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue,
|
|
231
|
+
declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
|
|
229
232
|
/**
|
|
230
233
|
* a plugin must always implement the init method so a player instance knows how to initialize it
|
|
231
234
|
*/
|
|
232
|
-
init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player:
|
|
235
|
+
init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player: PlayerWith<PluginPlayerAPIExtension>): void;
|
|
233
236
|
}
|
|
234
237
|
|
|
235
238
|
declare interface PluginCtor<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
|
package/plugins/share.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { MediaKeyFunc } from 'hls.js';
|
|
2
2
|
|
|
3
|
-
declare type ArrayToIntersection<T extends Array<unknown>> = T extends [
|
|
3
|
+
declare type ArrayToIntersection<T extends Array<unknown>> = T extends [
|
|
4
|
+
infer Current,
|
|
5
|
+
...infer Remaining
|
|
6
|
+
] ? Current & ArrayToIntersection<Remaining> : unknown;
|
|
4
7
|
|
|
5
8
|
declare type Autoplay = BitOpts | boolean;
|
|
6
9
|
|
|
@@ -225,11 +228,11 @@ declare type PlayerState = string;
|
|
|
225
228
|
|
|
226
229
|
declare type PlayerWith<T> = T & Player;
|
|
227
230
|
|
|
228
|
-
declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue,
|
|
231
|
+
declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
|
|
229
232
|
/**
|
|
230
233
|
* a plugin must always implement the init method so a player instance knows how to initialize it
|
|
231
234
|
*/
|
|
232
|
-
init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player:
|
|
235
|
+
init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player: PlayerWith<PluginPlayerAPIExtension>): void;
|
|
233
236
|
}
|
|
234
237
|
|
|
235
238
|
declare interface PluginCtor<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
|
package/plugins/speed.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { MediaKeyFunc } from 'hls.js';
|
|
2
2
|
|
|
3
|
-
declare type ArrayToIntersection<T extends Array<unknown>> = T extends [
|
|
3
|
+
declare type ArrayToIntersection<T extends Array<unknown>> = T extends [
|
|
4
|
+
infer Current,
|
|
5
|
+
...infer Remaining
|
|
6
|
+
] ? Current & ArrayToIntersection<Remaining> : unknown;
|
|
4
7
|
|
|
5
8
|
declare type Autoplay = BitOpts | boolean;
|
|
6
9
|
|
|
@@ -225,11 +228,11 @@ declare type PlayerState = string;
|
|
|
225
228
|
|
|
226
229
|
declare type PlayerWith<T> = T & Player;
|
|
227
230
|
|
|
228
|
-
declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue,
|
|
231
|
+
declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
|
|
229
232
|
/**
|
|
230
233
|
* a plugin must always implement the init method so a player instance knows how to initialize it
|
|
231
234
|
*/
|
|
232
|
-
init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player:
|
|
235
|
+
init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player: PlayerWith<PluginPlayerAPIExtension>): void;
|
|
233
236
|
}
|
|
234
237
|
|
|
235
238
|
declare interface PluginCtor<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
|
package/plugins/ssai.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Ad } from './dai/google.dai';
|
|
1
|
+
import type { Ad } from './dai/google.dai';
|
|
2
2
|
import type { MediaKeyFunc } from 'hls.js';
|
|
3
|
-
import { StreamData } from './dai/google.dai';
|
|
3
|
+
import type { StreamData } from './dai/google.dai';
|
|
4
4
|
|
|
5
5
|
/* Excluded from this release type: AdEvent */
|
|
6
6
|
|
|
@@ -15,7 +15,10 @@ declare enum AdType {
|
|
|
15
15
|
Postroll = "postroll"
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
declare type ArrayToIntersection<T extends Array<unknown>> = T extends [
|
|
18
|
+
declare type ArrayToIntersection<T extends Array<unknown>> = T extends [
|
|
19
|
+
infer Current,
|
|
20
|
+
...infer Remaining
|
|
21
|
+
] ? Current & ArrayToIntersection<Remaining> : unknown;
|
|
19
22
|
|
|
20
23
|
declare type Autoplay = BitOpts | boolean;
|
|
21
24
|
|
|
@@ -240,11 +243,11 @@ declare type PlayerState = string;
|
|
|
240
243
|
|
|
241
244
|
declare type PlayerWith<T> = T & Player;
|
|
242
245
|
|
|
243
|
-
declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue,
|
|
246
|
+
declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
|
|
244
247
|
/**
|
|
245
248
|
* a plugin must always implement the init method so a player instance knows how to initialize it
|
|
246
249
|
*/
|
|
247
|
-
init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player:
|
|
250
|
+
init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player: PlayerWith<PluginPlayerAPIExtension>): void;
|
|
248
251
|
}
|
|
249
252
|
|
|
250
253
|
declare interface PluginCtor<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
|
package/plugins/ssai.js
CHANGED
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* https://github.com/lancedikson/bowser
|
|
5
5
|
* MIT License | (c) Dustin Diaz 2012-2015
|
|
6
6
|
* MIT License | (c) Denis Demchenko 2015-2019
|
|
7
|
-
*/const S=class Bowser{static getParser(e,t=!1){if("string"!=typeof e)throw new Error("UserAgent should be a string");return new Parser(e,t)}static parse(e){return new Parser(e).getResult()}static get BROWSER_MAP(){return u}static get ENGINE_MAP(){return g}static get OS_MAP(){return m}static get PLATFORMS_MAP(){return p}}.parse(window.navigator.userAgent),{platform:w,os:_,browser:M}=S,A=e=>e&&e.toLowerCase();var E={rnd:Math.random().toString(36).substr(2,32),os:A(_.name+(_.versionName?" "+_.versionName:"")),device:A(w.type),browser:A(M.name),browser_version:(M&&M.version?M.version:"unknown").split(".").shift(),plugin_version:"3.13.1-rc.0"};const k="https://fp-eu-w1-aai.flowplayer.com/in",U="POST",T=["ad-requested","ad-request-error","ad-request-completed","ad-completed","ad-started","ad-error","ad-skipped"],R=["event_type","ad_tag_id","media_id","player_id","site_id","sitegroup_id","rnd","os","device","browser","browser_version","plugin_version","player_version"],P=["vast_error","reason","request_load_time","ad_type","vast_ad_id"],O=d("ads/analytics"),F=RequestQueue.of(),q=(...e)=>Object.assign({},...e);class Analytics{constructor(e,t={}){this.emitter=e,this.metadata=q(E,t.metadata||{}),this.emitter=e,this.events=t.events||[],this.required_keys=t.required_keys||[],this.optional_keys=t.optional_keys||[],this.valid_keys=this.required_keys.slice(0).concat(this.optional_keys),O(this),this.wireup()}static of(e,t){return new Analytics(e,t)}static ensure_required_keys(e,t){return e.required_keys.filter(e=>!(e in t))}static pluck_valid_keys(e,t){return((e,...t)=>Object.keys(e).filter(e=>~t.indexOf(e)).reduce((t,s)=>Object.assign(t,{[s]:e[s]}),{}))(t,...e.valid_keys)}static mergeMetadata(e,t={}){return e.metadata=Analytics.pluck_valid_keys(e,q(e.metadata,t,{player_version:"3.13.1-rc.0"})),e}wireup(){this.events.forEach(e=>{this.emitter.on(e,t=>{const s=t.detail,r=q(this.metadata,{event_type:e},s),i=Analytics.pluck_valid_keys(this,r),n=Analytics.ensure_required_keys(this,i);if(O(`Event[${e}]`,{payload:i,observation:s}),n.length)return O(`Analytics.validate_metadata() failed for\n Event[${e}]\n missing keys: ${n}`,i);RequestQueue.rpush(F,[k,U,i])})})}destroy(){this.emitter=this.metadata=this.events=this.required_keys=this.optional_keys=this.valid_keys=void 0}}var B;function C(e,t){var s;switch(t){case B.Preroll:return 0;case B.Postroll:return-1;default:return null===(s=e.ssai)||void 0===s?void 0:s.provider.getContentCurrentTime(e)}}function D(e,t,s){var r,i,n,a;const o=null===(r=t.ssai)||void 0===r?void 0:r.provider.getAdType(),d=null===(a=null===(n=null===(i=t.ssai)||void 0===i?void 0:i.provider)||void 0===n?void 0:n.src)||void 0===a?void 0:a.analyticsId,c={ad_break_time:C(t,o),ad_muted:t.muted,event_type:e};o&&Object.assign(c,{ad_type:o}),d&&Object.assign(c,{ad_tag_id:d}),s&&"duration"in s&&Object.assign(c,{ad_remaining_seconds:s.duration-s.currentTime,ad_duration_seconds:s.duration}),s&&"getAdId"in s&&Object.assign(c,{vast_ad_id:s.getAdId()}),t.emit("health:record",{event:"ads/"+e,detail:c}),t.emit(e,Object.assign(c,{data:s}))}function N(e,t){var s;e.setState("ssai-ad-active",!0);const r=null===(s=e.ssai)||void 0===s?void 0:s.state;r&&(r.adProgress={currentTime:0,duration:t},L(e,r))}function I(e,t){var s;const r=null===(s=e.ssai)||void 0===s?void 0:s.state;r&&(r.adProgress=t,L(e,r))}function x(e){if(!e.ssai)return;const t=e.ssai.state;e.setState("ssai-ad-active",!1),delete t.adProgress,void 0!==t.rate&&(e.playbackRate=t.rate,delete t.rate),"number"==typeof t.snapbackTime&&(r(e,t.snapbackTime),delete t.snapbackTime)}function L(e,t){const s=e.playbackRate;1!==s&&(t.rate=s,e.playbackRate=1)}!function(e){e.Preroll="preroll",e.Midroll="midroll",e.Postroll="postroll"}(B||(B={}));const Q=navigator.languages||[navigator.language];function j(e){const t=e.ssai.ui,s=new google.ima.dai.api.UiSettings,r=e.opt("lang")||function(){try{return Q.reduce((e,t)=>~t.indexOf("-")?e.concat(t,t.split("-")[0]):e.concat(t),[])}catch(e){return[]}}().find(e=>!e.includes("-"))||"en";s.setLocale(r);const i=new google.ima.dai.api.StreamManager(e,t,s);return i.addEventListener([google.ima.dai.api.StreamEvent.Type.LOADED,google.ima.dai.api.StreamEvent.Type.ERROR,google.ima.dai.api.StreamEvent.Type.STREAM_INITIALIZED,google.ima.dai.api.StreamEvent.Type.AD_BREAK_STARTED,google.ima.dai.api.StreamEvent.Type.AD_PROGRESS,google.ima.dai.api.StreamEvent.Type.AD_BREAK_ENDED,google.ima.dai.api.StreamEvent.Type.RESUMED,google.ima.dai.api.StreamEvent.Type.PAUSED,google.ima.dai.api.StreamEvent.Type.STARTED,google.ima.dai.api.StreamEvent.Type.COMPLETE,google.ima.dai.api.StreamEvent.Type.SKIPPED,google.ima.dai.api.StreamEvent.Type.CLICK],t=>{!function(e,t,s){switch(s.type){case google.ima.dai.api.StreamEvent.Type.STREAM_INITIALIZED:return async function(e,t){var s,r;const i=t.getStreamData().streamId,n=e.ssai.provider;if(!i||!n.isPod)return;if(!n.isVod){const t=null===(s=n.src)||void 0===s?void 0:s.streamUrl;return t?(n.daiStream=n.buildPodStreamURL(t,i),e.setSrc(n.daiStream)):console.error("streamUrl param is missing : https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/html5?service=pod#create_a_simple_video_player_2")}const a=null===(r=n.src)||void 0===r?void 0:r.requestStreamUrl;if(!a)return console.error("requestStreamUrl param is missing : https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/html5?service=pod#vod-pod-serving_1");try{n.daiStream=await a(e.ssai.streamManager,i),e.ssai.streamManager.loadStreamMetadata(),e.setSrc(n.daiStream)}catch(t){z(e)}}(e,s);case google.ima.dai.api.StreamEvent.Type.RESUMED:return D("ad-resumed",e,V(e,s));case google.ima.dai.api.StreamEvent.Type.PAUSED:return D("ad-paused",e,V(e,s));case google.ima.dai.api.StreamEvent.Type.COMPLETE:return D("ad-completed",e,V(e,s));case google.ima.dai.api.StreamEvent.Type.SKIPPED:return D("ad-skipped",e,V(e,s));case google.ima.dai.api.StreamEvent.Type.LOADED:return function(e,t){const s=t.getStreamData().url,r=e.ssai.provider;if(!s||r.isPod&&!r.isVod)return;r.daiStream=s,e.setSrc(s)}(e,s);case google.ima.dai.api.StreamEvent.Type.STARTED:return e.ssai.provider.currentAd=s.getAd(),D("ad-started",e,V(e,s));case google.ima.dai.api.StreamEvent.Type.AD_BREAK_STARTED:return N(e),D("ad-break-started",e,V(e,s));case google.ima.dai.api.StreamEvent.Type.AD_BREAK_ENDED:return D(a,e,V(e,s)),x(e),e.ssai.provider.currentAd=void 0;case google.ima.dai.api.StreamEvent.Type.ERROR:return z(e,s);case google.ima.dai.api.StreamEvent.Type.AD_PROGRESS:{const t=V(e,s);return I(e,t.stream_data.adProgressData),D("ad-progress",e,t)}case google.ima.dai.api.StreamEvent.Type.CLICK:(function(e,t){if(!e.paused)e.togglePlay(!1)})(e)}}(e,0,t)},!1),e.on("ID3",({data:e})=>{const t=null==e?void 0:e.cue;if(!t)return;const s={},r=t.value;s[r.key]=r.data,i.onTimedMetadata(s)}),e.on("ssai:hls:metadata",e=>{var t;null===(t=e.detail)||void 0===t||t.samples.forEach(e=>i.processMetadata("ID3",e.data,e.pts))}),e.on("ssai:dash:metadata",e=>{const t=e.detail;if(!t)return;const s=t.event.messageData,r=t.event.calculatedPresentationTime;i.processMetadata("urn:google:dai:2018",s,r)}),i}function V(e,t){return{stream_data:t.getStreamData(),ad:e.ssai.provider.currentAd}}function z(e,t){var s,r;const i=e.ssai.provider;if(null===(s=i.src)||void 0===s?void 0:s.backupStream)return e.setSrc(i.src.backupStream);e.emit("error",{message:(null===(r=null==t?void 0:t.getStreamData())||void 0===r?void 0:r.errorMessage)||"error loading stream"})}const W=d("ads/ima/sdk");var G;async function K(e,t){var s;const r=null===(s=null===window||void 0===window?void 0:window.google)||void 0===s?void 0:s.ima;if(t?null==r?void 0:r.dai:r)return void W(":noop");const i=t?"https://imasdk.googleapis.com/js/sdkloader/ima3_dai.js":e._storage.getItem("ima/debug")?"https://imasdk.googleapis.com/js/sdkloader/ima3_debug.js":"https://imasdk.googleapis.com/js/sdkloader/ima3.js";try{return await async function(e){return new Promise((t,s)=>{let r=document.querySelector(`script[src='${e}']`);if(r)return H(r,t,s);r=document.createElement("script"),r.setAttribute("state",G.LOADING),H(r,t,s),r.src=e,document.head.appendChild(r)})}(i),void W(":loaded")}catch(e){W(":error "+e.message,e)}}function H(e,t,s){const r=e.getAttribute("state");if(r&&[G.ERROR,G.LOADED].includes(r))return t(void 0);e.addEventListener("load",()=>{e.setAttribute("state",G.LOADED),t(void 0)},{once:!0}),["error","abort"].forEach(t=>{e.addEventListener(t,()=>{e.setAttribute("state",G.ERROR),s("script failed to load")},{once:!0})})}!function(e){e.LOADING="loading",e.LOADED="loaded",e.ERROR="error"}(G||(G={}));const $=window.YospaceAdManagement||{AnalyticEventObserver:null};class EventObserver extends $.AnalyticEventObserver{constructor(e){super(),this.video=e}onAdvertBreakStart(e){const t=e.getDuration();if(!e.isActive()&&t){const e=s(this.video);r(this.video,e+t/1e3)}N(this.video,e.getStart()),D("ad-break-started",this.video)}onAdvertBreakEnd(){x(this.video),D(a,this.video)}onAdvertStart(e){}onAdvertEnd(){}onTrackingEvent(e){}}function Z(e,t){YospaceAdManagement.SessionVOD.create(e,t.ssai.properties,e=>{const r=e.getPayload();if(r.getSessionResult()===YospaceAdManagement.SessionResult.INITIALISED){t.ssai.session=r;const e=new EventObserver(t);r.addAnalyticObserver(e),t.setSrc({src:r.getPlaybackUrl()}),setInterval(()=>{const e=1e3*s(t);r.onPlayheadUpdate(e),function(e,t,s){const r=e.getCurrentAdBreak();if(!r)return;const i={currentTime:s-r.getStart(),duration:r.getDuration()};I(t,i),D("ad-progress",t,{stream_data:i})}(r,t,e)},250)}else console.warn("YoSpace Failed to initialise session. ResultCode = "+r.getResultCode())})}var X=Object.freeze({__proto__:null,exists:function(){return!!window.YospaceAdManagement},init:function(e,t){t.ssai&&(!function(e){Object.defineProperty(e,"currentTime",{get:function(){if(e.ssai){const t=e.ssai.state.adProgress;return t?t.currentTime:e.ssai.provider.getContentCurrentTime(e)}return s(e)},set:function(t){var s;if(e.ssai){if(e.ssai.state.adProgress)return;return null===(s=e.ssai.provider)||void 0===s?void 0:s.setContentCurrentTime(e,t)}}}),Object.defineProperty(e,"duration",{get:function(){if(e.ssai){const t=e.ssai.state.adProgress;return t?t.duration:e.ssai.provider.getContentDuration(e)}return n(e)},set:function(){}})}(t),Object.assign(t.ssai,function(){const e=new YospaceAdManagement.SessionProperties;return e.setUserAgent(navigator.userAgent),{properties:e}}()))},srcIsValid:function(e){return"yospace"==e.type},onload:function(e,t){t&&t.src&&Z(t.src,e)},getContentCurrentTime:function(e){const t=s(e),r=e.ssai.session;return r?r.getContentPositionForPlayhead(1e3*t)/1e3:t},setContentCurrentTime:function(e,t){const s=e.ssai.session;return r(e,s?s.getPlayheadForContentPosition(1e3*t)/1e3:t)},onNewSrc:function(e){},getContentDuration:function(e){const t=e.ssai.session,s=n(e);return t?t.getContentPositionForPlayhead(t.getDuration())/1e3:s},getAdType:function(){},getPreviousActiveAdStart:function(e,t){const s=e.ssai.session;if(!s)return;const r=s.getAdBreaks();let i;const n=1e3*t;return r.forEach(e=>{void 0===i&&e.getStart()<n&&e.isActive()&&(i=e)}),void 0!==i?i.getStart()/1e3:void 0}});const Y=(e,t)=>new(((e,t)=>{const s=e.get(t);if(!s)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 i=window.customElements.get(s);return"function"!=typeof i?r:i})(e._customElements,t))(e),J=(e,t,s)=>{window.customElements.get(t)||window.customElements.define(t,s),e.customElements.get(t)||e.customElements.set(t,t)};class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}class SSAIAdUi extends FlowplayerComponent{constructor(e){super(e),this.className="fp-ssai-ui",this.append(...this.player.createComponents("flowplayer-ssai-indicator","flowplayer-ssai-timeline","flowplayer-ssai-controls"))}}class SSAITimeline extends FlowplayerComponent{constructor(e){super(e),this.className="fp-ssai-timeline";const t=document.createElement("div");t.className="fp-ssai-progress",this.append(t),this.player.on(a,()=>{t.classList.remove("go"),"--ssai-percent-complete --ssai-percent-previous".split(" ").forEach(e=>this.style.setProperty(e,"0"))}),this.player.on("ad-progress",e=>{var s,r,i;const n=null===(i=null===(r=null===(s=e.detail)||void 0===s?void 0:s.data)||void 0===r?void 0:r.stream_data)||void 0===i?void 0:i.adProgressData;if(!n)return;const a=n.currentTime/n.duration*100,o=t.style.getPropertyValue("--ssai-percent-complete");t.classList.remove("go"),t.style.setProperty("--ssai-percent-previous",o),t.style.setProperty("--ssai-percent-complete",a.toFixed(3)),t.classList.add("go")})}}function ee(e){const t="number"==typeof e?e:parseInt(e,10);return(t>9?"":"0")+t}class SSAIControls extends FlowplayerComponent{constructor(e){super(e),this.className="fp-ssai-controls",this.createLeftZone(),this.createRightZone()}createRightZone(){const e=document.createElement("div");e.className="fp-ssai-right-zone",e.append(...this.player.createComponents("flowplayer-volume-control"),...this.fsIcons()),this.append(e)}createLeftZone(){const e=document.createElement("div");e.className="fp-ssai-left-zone",e.append(...this.player.createComponents("flowplayer-control-buttons"),this.remainingTimeComponent()),this.append(e)}fsIcons(){return this.player.createComponents("flowplayer-fullscreen-enter-icon","flowplayer-fullscreen-exit-icon").map(e=>(e.onclick=()=>this.player.toggleFullScreen(),e))}remainingTimeComponent(){const e=document.createElement("div");return e.className="fp-ssai-remaining",this.player.on("ad-progress",t=>{var s,r;const i=null===(r=null===(s=t.detail.data)||void 0===s?void 0:s.stream_data)||void 0===r?void 0:r.adProgressData;i&&(e.textContent=function(e){if(isNaN(e)||e>=Number.MAX_SAFE_INTEGER)return"";const t=e<0?"-":"";e=Math.round(Math.abs(e));const s=Math.floor(e/3600);let r=Math.floor(e/60);return e-=60*r,s>=1?(r-=60*s,t+s+":"+ee(r)+":"+ee(e)):t+ee(r)+":"+ee(e)}(i.duration-i.currentTime))}),e}}class SSAIAdIndicator extends FlowplayerComponent{constructor(e){super(e),this.className="fp-ssai-indicator",this.player.on("ad-started",e=>{var t,s,r;const i=null===(r=null===(s=null===(t=e.detail)||void 0===t?void 0:t.data)||void 0===s?void 0:s.ad)||void 0===r?void 0:r.getAdPodInfo();i&&(this.textContent=`${this.player.i18n("ads.indicator","ADS")} ${i.getAdPosition()} / ${i.getTotalAds()}`)})}}const te=[X,new class Dai{async init(e,t){var s,r;if(t.ssai)return this.make_analytics(t),await K(t,!0),(null===(r=null===(s=window.google)||void 0===s?void 0:s.ima)||void 0===r?void 0:r.dai)?void 0:console.warn("google.ima.dai unavailable")}async onload(e,t){var s,r,i;if(await K(e,!0),null===(r=null===(s=window.google)||void 0===s?void 0:s.ima)||void 0===r?void 0:r.dai){if((null===(i=e.ssai)||void 0===i?void 0:i.streamManager)||(e.ssai.streamManager=j(e)),this.src=t,this.isPod=!!t.networkCode,this.isVod=!(t.assetKey||t.customAssetKey),this.isPod)return this.requestPodStream(e.ssai.streamManager,t);this.requestStream(e.ssai.streamManager,t)}else t.backupStream&&e.setSrc(t.backupStream)}onNewSrc(e,t){var s;t.src!==this.daiStream&&(null===(s=e.ssai.streamManager)||void 0===s||s.reset())}make_analytics(e){const t=Analytics.of(e,{required_keys:R,events:T,optional_keys:P});e.on("config",()=>{var s;return Analytics.mergeMetadata(t,null===(s=e.opts)||void 0===s?void 0:s.metadata)})}exists(){return!0}getAdType(){if(this.currentAd)switch(this.currentAd.getAdPodInfo().getPodIndex()){case 0:return B.Preroll;case-1:return B.Postroll;case-2:return;default:return B.Midroll}}getContentCurrentTime(e){const t=e.ssai.streamManager,s=e.currentTime;return t?t.contentTimeForStreamTime(s):s}setContentCurrentTime(e,t){}getContentDuration(e){const t=e.ssai.streamManager,s=e.duration;return t?t.contentTimeForStreamTime(s):s}getPreviousActiveAdStart(e,t){var s,r;const i=null===(r=null===(s=e.ssai)||void 0===s?void 0:s.streamManager)||void 0===r?void 0:r.previousCuePointForStreamTime(t);if(i&&!i.played)return i.start}srcIsValid(e){return"google/dai"==e.type&&!!(e.videoId&&e.contentSourceId||e.assetKey||e.networkCode)}requestStream(e,t){const s=this.isVod?new google.ima.dai.api.VODStreamRequest:new google.ima.dai.api.LiveStreamRequest;e.requestStream(Object.assign(s,t))}requestPodStream(e,t){const s=this.isVod?new google.ima.dai.api.PodVodStreamRequest:new google.ima.dai.api.PodStreamRequest;e.requestStream(Object.assign(s,t))}buildPodStreamURL(e,t){return e.replace("[[STREAMID]]",t)}}];class Ssai{constructor(e){this.umd=e,J(e,"flowplayer-ssai-ui",SSAIAdUi),J(e,"flowplayer-ssai-timeline",SSAITimeline),J(e,"flowplayer-ssai-controls",SSAIControls),J(e,"flowplayer-ssai-indicator",SSAIAdIndicator)}init(e,t,i){te.forEach(e=>{if(i.ssai||!e.exists())return;const n=Y(i,"flowplayer-ssai-ui");t.append(n),i.ssai={provider:e,ui:n,state:{snapback:!1}},e.init(t,i),i.on("seeked",()=>function(e){if(e.opt("live"))return;if(!e.ssai)return;const{provider:t,state:i}=e.ssai;if(i.snapback)return i.snapback=!1;const n=s(e),a=t.getPreviousActiveAdStart(e,n);void 0!==a&&(i.snapback=!0,i.snapbackTime=n,r(e,a))}(i)),i.on("src",t=>{i.setState("ssai-ad-active",!1),i.ssai&&(i.ssai.state={snapback:!1},e.onNewSrc(i,t.detail))})})}onload(e,t,s,r){var i;(null===(i=s.ssai)||void 0===i?void 0:i.provider)&&s.ssai.provider.onload(s,r)}wants(e,t,s){let r=!1;return te.forEach(e=>{if(!r&&e.exists()&&e.srcIsValid(t))return r=!0}),r}}return Ssai.events=o,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 s=e.flowplayer;return"function"==typeof s?(s(t),t):(Array.isArray(s.extensions)||(s.extensions=[]),~s.extensions.indexOf(t)||s.extensions.push(t),t)}(window,Ssai)}));
|
|
7
|
+
*/const S=class Bowser{static getParser(e,t=!1){if("string"!=typeof e)throw new Error("UserAgent should be a string");return new Parser(e,t)}static parse(e){return new Parser(e).getResult()}static get BROWSER_MAP(){return u}static get ENGINE_MAP(){return g}static get OS_MAP(){return m}static get PLATFORMS_MAP(){return p}}.parse(window.navigator.userAgent),{platform:w,os:_,browser:M}=S,A=e=>e&&e.toLowerCase();var E={rnd:Math.random().toString(36).substr(2,32),os:A(_.name+(_.versionName?" "+_.versionName:"")),device:A(w.type),browser:A(M.name),browser_version:(M&&M.version?M.version:"unknown").split(".").shift(),plugin_version:"3.14.0-rc"};const k="https://fp-eu-w1-aai.flowplayer.com/in",U="POST",T=["ad-requested","ad-request-error","ad-request-completed","ad-completed","ad-started","ad-error","ad-skipped"],R=["event_type","ad_tag_id","media_id","player_id","site_id","sitegroup_id","rnd","os","device","browser","browser_version","plugin_version","player_version"],P=["vast_error","reason","request_load_time","ad_type","vast_ad_id"],O=d("ads/analytics"),F=RequestQueue.of(),q=(...e)=>Object.assign({},...e);class Analytics{constructor(e,t={}){this.emitter=e,this.metadata=q(E,t.metadata||{}),this.emitter=e,this.events=t.events||[],this.required_keys=t.required_keys||[],this.optional_keys=t.optional_keys||[],this.valid_keys=this.required_keys.slice(0).concat(this.optional_keys),O(this),this.wireup()}static of(e,t){return new Analytics(e,t)}static ensure_required_keys(e,t){return e.required_keys.filter(e=>!(e in t))}static pluck_valid_keys(e,t){return((e,...t)=>Object.keys(e).filter(e=>~t.indexOf(e)).reduce((t,s)=>Object.assign(t,{[s]:e[s]}),{}))(t,...e.valid_keys)}static mergeMetadata(e,t={}){return e.metadata=Analytics.pluck_valid_keys(e,q(e.metadata,t,{player_version:"3.14.0-rc"})),e}wireup(){this.events.forEach(e=>{this.emitter.on(e,t=>{const s=t.detail,r=q(this.metadata,{event_type:e},s),i=Analytics.pluck_valid_keys(this,r),n=Analytics.ensure_required_keys(this,i);if(O(`Event[${e}]`,{payload:i,observation:s}),n.length)return O(`Analytics.validate_metadata() failed for\n Event[${e}]\n missing keys: ${n}`,i);RequestQueue.rpush(F,[k,U,i])})})}destroy(){this.emitter=this.metadata=this.events=this.required_keys=this.optional_keys=this.valid_keys=void 0}}var B;function C(e,t){var s;switch(t){case B.Preroll:return 0;case B.Postroll:return-1;default:return null===(s=e.ssai)||void 0===s?void 0:s.provider.getContentCurrentTime(e)}}function D(e,t,s){var r,i,n,a;const o=null===(r=t.ssai)||void 0===r?void 0:r.provider.getAdType(),d=null===(a=null===(n=null===(i=t.ssai)||void 0===i?void 0:i.provider)||void 0===n?void 0:n.src)||void 0===a?void 0:a.analyticsId,c={ad_break_time:C(t,o),ad_muted:t.muted,event_type:e};o&&Object.assign(c,{ad_type:o}),d&&Object.assign(c,{ad_tag_id:d}),s&&"duration"in s&&Object.assign(c,{ad_remaining_seconds:s.duration-s.currentTime,ad_duration_seconds:s.duration}),s&&"getAdId"in s&&Object.assign(c,{vast_ad_id:s.getAdId()}),t.emit("health:record",{event:"ads/"+e,detail:c}),t.emit(e,Object.assign(c,{data:s}))}function N(e,t){var s;e.setState("ssai-ad-active",!0);const r=null===(s=e.ssai)||void 0===s?void 0:s.state;r&&(r.adProgress={currentTime:0,duration:t},L(e,r))}function I(e,t){var s;const r=null===(s=e.ssai)||void 0===s?void 0:s.state;r&&(r.adProgress=t,L(e,r))}function x(e){if(!e.ssai)return;const t=e.ssai.state;e.setState("ssai-ad-active",!1),delete t.adProgress,void 0!==t.rate&&(e.playbackRate=t.rate,delete t.rate),"number"==typeof t.snapbackTime&&(r(e,t.snapbackTime),delete t.snapbackTime)}function L(e,t){const s=e.playbackRate;1!==s&&(t.rate=s,e.playbackRate=1)}!function(e){e.Preroll="preroll",e.Midroll="midroll",e.Postroll="postroll"}(B||(B={}));const Q=navigator.languages||[navigator.language];function j(e){const t=e.ssai.ui,s=new google.ima.dai.api.UiSettings,r=e.opt("lang")||function(){try{return Q.reduce((e,t)=>~t.indexOf("-")?e.concat(t,t.split("-")[0]):e.concat(t),[])}catch(e){return[]}}().find(e=>!e.includes("-"))||"en";s.setLocale(r);const i=new google.ima.dai.api.StreamManager(e,t,s);return i.addEventListener([google.ima.dai.api.StreamEvent.Type.LOADED,google.ima.dai.api.StreamEvent.Type.ERROR,google.ima.dai.api.StreamEvent.Type.STREAM_INITIALIZED,google.ima.dai.api.StreamEvent.Type.AD_BREAK_STARTED,google.ima.dai.api.StreamEvent.Type.AD_PROGRESS,google.ima.dai.api.StreamEvent.Type.AD_BREAK_ENDED,google.ima.dai.api.StreamEvent.Type.RESUMED,google.ima.dai.api.StreamEvent.Type.PAUSED,google.ima.dai.api.StreamEvent.Type.STARTED,google.ima.dai.api.StreamEvent.Type.COMPLETE,google.ima.dai.api.StreamEvent.Type.SKIPPED,google.ima.dai.api.StreamEvent.Type.CLICK],t=>{!function(e,t,s){switch(s.type){case google.ima.dai.api.StreamEvent.Type.STREAM_INITIALIZED:return async function(e,t){var s,r;const i=t.getStreamData().streamId,n=e.ssai.provider;if(!i||!n.isPod)return;if(!n.isVod){const t=null===(s=n.src)||void 0===s?void 0:s.streamUrl;return t?(n.daiStream=n.buildPodStreamURL(t,i),e.setSrc(n.daiStream)):console.error("streamUrl param is missing : https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/html5?service=pod#create_a_simple_video_player_2")}const a=null===(r=n.src)||void 0===r?void 0:r.requestStreamUrl;if(!a)return console.error("requestStreamUrl param is missing : https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/html5?service=pod#vod-pod-serving_1");try{n.daiStream=await a(e.ssai.streamManager,i),e.ssai.streamManager.loadStreamMetadata(),e.setSrc(n.daiStream)}catch(t){z(e)}}(e,s);case google.ima.dai.api.StreamEvent.Type.RESUMED:return D("ad-resumed",e,V(e,s));case google.ima.dai.api.StreamEvent.Type.PAUSED:return D("ad-paused",e,V(e,s));case google.ima.dai.api.StreamEvent.Type.COMPLETE:return D("ad-completed",e,V(e,s));case google.ima.dai.api.StreamEvent.Type.SKIPPED:return D("ad-skipped",e,V(e,s));case google.ima.dai.api.StreamEvent.Type.LOADED:return function(e,t){const s=t.getStreamData().url,r=e.ssai.provider;if(!s||r.isPod&&!r.isVod)return;r.daiStream=s,e.setSrc(s)}(e,s);case google.ima.dai.api.StreamEvent.Type.STARTED:return e.ssai.provider.currentAd=s.getAd(),D("ad-started",e,V(e,s));case google.ima.dai.api.StreamEvent.Type.AD_BREAK_STARTED:return N(e),D("ad-break-started",e,V(e,s));case google.ima.dai.api.StreamEvent.Type.AD_BREAK_ENDED:return D(a,e,V(e,s)),x(e),e.ssai.provider.currentAd=void 0;case google.ima.dai.api.StreamEvent.Type.ERROR:return z(e,s);case google.ima.dai.api.StreamEvent.Type.AD_PROGRESS:{const t=V(e,s);return I(e,t.stream_data.adProgressData),D("ad-progress",e,t)}case google.ima.dai.api.StreamEvent.Type.CLICK:(function(e,t){if(!e.paused)e.togglePlay(!1)})(e)}}(e,0,t)},!1),e.on("ID3",({data:e})=>{const t=null==e?void 0:e.cue;if(!t)return;const s={},r=t.value;s[r.key]=r.data,i.onTimedMetadata(s)}),e.on("ssai:hls:metadata",e=>{var t;null===(t=e.detail)||void 0===t||t.samples.forEach(e=>i.processMetadata("ID3",e.data,e.pts))}),e.on("ssai:dash:metadata",e=>{const t=e.detail;if(!t)return;const s=t.event.messageData,r=t.event.calculatedPresentationTime;i.processMetadata("urn:google:dai:2018",s,r)}),i}function V(e,t){return{stream_data:t.getStreamData(),ad:e.ssai.provider.currentAd}}function z(e,t){var s,r;const i=e.ssai.provider;if(null===(s=i.src)||void 0===s?void 0:s.backupStream)return e.setSrc(i.src.backupStream);e.emit("error",{message:(null===(r=null==t?void 0:t.getStreamData())||void 0===r?void 0:r.errorMessage)||"error loading stream"})}const W=d("ads/ima/sdk");var G;async function K(e,t){var s;const r=null===(s=null===window||void 0===window?void 0:window.google)||void 0===s?void 0:s.ima;if(t?null==r?void 0:r.dai:r)return void W(":noop");const i=t?"https://imasdk.googleapis.com/js/sdkloader/ima3_dai.js":e._storage.getItem("ima/debug")?"https://imasdk.googleapis.com/js/sdkloader/ima3_debug.js":"https://imasdk.googleapis.com/js/sdkloader/ima3.js";try{return await async function(e){return new Promise((t,s)=>{let r=document.querySelector(`script[src='${e}']`);if(r)return H(r,t,s);r=document.createElement("script"),r.setAttribute("state",G.LOADING),H(r,t,s),r.src=e,document.head.appendChild(r)})}(i),void W(":loaded")}catch(e){W(":error "+e.message,e)}}function H(e,t,s){const r=e.getAttribute("state");if(r&&[G.ERROR,G.LOADED].includes(r))return t(void 0);e.addEventListener("load",()=>{e.setAttribute("state",G.LOADED),t(void 0)},{once:!0}),["error","abort"].forEach(t=>{e.addEventListener(t,()=>{e.setAttribute("state",G.ERROR),s("script failed to load")},{once:!0})})}!function(e){e.LOADING="loading",e.LOADED="loaded",e.ERROR="error"}(G||(G={}));const $=window.YospaceAdManagement||{AnalyticEventObserver:null};class EventObserver extends $.AnalyticEventObserver{constructor(e){super(),this.video=e}onAdvertBreakStart(e){const t=e.getDuration();if(!e.isActive()&&t){const e=s(this.video);r(this.video,e+t/1e3)}N(this.video,e.getStart()),D("ad-break-started",this.video)}onAdvertBreakEnd(){x(this.video),D(a,this.video)}onAdvertStart(e){}onAdvertEnd(){}onTrackingEvent(e){}}function Z(e,t){YospaceAdManagement.SessionVOD.create(e,t.ssai.properties,e=>{const r=e.getPayload();if(r.getSessionResult()===YospaceAdManagement.SessionResult.INITIALISED){t.ssai.session=r;const e=new EventObserver(t);r.addAnalyticObserver(e),t.setSrc({src:r.getPlaybackUrl()}),setInterval(()=>{const e=1e3*s(t);r.onPlayheadUpdate(e),function(e,t,s){const r=e.getCurrentAdBreak();if(!r)return;const i={currentTime:s-r.getStart(),duration:r.getDuration()};I(t,i),D("ad-progress",t,{stream_data:i})}(r,t,e)},250)}else console.warn("YoSpace Failed to initialise session. ResultCode = "+r.getResultCode())})}var X=Object.freeze({__proto__:null,exists:function(){return!!window.YospaceAdManagement},init:function(e,t){t.ssai&&(!function(e){Object.defineProperty(e,"currentTime",{get:function(){if(e.ssai){const t=e.ssai.state.adProgress;return t?t.currentTime:e.ssai.provider.getContentCurrentTime(e)}return s(e)},set:function(t){var s;if(e.ssai){if(e.ssai.state.adProgress)return;return null===(s=e.ssai.provider)||void 0===s?void 0:s.setContentCurrentTime(e,t)}}}),Object.defineProperty(e,"duration",{get:function(){if(e.ssai){const t=e.ssai.state.adProgress;return t?t.duration:e.ssai.provider.getContentDuration(e)}return n(e)},set:function(){}})}(t),Object.assign(t.ssai,function(){const e=new YospaceAdManagement.SessionProperties;return e.setUserAgent(navigator.userAgent),{properties:e}}()))},srcIsValid:function(e){return"yospace"==e.type},onload:function(e,t){t&&t.src&&Z(t.src,e)},getContentCurrentTime:function(e){const t=s(e),r=e.ssai.session;return r?r.getContentPositionForPlayhead(1e3*t)/1e3:t},setContentCurrentTime:function(e,t){const s=e.ssai.session;return r(e,s?s.getPlayheadForContentPosition(1e3*t)/1e3:t)},onNewSrc:function(e){},getContentDuration:function(e){const t=e.ssai.session,s=n(e);return t?t.getContentPositionForPlayhead(t.getDuration())/1e3:s},getAdType:function(){},getPreviousActiveAdStart:function(e,t){const s=e.ssai.session;if(!s)return;const r=s.getAdBreaks();let i;const n=1e3*t;return r.forEach(e=>{void 0===i&&e.getStart()<n&&e.isActive()&&(i=e)}),void 0!==i?i.getStart()/1e3:void 0}});const Y=(e,t)=>new(((e,t)=>{const s=e.get(t);if(!s)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 i=window.customElements.get(s);return"function"!=typeof i?r:i})(e._customElements,t))(e),J=(e,t,s)=>{window.customElements.get(t)||window.customElements.define(t,s),e.customElements.get(t)||e.customElements.set(t,t)};class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}class SSAIAdUi extends FlowplayerComponent{constructor(e){super(e),this.className="fp-ssai-ui",this.append(...this.player.createComponents("flowplayer-ssai-indicator","flowplayer-ssai-timeline","flowplayer-ssai-controls"))}}class SSAITimeline extends FlowplayerComponent{constructor(e){super(e),this.className="fp-ssai-timeline";const t=document.createElement("div");t.className="fp-ssai-progress",this.append(t),this.player.on(a,()=>{t.classList.remove("go"),"--ssai-percent-complete --ssai-percent-previous".split(" ").forEach(e=>this.style.setProperty(e,"0"))}),this.player.on("ad-progress",e=>{var s,r,i;const n=null===(i=null===(r=null===(s=e.detail)||void 0===s?void 0:s.data)||void 0===r?void 0:r.stream_data)||void 0===i?void 0:i.adProgressData;if(!n)return;const a=n.currentTime/n.duration*100,o=t.style.getPropertyValue("--ssai-percent-complete");t.classList.remove("go"),t.style.setProperty("--ssai-percent-previous",o),t.style.setProperty("--ssai-percent-complete",a.toFixed(3)),t.classList.add("go")})}}function ee(e){const t="number"==typeof e?e:parseInt(e,10);return(t>9?"":"0")+t}class SSAIControls extends FlowplayerComponent{constructor(e){super(e),this.className="fp-ssai-controls",this.createLeftZone(),this.createRightZone()}createRightZone(){const e=document.createElement("div");e.className="fp-ssai-right-zone",e.append(...this.player.createComponents("flowplayer-volume-control"),...this.fsIcons()),this.append(e)}createLeftZone(){const e=document.createElement("div");e.className="fp-ssai-left-zone",e.append(...this.player.createComponents("flowplayer-control-buttons"),this.remainingTimeComponent()),this.append(e)}fsIcons(){return this.player.createComponents("flowplayer-fullscreen-enter-icon","flowplayer-fullscreen-exit-icon").map(e=>(e.onclick=()=>this.player.toggleFullScreen(),e))}remainingTimeComponent(){const e=document.createElement("div");return e.className="fp-ssai-remaining",this.player.on("ad-progress",t=>{var s,r;const i=null===(r=null===(s=t.detail.data)||void 0===s?void 0:s.stream_data)||void 0===r?void 0:r.adProgressData;i&&(e.textContent=function(e){if(isNaN(e)||e>=Number.MAX_SAFE_INTEGER)return"";const t=e<0?"-":"";e=Math.round(Math.abs(e));const s=Math.floor(e/3600);let r=Math.floor(e/60);return e-=60*r,s>=1?(r-=60*s,t+s+":"+ee(r)+":"+ee(e)):t+ee(r)+":"+ee(e)}(i.duration-i.currentTime))}),e}}class SSAIAdIndicator extends FlowplayerComponent{constructor(e){super(e),this.className="fp-ssai-indicator",this.player.on("ad-started",e=>{var t,s,r;const i=null===(r=null===(s=null===(t=e.detail)||void 0===t?void 0:t.data)||void 0===s?void 0:s.ad)||void 0===r?void 0:r.getAdPodInfo();i&&(this.textContent=`${this.player.i18n("ads.indicator","ADS")} ${i.getAdPosition()} / ${i.getTotalAds()}`)})}}const te=[X,new class Dai{async init(e,t){var s,r;if(t.ssai)return this.make_analytics(t),await K(t,!0),(null===(r=null===(s=window.google)||void 0===s?void 0:s.ima)||void 0===r?void 0:r.dai)?void 0:console.warn("google.ima.dai unavailable")}async onload(e,t){var s,r,i;if(await K(e,!0),null===(r=null===(s=window.google)||void 0===s?void 0:s.ima)||void 0===r?void 0:r.dai){if((null===(i=e.ssai)||void 0===i?void 0:i.streamManager)||(e.ssai.streamManager=j(e)),this.src=t,this.isPod=!!t.networkCode,this.isVod=!(t.assetKey||t.customAssetKey),this.isPod)return this.requestPodStream(e.ssai.streamManager,t);this.requestStream(e.ssai.streamManager,t)}else t.backupStream&&e.setSrc(t.backupStream)}onNewSrc(e,t){var s;t.src!==this.daiStream&&(null===(s=e.ssai.streamManager)||void 0===s||s.reset())}make_analytics(e){const t=Analytics.of(e,{required_keys:R,events:T,optional_keys:P});e.on("config",()=>{var s;return Analytics.mergeMetadata(t,null===(s=e.opts)||void 0===s?void 0:s.metadata)})}exists(){return!0}getAdType(){if(this.currentAd)switch(this.currentAd.getAdPodInfo().getPodIndex()){case 0:return B.Preroll;case-1:return B.Postroll;case-2:return;default:return B.Midroll}}getContentCurrentTime(e){const t=e.ssai.streamManager,s=e.currentTime;return t?t.contentTimeForStreamTime(s):s}setContentCurrentTime(e,t){}getContentDuration(e){const t=e.ssai.streamManager,s=e.duration;return t?t.contentTimeForStreamTime(s):s}getPreviousActiveAdStart(e,t){var s,r;const i=null===(r=null===(s=e.ssai)||void 0===s?void 0:s.streamManager)||void 0===r?void 0:r.previousCuePointForStreamTime(t);if(i&&!i.played)return i.start}srcIsValid(e){return"google/dai"==e.type&&!!(e.videoId&&e.contentSourceId||e.assetKey||e.networkCode)}requestStream(e,t){const s=this.isVod?new google.ima.dai.api.VODStreamRequest:new google.ima.dai.api.LiveStreamRequest;e.requestStream(Object.assign(s,t))}requestPodStream(e,t){const s=this.isVod?new google.ima.dai.api.PodVodStreamRequest:new google.ima.dai.api.PodStreamRequest;e.requestStream(Object.assign(s,t))}buildPodStreamURL(e,t){return e.replace("[[STREAMID]]",t)}}];class Ssai{constructor(e){this.umd=e,J(e,"flowplayer-ssai-ui",SSAIAdUi),J(e,"flowplayer-ssai-timeline",SSAITimeline),J(e,"flowplayer-ssai-controls",SSAIControls),J(e,"flowplayer-ssai-indicator",SSAIAdIndicator)}init(e,t,i){te.forEach(e=>{if(i.ssai||!e.exists())return;const n=Y(i,"flowplayer-ssai-ui");t.append(n),i.ssai={provider:e,ui:n,state:{snapback:!1}},e.init(t,i),i.on("seeked",()=>function(e){if(e.opt("live"))return;if(!e.ssai)return;const{provider:t,state:i}=e.ssai;if(i.snapback)return i.snapback=!1;const n=s(e),a=t.getPreviousActiveAdStart(e,n);void 0!==a&&(i.snapback=!0,i.snapbackTime=n,r(e,a))}(i)),i.on("src",t=>{i.setState("ssai-ad-active",!1),i.ssai&&(i.ssai.state={snapback:!1},e.onNewSrc(i,t.detail))})})}onload(e,t,s,r){var i;(null===(i=s.ssai)||void 0===i?void 0:i.provider)&&s.ssai.provider.onload(s,r)}wants(e,t,s){let r=!1;return te.forEach(e=>{if(!r&&e.exists()&&e.srcIsValid(t))return r=!0}),r}}return Ssai.events=o,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 s=e.flowplayer;return"function"==typeof s?(s(t),t):(Array.isArray(s.extensions)||(s.extensions=[]),~s.extensions.indexOf(t)||s.extensions.push(t),t)}(window,Ssai)}));
|
package/plugins/subtitles.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import type { LevelAttributes } from 'hls.js';
|
|
1
2
|
import type { MediaKeyFunc } from 'hls.js';
|
|
2
3
|
|
|
3
|
-
declare type ArrayToIntersection<T extends Array<unknown>> = T extends [
|
|
4
|
+
declare type ArrayToIntersection<T extends Array<unknown>> = T extends [
|
|
5
|
+
infer Current,
|
|
6
|
+
...infer Remaining
|
|
7
|
+
] ? Current & ArrayToIntersection<Remaining> : unknown;
|
|
4
8
|
|
|
5
9
|
declare type Autoplay = BitOpts | boolean;
|
|
6
10
|
|
|
@@ -75,6 +79,8 @@ declare interface Config {
|
|
|
75
79
|
|
|
76
80
|
declare type ConfigWith<T> = Config & T;
|
|
77
81
|
|
|
82
|
+
/* Excluded from this release type: CUES_PARSED */
|
|
83
|
+
|
|
78
84
|
declare type DeviceId = string;
|
|
79
85
|
|
|
80
86
|
declare type DRM_KEYSYSTEM = "com.widevine.alpha" | "com.microsoft.playready" | "org.w3.clearkey" | "com.apple.fps.1_0";
|
|
@@ -100,6 +106,14 @@ declare type DRMVendorImplementation = {
|
|
|
100
106
|
}, cb: (license_data: Uint8Array) => void) => void;
|
|
101
107
|
};
|
|
102
108
|
|
|
109
|
+
declare namespace events {
|
|
110
|
+
export {
|
|
111
|
+
TRACK_UPDATED,
|
|
112
|
+
TRACKS,
|
|
113
|
+
SWITCH
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
103
117
|
declare type FlowplayerCustomElementRegistry = Map<string, string>;
|
|
104
118
|
|
|
105
119
|
declare interface FlowplayerUMD extends FlowplayerUMDBase {
|
|
@@ -144,14 +158,51 @@ declare interface FPEvent<T> extends CustomEvent<T> {
|
|
|
144
158
|
data?: T;
|
|
145
159
|
}
|
|
146
160
|
|
|
161
|
+
/**
|
|
162
|
+
* @public
|
|
163
|
+
* Defines the attributes for HTML track elements.
|
|
164
|
+
*/
|
|
147
165
|
export declare type HTMLTrackAttributes = {
|
|
166
|
+
/**
|
|
167
|
+
* WebVTT file URL.
|
|
168
|
+
* The URL for the WebVTT file.
|
|
169
|
+
*/
|
|
148
170
|
src: string;
|
|
171
|
+
/**
|
|
172
|
+
* The language of the subtitle (2 letter BCP47 code).
|
|
173
|
+
* The language of the subtitle.
|
|
174
|
+
*/
|
|
149
175
|
lang?: string;
|
|
176
|
+
/**
|
|
177
|
+
* Label to show in the menu.
|
|
178
|
+
* Mandatory label to show in the menu.
|
|
179
|
+
*/
|
|
150
180
|
label?: string;
|
|
181
|
+
/**
|
|
182
|
+
* Adds a crossorigin attribute to the element.
|
|
183
|
+
* Possible values: 'use-credentials', 'anonymous'.
|
|
184
|
+
*/
|
|
151
185
|
crossorigin?: string | null;
|
|
186
|
+
/**
|
|
187
|
+
* Defines which track to show as default.
|
|
188
|
+
* One per tracks array. If set, this track will be on at player start.
|
|
189
|
+
*/
|
|
152
190
|
default?: boolean;
|
|
191
|
+
/**
|
|
192
|
+
* Possible options: 'captions', 'subtitles', 'descriptions'.
|
|
193
|
+
* The kind of track.
|
|
194
|
+
*/
|
|
153
195
|
kind?: "captions" | "chapters" | "subtitles";
|
|
196
|
+
/**
|
|
197
|
+
* The mode of the track.
|
|
198
|
+
* Possible options: 'hidden', 'showing', 'disabled'.
|
|
199
|
+
*/
|
|
154
200
|
mode?: "hidden" | "showing" | "disabled";
|
|
201
|
+
/**
|
|
202
|
+
* The ID of the subtitle.
|
|
203
|
+
* The unique identifier for the subtitle track.
|
|
204
|
+
*/
|
|
205
|
+
id?: string;
|
|
155
206
|
};
|
|
156
207
|
|
|
157
208
|
declare type JSONPlayer = any;
|
|
@@ -232,11 +283,11 @@ declare type PlayerState = string;
|
|
|
232
283
|
|
|
233
284
|
declare type PlayerWith<T> = T & Player;
|
|
234
285
|
|
|
235
|
-
declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue,
|
|
286
|
+
declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
|
|
236
287
|
/**
|
|
237
288
|
* a plugin must always implement the init method so a player instance knows how to initialize it
|
|
238
289
|
*/
|
|
239
|
-
init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player:
|
|
290
|
+
init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player: PlayerWith<PluginPlayerAPIExtension>): void;
|
|
240
291
|
}
|
|
241
292
|
|
|
242
293
|
declare interface PluginCtor<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
|
|
@@ -261,20 +312,118 @@ declare type SourceWith<T> = SourceObj & T;
|
|
|
261
312
|
|
|
262
313
|
/**
|
|
263
314
|
* @public
|
|
315
|
+
* html subtitles plugin
|
|
316
|
+
**/
|
|
317
|
+
declare const Subtitles: PluginCtor<SubtitlesConfig, SubtitlesPlayerAPI> & SubtitlesAPI;
|
|
318
|
+
export default Subtitles;
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* @public
|
|
322
|
+
* The public API available for the Subtitles plugin.
|
|
323
|
+
*/
|
|
324
|
+
export declare type SubtitlesAPI = {
|
|
325
|
+
/**
|
|
326
|
+
* Represents the events emitted by the Subtitles plugin.
|
|
327
|
+
*/
|
|
328
|
+
events: SubtitlesEvents;
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* @public
|
|
333
|
+
* Subtitles are configured in the src (for playlists) or player level object subtitles and the child object tracks, which can contain multiple subtitle tracks in different languages.
|
|
264
334
|
*/
|
|
265
335
|
export declare type SubtitlesConfig = ConfigWith<{
|
|
266
336
|
subtitles?: {
|
|
267
|
-
|
|
337
|
+
/**
|
|
338
|
+
* When set to true, enables native rendering of subtitles by the browser.
|
|
339
|
+
* Helpful when injecting CSS rules or defining subtitle styles directly in WebVTT files.
|
|
340
|
+
* Default: false.
|
|
341
|
+
*/
|
|
268
342
|
native?: boolean;
|
|
343
|
+
/**
|
|
344
|
+
* To disable existing subtitles with subtitles: show: false.
|
|
345
|
+
*/
|
|
346
|
+
show?: boolean;
|
|
347
|
+
/**
|
|
348
|
+
* Required for sideloaded WebVTT track files only.
|
|
349
|
+
* Contains one or multiple track source objects.
|
|
350
|
+
*/
|
|
269
351
|
tracks?: HTMLTrackAttributes[];
|
|
270
352
|
};
|
|
271
353
|
}>;
|
|
272
354
|
|
|
273
355
|
/**
|
|
274
|
-
*
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
export
|
|
356
|
+
* @public
|
|
357
|
+
* Defines all the events that the Subtitles plugin emits.
|
|
358
|
+
*/
|
|
359
|
+
export declare type SubtitlesEvents = typeof events;
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* @public
|
|
363
|
+
* This type is used to extend the Player API with the Subtitles API.
|
|
364
|
+
*/
|
|
365
|
+
export declare type SubtitlesPlayerAPI = {
|
|
366
|
+
on(event: SubtitlesEvents["TRACK_UPDATED"], handler: (e: SubtitlesTracksEvent) => void): Player;
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* @public
|
|
371
|
+
* This event is emitted when the subtitles tracks are updated.
|
|
372
|
+
*/
|
|
373
|
+
export declare type SubtitlesTracksEvent = FPEvent<{
|
|
374
|
+
tracks: TextTrackWithAttributes[];
|
|
375
|
+
}>;
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* @public
|
|
379
|
+
* Represents the event type for changing subtitles. (Emitted by the menu element)
|
|
380
|
+
*/
|
|
381
|
+
declare const SWITCH = "subs:change";
|
|
382
|
+
|
|
383
|
+
/* Excluded from this release type: TEXT_TRACKS */
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* @public
|
|
387
|
+
* Represents a TextTrack with additional attributes for handling custom track states and properties.
|
|
388
|
+
*/
|
|
389
|
+
export declare type TextTrackWithAttributes = TextTrack & {
|
|
390
|
+
/**
|
|
391
|
+
* Indicates whether the track has been removed.
|
|
392
|
+
*/
|
|
393
|
+
removed?: boolean;
|
|
394
|
+
/**
|
|
395
|
+
* Indicates whether the track is embedded in the HLS stream.
|
|
396
|
+
*/
|
|
397
|
+
is_hls_embedded?: boolean;
|
|
398
|
+
/**
|
|
399
|
+
* Indicates whether the track is the default track.
|
|
400
|
+
*/
|
|
401
|
+
default?: boolean;
|
|
402
|
+
/**
|
|
403
|
+
* The unique identifier for the track.
|
|
404
|
+
*/
|
|
405
|
+
track_id?: string | number;
|
|
406
|
+
/**
|
|
407
|
+
* Indicates whether the track is currently active.
|
|
408
|
+
*/
|
|
409
|
+
is_active?: boolean;
|
|
410
|
+
/**
|
|
411
|
+
* Additional attributes associated with the track.
|
|
412
|
+
*/
|
|
413
|
+
attr?: LevelAttributes;
|
|
414
|
+
};
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* @public
|
|
418
|
+
* Represents the event type for text track updates.
|
|
419
|
+
*/
|
|
420
|
+
declare const TRACK_UPDATED = "tracks:text:updated";
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* @public
|
|
424
|
+
* Represents the event type for fetching all subtitle tracks. (Emitted by the menu element)
|
|
425
|
+
*/
|
|
426
|
+
declare const TRACKS = "subs:tracks";
|
|
278
427
|
|
|
279
428
|
declare type UnsafeSource = SourceStr | SourceObj | Array<SourceStr | SourceObj>;
|
|
280
429
|
|
package/plugins/subtitles.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.subtitles=t())}(this,(function(){"use strict";function e(e,t,s){const i=function(e){return Array.isArray(e)?e.slice(0):e.split(".")}(t);for(;i.length;){if(null==e)return s;const t=i.shift();if("string"!=typeof t)return s;e=e[t]}return null==e?s:e}function t(e,t){e.innerHTML="",t.forEach((function(t){const s=document.createElement("pre");s.classList.add("fp-cue"),function(e,t){const s=e.style,i=t.size;s.setProperty("--caption-size",i.toString());const n=t.position;n&&"auto"!==n&&t?s.setProperty("--caption-position",n.toString()):s.removeProperty("--caption-position");const r="captions-align-"+t.align;Array.from(e.classList).forEach((function(s){s!=r&&("captions-vertical"==s&&t.vertical||s.startsWith("captions")&&e.classList.remove(s))})),e.classList.add(r),e.classList.toggle("captions-vertical",!!t.vertical)}(e,t),s.appendChild(t.getCueAsHTML()),e.appendChild(s)}))}function s(){}var i;function n(e,t){if(function(e){return Object.values(i).includes(e)}(t=t||i.Anonymous))return e instanceof HTMLVideoElement&&(e.poster="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="),"crossOrigin"in e?e.crossOrigin=t:e.setAttribute("crossorigin",t),e}function r(e){const t=document.createElement("a");return t.href=e,t.origin}function a(e,t){const i=document.createElement("track");i.className="fp-track renderable",i.kind=t.kind||"captions",i.label=t.label||t.lang||"",i.lang=t.lang||"",i.id=["fp",t.lang].join("-");const a=i.track;return a.removeCue=s,"string"!=typeof t.crossorigin&&function(e,t){try{return e.src.startsWith("blob:"),r(e.src)!==r(t)}catch(e){return console.error(e),!0}}(e,t.src)&&(n(e),t.crossorigin=e.getAttribute("crossorigin")),"crossorigin"in t&&n(e,t.crossorigin),Object.keys(t).forEach(e=>{"default"!==e&&(i[e]=t[e])}),a.mode=t.default?"hidden":"disabled",e.appendChild(i),i}!function(e){e.Anonymous="anonymous",e.UseCredentials="use-credentials",e.Empty=""}(i||(i={}));const o="is-source-processing",l=(e,t)=>new(((e,t)=>{const s=e.get(t);if(!s)throw new Error(`no flowplayer component with the name ${t} exists`);const i=window.customElements.get(t);if(!i)throw new Error(`no default flowplayer component with the name ${t} exists`);const n=window.customElements.get(s);return"function"!=typeof n?i:n})(e._customElements,t))(e),c=(e,t,s)=>{window.customElements.get(t)||window.customElements.define(t,s),e.customElements.get(t)||e.customElements.set(t,t)};function u(e,t,s){const i=function(e,t){const s=new CustomEvent(e,{detail:t,cancelable:!0});return t&&Object.defineProperty(s,"data",{get:()=>t}),s}(t,s);return e.dispatchEvent(i),e}function d(e,t){const s=e._customElements.get(t);return s&&e.root.querySelector(s)||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 FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}const p="fp-on",m="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=f(),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 s=this.menuContainer.open;s||(h(),document.active_menu=this.menuContainer),this.menuContainer.open=!s,e.root.classList.toggle("has-menu-opened",!s),this.summaryEle.setAttribute("aria-expanded",s?"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||f()),this.summaryEle.setAttribute("aria-label",e.menuTitle||"Menu"),e.summaryTitle&&(this.summaryEle.textContent=e.summaryTitle),e.summaryIcon){const t=l(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 s=document.createElement("li");s.setAttribute("role","menuitem"),s.setAttribute("aria-selected","false"),s.setAttribute("tabindex","0"),e.icon&&s.append(e.icon);const i=document.createElement("span");i.textContent=e.text,s.append(i),s.addEventListener("click",()=>{this.select_item(t),"function"==typeof e.onclick&&e.onclick()}),this.olEle.appendChild(s),e.selected&&this.select_item(t)}select_item(e){this.options.forEach((t,s)=>{t.classList.toggle(p,s===e)})}unselect_item(){this.options.forEach(e=>{e.classList.remove(p)})}toggle_visibility(e){this.classList.toggle(m,e),this.menu.style.setProperty("display",e?"none":"flex")}}function h(){Array.from(document.querySelectorAll(".fp-engine")).forEach(e=>{var t;const s=e.root.querySelector("details[open].fp-menu-container");s&&(s.open=!1,null===(t=s.querySelector("summary"))||void 0===t||t.removeAttribute("aria-expanded"),e.root.classList.toggle("has-menu-opened",!1))})}function f(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}document.addEventListener("click",(function(e){this.active_menu&&!e.composedPath().includes(this.active_menu)&&(h(),this.active_menu=void 0)}));const y=["255, 255, 255","255, 255, 0","0, 255, 0","0, 255, 255","0, 0, 255","255, 0, 255","255, 0, 0","0, 0, 0"],v=[.25,.5,.75,1,1.25,1.5,1.75,2,3,4],b=["White","Yellow","Green","Cyan","Blue","Magenta","Red","Black"],g=["Monospaced Serif","Proportional Serif","Monospaced Sans-Serif","Proportional Sans-Serif","Casual","Cursive"],k=["Courier New, monospace","serif","Andale Mono, Lucida Console, monospace","sans-serif","Comic Sans MS, Impact, fantasy","Monotype Corsiva, cursive"],x=["None","Drop shadow","Raised","Depressed","Outline"],E=["","rgb(34, 34, 34) 2px 2px 3px, rgb(34, 34, 34) 2px 2px 4px, rgb(34, 34, 34) 2px 2px 5px","rgb(34, 34, 34) 1px 1px, rgb(34, 34, 34) 2px 2px, rgb(34, 34, 34) 3px 3px","rgb(204, 204, 204) 1px 1px, rgb(204, 204, 204) 0px 1px, rgb(34, 34, 34) -1px -1px, rgb(34, 34, 34) 0px -1px","rgb(34, 34, 34) 0px 0px 1px, rgb(34, 34, 34) 0px 0px 1px, rgb(34, 34, 34) 0px 0px 1px, rgb(34, 34, 34) 0px 0px 1px, rgb(34, 34, 34) 0px 0px 1px"];class StyleOpt{constructor(e,t,s,i,n){this.player=e,this.labels=t,this.values=s,this.css_variable=i,this.default_value=n,this.selected=e._storage.getItem(i)||n}set selected(e){document.documentElement.style.setProperty(this.css_variable,e),this.player._storage.setItem(this.css_variable,e)}get selected(){return document.documentElement.style.getPropertyValue(this.css_variable)}}var A;!function(e){e[e.main=0]="main",e[e.tracks=1]="tracks",e[e.style=2]="style",e[e.styleOpt=3]="styleOpt"}(A||(A={}));class FlowplayerSubtitlesMenu extends FlowplayerMenu{constructor(e){if(super(e),this.state=A.main,this.selectedTrackIdx=-1,this.isTV=!1,this.styleOpts=function(e){return{[e.i18n("cc.properties.fontSize","Font size")]:new StyleOpt(e,v.map(e=>100*e+"%"),v.map(e=>100*e+"%"),"--fp-sub-font-size","100%"),[e.i18n("cc.properties.fontFamily","Font family")]:new StyleOpt(e,g.map(t=>e.i18n("cc.fontFamily."+t,t)),k,"--fp-sub-font-family","sans-serif"),[e.i18n("cc.properties.fontColor","Font color")]:new StyleOpt(e,b.map(t=>e.i18n("cc.colors."+t,t)),y,"--fp-sub-font-color",y[0]),[e.i18n("cc.properties.fontOpacity","Font opacity")]:new StyleOpt(e,v.flatMap(e=>e>1?[]:100*e+"%"),v.flatMap(e=>e>1?[]:e+""),"--fp-sub-font-opacity","1"),[e.i18n("cc.properties.backgroundColor","Background color")]:new StyleOpt(e,b.map(t=>e.i18n("cc.colors."+t,t)),y,"--fp-sub-background-color",y[7]),[e.i18n("cc.properties.backgroundOpacity","Background opacity")]:new StyleOpt(e,v.flatMap(e=>e>1?[]:100*e+"%"),v.flatMap(e=>e>1?[]:e+""),"--fp-sub-background-opacity","0.5"),[e.i18n("cc.properties.characterEdgeStyle","Character edge style")]:new StyleOpt(e,x.map(t=>e.i18n("cc.edgeStyle."+t,t)),E,"--fp-sub-edge-style","")}}(e),e.on("mount",()=>{setTimeout(()=>this.isTV=e.hasState("is-tv"),0),this.classList.toggle("subs-native",!!e.opt("subtitles.native"))}),e.on(Subtitles.events.TRACK_UPDATED,e=>this.summaryEle.classList.toggle("fp-color-text",!!e.detail)),e.opt("subtitles.native"))return;const t=l(this.player,"flowplayer-menu-back");t.setAttribute("aria-label","Back to previous menu"),this.menuHeader.prepend(t),t.addEventListener("click",()=>this.navigateBack());const s=l(this.player,"flowplayer-subs-menu-icon");s.setAttribute("aria-label","Open style menu"),s.addEventListener("click",()=>this.createMenu(A.style)),this.menuHeader.insertBefore(s,this.menuTitle),this.summaryEle.addEventListener("click",()=>{this.menuContainer.open||this.createMenu(A.main)}),this.menu.addEventListener("click",e=>{(e.target===s||e.target===t||this.state!==A.main&&e.target!==this.closeEle)&&e.preventDefault()}),this.addEventListener(Subtitles.events.TRACKS,e=>{var t;this.tracks=e.detail,this.selectedTrackIdx=-1,this.toggle_visibility(!(null===(t=null==this?void 0:this.tracks)||void 0===t?void 0:t.length)),this.state===(this.isTV?A.tracks:A.main)&&this.createMenu(this.isTV?A.tracks:A.main)}),this.addEventListener(Subtitles.events.SWITCH,e=>{this.selectedTrackIdx=e.detail.selected_index,this.state===(this.isTV?A.tracks:A.main)&&this.select_item(this.selectedTrackIdx)}),this.player.addEventListener("tv-menu:will-open",()=>{var e;(null===(e=this.tracks)||void 0===e?void 0:e.length)&&this.createMenu(A.main)}),this.player.on(["tv-menu:will-close","keyboard:close:menus"],e=>{var t;this.state!==A.main&&(null===(t=document.activeElement)||void 0===t?void 0:t.closest(".fp-menu"))===this.menu&&(this.navigateBack(),e.preventDefault())})}navigateBack(){switch(this.state){case A.style:case A.tracks:return this.createMenu(A.main);case A.styleOpt:return this.createMenu(A.style)}}getMenuTitle(){switch(this.state){case A.main:return this.player.i18n("cc.menu_title","Subtitles");case A.tracks:return this.player.i18n("cc.tracks","Tracks");case A.style:return this.player.i18n("cc.options","Options");default:return""}}createMenuOpts(e){switch(this.state){case A.main:return this.isTV?this.createTvMainMenuOpts():this.createTracksMenuOpts();case A.tracks:return this.createTracksMenuOpts();case A.style:return this.createStyleMenuOpts();case A.styleOpt:return e?this.createStylePropertyMenuOpts(this.styleOpts[e]):[]}}createMenu(e,t){var s;this.state=e,this.menu.classList.toggle("fp-submenu",e>0),this.menuTitle.textContent=t||this.getMenuTitle(),this.render(this.createMenuOpts(t)),null===(s=this.menu.querySelector("li"))||void 0===s||s.focus()}createTvMainMenuOpts(){return[{text:this.player.i18n("cc.tracks","Tracks"),onclick:this.createMenu.bind(this,A.tracks)},{text:this.player.i18n("cc.options","Options"),onclick:this.createMenu.bind(this,A.style)}]}createTracksMenuOpts(){return Array.isArray(null==this?void 0:this.tracks)?this.tracks.map((e,t)=>({text:e.text,onclick:()=>{e.onclick(),this.selectedTrackIdx=this.selectedTrackIdx===t?-1:t},selected:this.selectedTrackIdx===t})):[]}createStyleMenuOpts(){const e=Object.keys(this.styleOpts).map(e=>({text:e,onclick:this.createMenu.bind(this,A.styleOpt,e)}));return e.push({text:this.player.i18n("cc.reset","Reset"),onclick:()=>Object.values(this.styleOpts).forEach(e=>e.selected=e.default_value)}),e}createStylePropertyMenuOpts(e){return e.labels.map((t,s)=>({text:t,onclick:()=>{e.selected=e.values[s]},selected:s===e.values.indexOf(e.selected)}))}select_item(e){if(this.state!==A.style)return this.state===A.styleOpt?super.select_item(e):void this.options.forEach((t,s)=>{t.classList.toggle(p,s===e&&!t.classList.contains(p))})}}class FlowplayerIcon extends FlowplayerComponent{constructor(e,t){super(e),this.classList.add("fp-icon",t.name),t.title&&this.setAttribute("title",t.title),t.title&&this.setAttribute("aria-label",t.title),t.translation_key&&this.setAttribute("aria-label",e.i18n(t.translation_key)),this.setAttribute("tabindex","0"),this.setAttribute("focusable","true")}}const w={translation_key:"cc.menu_title",name:"fp-subtitles-menu"},S={name:"fp-menu-back"};function T(e){return!document.fullscreenEnabled&&"function"==typeof e.webkitEnterFullScreen&&"function"==typeof e.webkitExitFullScreen}class Subtitles{constructor(e){c(e,"flowplayer-subtitles-menu",FlowplayerSubtitlesMenu),c(e,"flowplayer-subs-menu-icon",class extends FlowplayerIcon{constructor(e){super(e,w)}}),c(e,"flowplayer-menu-back",class extends FlowplayerIcon{constructor(e){super(e,S)}})}init(i,n,r){var c,p;const m=l(r,"flowplayer-subtitles-menu");m instanceof FlowplayerSubtitlesMenu&&m.setMenuAttrs({class:"fp-cc",summaryTitle:r.i18n("cc.button","CC"),menuTitle:r.i18n("cc.menu_title","Subtitles"),options_event:(null===(c=i.subtitles)||void 0===c?void 0:c.native)?Subtitles.events.TRACKS:void 0,item_selected_event:(null===(p=i.subtitles)||void 0===p?void 0:p.native)?Subtitles.events.SWITCH:void 0});const h=function(e){const t=document.createElement("div");return t.classList.add("fp-captions"),t.ontouchend=t=>e.emit(t.type),t.onclick=t=>e.emit(t.type),t}(r);let f,y=[],v=[];function b(){return Array.from(r.textTracks).filter(e=>~["captions","subtitles","descriptions"].indexOf(e.kind)&&!e.removed&&e.label)}function g(){return b().find(e=>e.is_active)}function k(e){Array.from(e.querySelectorAll("track")).forEach(t=>{["captions","subtitles","descriptions"].includes(t.kind)&&e.removeChild(t)})}function x(e,t,s){u(t,Subtitles.events.TRACKS,s.map((function(t){return{text:t.label,onclick:E.bind(0,e,t)}})));const i=g();return i?b().find(e=>e===i)?void u(t,Subtitles.events.SWITCH,{selected_index:s.indexOf(i)}):A():e.emit("tracks:text:updated")}function E(e,t){var s,i;if(t==g())return A();A(),t.is_hls_embedded&&"number"==typeof t.track_id&&e.hls&&(e.hls.subtitleTrack=t.track_id),t.mode=(null===(s=e.opts.subtitles)||void 0===s?void 0:s.native)?"showing":"hidden",t.is_active=!0,e.emit("tracks:text:updated",t),(null===(i=e.opts.subtitles)||void 0===i?void 0:i.native)||e.emit("cuechange",{track:t})}function A(){const e=g();e&&(r.emit("tracks:text:updated"),e.mode="disabled",e.is_active=!1,t(h,[]))}!function(e){if(!T(e))return;e.on("webkitbeginfullscreen",()=>{const e=g();e&&(e.mode="showing")}),e.on("webkitendfullscreen",()=>{var t;const s=b().find(e=>"showing"===e.mode);s&&!(null===(t=e.opts.subtitles)||void 0===t?void 0:t.native)&&(s.mode="hidden"),s!==g()&&(s?E(e,s):A(),u(m,Subtitles.events.SWITCH,{selected_index:s?v.indexOf(s):-1}))})}(r),r.on("mount",(function(){var e,t;const s=d(r,"flowplayer-control");if(!s)return null===(e=d(r,"flowplayer-ui"))||void 0===e?void 0:e.appendChild(h);s.insertAdjacentElement("beforebegin",h),null===(t=r.hasState("is-tv")?d(r,"flowplayer-tv-menu"):s)||void 0===t||t.append(m)})),r.on("config",(function(e){var t,s;const i=null===(s=null===(t=e.data)||void 0===t?void 0:t.subtitles)||void 0===s?void 0:s.tracks;i&&y!==i&&(y=i,k(r),v=b(),x(r,m,v),y.forEach(e=>a(r,e)))})),r.on("tracks:text:all",e=>{const t=e.detail.tracks;t!==f&&(f=t,v=v.flatMap(e=>e.is_hls_embedded?(e.removed=!0,[]):e),x(r,m,v),t.filter(e=>{var t,s;return~["subtitles","captions"].indexOf((null==e?void 0:e.kind)||(null===(s=null===(t=null==e?void 0:e.subtitleTrack)||void 0===t?void 0:t.type)||void 0===s?void 0:s.toLocaleLowerCase())||"")}).forEach(e=>{var t,i,n,a,o,l,c;const u=r.addTextTrack("captions"===e.kind?"captions":"subtitles",(null===(t=e.subtitleTrack)||void 0===t?void 0:t.name)||e.label,null===(i=e.subtitleTrack)||void 0===i?void 0:i.lang);u.is_hls_embedded=!0,u.default=void 0!==(null===(n=e.subtitleTrack)||void 0===n?void 0:n.default)?null===(a=e.subtitleTrack)||void 0===a?void 0:a.default:e.default,u.track_id=null!==(l=null===(o=e.subtitleTrack)||void 0===o?void 0:o.id)&&void 0!==l?l:e._id,u.mode=u.default?"hidden":"disabled",u.removeCue=s,u.attr=null===(c=e.subtitleTrack)||void 0===c?void 0:c.attrs}))}),r.on("cues:parsed",e=>{const t=e.detail,s=v.find(e=>e.is_hls_embedded&&!e.removed&&(e.default&&"default"===t.track||e.track_id===t.track||"subtitles"+e.track_id===t.track||"captions"+e.track_id===t.track));s&&t.cues.forEach(e=>s.addCue(e))}),r.textTracks.addEventListener("addtrack",()=>{const e=b();if(v.length===e.length&&v.every((t,s)=>t===e[s]))return;let t=g();if(e.map((function(e){return~["showing","hidden"].indexOf(e.mode)&&(t=e,e.mode="disabled",e.is_active=!1),e.oncuechange=function(t){var s;if(!(e===g()||T(r)&&r.hasState("is-fullscreen")))return e.mode="disabled";(null===(s=i.subtitles)||void 0===s?void 0:s.native)||r.emit(t.type,{track:t.target})},e})),u(m,Subtitles.events.TRACKS,e.map((function(e){return{text:e.label,onclick:E.bind(0,r,e)}}))),v=e,!t)return A();E(r,t),u(m,Subtitles.events.SWITCH,{selected_index:v.indexOf(t)})}),r.on("cuechange",(function(s){var i;const n=null===(i=s.data)||void 0===i?void 0:i.track;if(!n||!["captions","subtitles","descriptions"].includes(n.kind))return;const r=Array.from(e(n,"activeCues",[])).filter((e,t,s)=>t===s.findIndex(t=>e.id===t.id)).sort((e,t)=>"number"!=typeof e.line||"number"!=typeof t.line?0:e.line-t.line);t(h,r)})),r.on(["playlist/advance","src"],e=>{r.currentSrc&&("src"===e.type&&["is-playlist",o].some(e=>r.root.classList.contains(e))||(delete r.opts.subtitles,k(r),y=[],A(),v=[],f=[],b().forEach(e=>e.removed=!0),u(m,Subtitles.events.TRACKS,[])))})}}Subtitles.events={TRACKS:"subs:tracks",SWITCH:"subs:change",TRACK_UPDATED:"tracks:text:updated"};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 s=e.flowplayer;return"function"==typeof s?(s(t),t):(Array.isArray(s.extensions)||(s.extensions=[]),~s.extensions.indexOf(t)||s.extensions.push(t),t)}(window,Subtitles)}));
|
|
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.subtitles=t())}(this,(function(){"use strict";function e(e,t,s){const n=function(e){return Array.isArray(e)?e.slice(0):e.split(".")}(t);for(;n.length;){if(null==e)return s;const t=n.shift();if("string"!=typeof t)return s;e=e[t]}return null==e?s:e}function t(e,t){e.innerHTML="",t.forEach((function(t){const s=document.createElement("pre");s.classList.add("fp-cue"),function(e,t){const s=e.style,n=t.size;s.setProperty("--caption-size",n.toString());const i=t.position;i&&"auto"!==i&&t?s.setProperty("--caption-position",i.toString()):s.removeProperty("--caption-position");const r="captions-align-"+t.align;Array.from(e.classList).forEach((function(s){s!=r&&("captions-vertical"==s&&t.vertical||s.startsWith("captions")&&e.classList.remove(s))})),e.classList.add(r),e.classList.toggle("captions-vertical",!!t.vertical)}(e,t),s.appendChild(t.getCueAsHTML()),e.appendChild(s)}))}function s(){}const n="is-source-processing",i=(e,t)=>new(((e,t)=>{const s=e.get(t);if(!s)throw new Error(`no flowplayer component with the name ${t} exists`);const n=window.customElements.get(t);if(!n)throw new Error(`no default flowplayer component with the name ${t} exists`);const i=window.customElements.get(s);return"function"!=typeof i?n:i})(e._customElements,t))(e),r=(e,t,s)=>{window.customElements.get(t)||window.customElements.define(t,s),e.customElements.get(t)||e.customElements.set(t,t)};function a(e,t,s){const n=function(e,t){const s=new CustomEvent(e,{detail:t,cancelable:!0});return t&&Object.defineProperty(s,"data",{get:()=>t}),s}(t,s);return e.dispatchEvent(n),e}function o(e,t){const s=e._customElements.get(t);return s&&e.root.querySelector(s)||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 FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}const l="fp-on",c="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=d(),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 s=this.menuContainer.open;s||(u(),document.active_menu=this.menuContainer),this.menuContainer.open=!s,e.root.classList.toggle("has-menu-opened",!s),this.summaryEle.setAttribute("aria-expanded",s?"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||d()),this.summaryEle.setAttribute("aria-label",e.menuTitle||"Menu"),e.summaryTitle&&(this.summaryEle.textContent=e.summaryTitle),e.summaryIcon){const t=i(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 s=document.createElement("li");s.setAttribute("role","menuitem"),s.setAttribute("aria-selected","false"),s.setAttribute("tabindex","0"),e.icon&&s.append(e.icon);const n=document.createElement("span");n.textContent=e.text,s.append(n),s.addEventListener("click",()=>{this.select_item(t),"function"==typeof e.onclick&&e.onclick()}),this.olEle.appendChild(s),e.selected&&this.select_item(t)}select_item(e){this.options.forEach((t,s)=>{t.classList.toggle(l,s===e)})}unselect_item(){this.options.forEach(e=>{e.classList.remove(l)})}toggle_visibility(e){this.classList.toggle(c,e),this.menu.style.setProperty("display",e?"none":"flex")}}function u(){Array.from(document.querySelectorAll(".fp-engine")).forEach(e=>{var t;const s=e.root.querySelector("details[open].fp-menu-container");s&&(s.open=!1,null===(t=s.querySelector("summary"))||void 0===t||t.removeAttribute("aria-expanded"),e.root.classList.toggle("has-menu-opened",!1))})}function d(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}document.addEventListener("click",(function(e){this.active_menu&&!e.composedPath().includes(this.active_menu)&&(u(),this.active_menu=void 0)}));const p=["255, 255, 255","255, 255, 0","0, 255, 0","0, 255, 255","0, 0, 255","255, 0, 255","255, 0, 0","0, 0, 0"],m=[.25,.5,.75,1,1.25,1.5,1.75,2,3,4],h=["White","Yellow","Green","Cyan","Blue","Magenta","Red","Black"],f=["Monospaced Serif","Proportional Serif","Monospaced Sans-Serif","Proportional Sans-Serif","Casual","Cursive"],y=["Courier New, monospace","serif","Andale Mono, Lucida Console, monospace","sans-serif","Comic Sans MS, Impact, fantasy","Monotype Corsiva, cursive"],v=["None","Drop shadow","Raised","Depressed","Outline"],b=["","rgb(34, 34, 34) 2px 2px 3px, rgb(34, 34, 34) 2px 2px 4px, rgb(34, 34, 34) 2px 2px 5px","rgb(34, 34, 34) 1px 1px, rgb(34, 34, 34) 2px 2px, rgb(34, 34, 34) 3px 3px","rgb(204, 204, 204) 1px 1px, rgb(204, 204, 204) 0px 1px, rgb(34, 34, 34) -1px -1px, rgb(34, 34, 34) 0px -1px","rgb(34, 34, 34) 0px 0px 1px, rgb(34, 34, 34) 0px 0px 1px, rgb(34, 34, 34) 0px 0px 1px, rgb(34, 34, 34) 0px 0px 1px, rgb(34, 34, 34) 0px 0px 1px"];class StyleOpt{constructor(e,t,s,n,i){this.player=e,this.labels=t,this.values=s,this.css_variable=n,this.default_value=i,this.selected=e._storage.getItem(n)||i}set selected(e){document.documentElement.style.setProperty(this.css_variable,e),this.player._storage.setItem(this.css_variable,e)}get selected(){return document.documentElement.style.getPropertyValue(this.css_variable)}}var g;!function(e){e[e.main=0]="main",e[e.tracks=1]="tracks",e[e.style=2]="style",e[e.styleOpt=3]="styleOpt"}(g||(g={}));class FlowplayerSubtitlesMenu extends FlowplayerMenu{constructor(e){if(super(e),this.state=g.main,this.selectedTrackIdx=-1,this.isTV=!1,this.styleOpts=function(e){return{[e.i18n("cc.properties.fontSize","Font size")]:new StyleOpt(e,m.map(e=>100*e+"%"),m.map(e=>100*e+"%"),"--fp-sub-font-size","100%"),[e.i18n("cc.properties.fontFamily","Font family")]:new StyleOpt(e,f.map(t=>e.i18n("cc.fontFamily."+t,t)),y,"--fp-sub-font-family","sans-serif"),[e.i18n("cc.properties.fontColor","Font color")]:new StyleOpt(e,h.map(t=>e.i18n("cc.colors."+t,t)),p,"--fp-sub-font-color",p[0]),[e.i18n("cc.properties.fontOpacity","Font opacity")]:new StyleOpt(e,m.flatMap(e=>e>1?[]:100*e+"%"),m.flatMap(e=>e>1?[]:e+""),"--fp-sub-font-opacity","1"),[e.i18n("cc.properties.backgroundColor","Background color")]:new StyleOpt(e,h.map(t=>e.i18n("cc.colors."+t,t)),p,"--fp-sub-background-color",p[7]),[e.i18n("cc.properties.backgroundOpacity","Background opacity")]:new StyleOpt(e,m.flatMap(e=>e>1?[]:100*e+"%"),m.flatMap(e=>e>1?[]:e+""),"--fp-sub-background-opacity","0.5"),[e.i18n("cc.properties.characterEdgeStyle","Character edge style")]:new StyleOpt(e,v.map(t=>e.i18n("cc.edgeStyle."+t,t)),b,"--fp-sub-edge-style","")}}(e),e.on("mount",()=>{setTimeout(()=>this.isTV=e.hasState("is-tv"),0),this.classList.toggle("subs-native",!!e.opt("subtitles.native"))}),e.on(M.events.TRACK_UPDATED,e=>this.summaryEle.classList.toggle("fp-color-text",!!e.detail)),e.opt("subtitles.native"))return;const t=i(this.player,"flowplayer-menu-back");t.setAttribute("aria-label","Back to previous menu"),this.menuHeader.prepend(t),t.addEventListener("click",()=>this.navigateBack());const s=i(this.player,"flowplayer-subs-menu-icon");s.setAttribute("aria-label","Open style menu"),s.addEventListener("click",()=>this.createMenu(g.style)),this.menuHeader.insertBefore(s,this.menuTitle),this.summaryEle.addEventListener("click",()=>{this.menuContainer.open||this.createMenu(g.main)}),this.menu.addEventListener("click",e=>{(e.target===s||e.target===t||this.state!==g.main&&e.target!==this.closeEle)&&e.preventDefault()}),this.addEventListener(M.events.TRACKS,e=>{var t;this.tracks=e.detail,this.selectedTrackIdx=-1,this.toggle_visibility(!(null===(t=null==this?void 0:this.tracks)||void 0===t?void 0:t.length)),this.state===(this.isTV?g.tracks:g.main)&&this.createMenu(this.isTV?g.tracks:g.main)}),this.addEventListener(M.events.SWITCH,e=>{this.selectedTrackIdx=e.detail.selected_index,this.state===(this.isTV?g.tracks:g.main)&&this.select_item(this.selectedTrackIdx)}),this.player.addEventListener("tv-menu:will-open",()=>{var e;(null===(e=this.tracks)||void 0===e?void 0:e.length)&&this.createMenu(g.main)}),this.player.on(["tv-menu:will-close","keyboard:close:menus"],e=>{var t;this.state!==g.main&&(null===(t=document.activeElement)||void 0===t?void 0:t.closest(".fp-menu"))===this.menu&&(this.navigateBack(),e.preventDefault())})}navigateBack(){switch(this.state){case g.style:case g.tracks:return this.createMenu(g.main);case g.styleOpt:return this.createMenu(g.style)}}getMenuTitle(){switch(this.state){case g.main:return this.player.i18n("cc.menu_title","Subtitles");case g.tracks:return this.player.i18n("cc.tracks","Tracks");case g.style:return this.player.i18n("cc.options","Options");default:return""}}createMenuOpts(e){switch(this.state){case g.main:return this.isTV?this.createTvMainMenuOpts():this.createTracksMenuOpts();case g.tracks:return this.createTracksMenuOpts();case g.style:return this.createStyleMenuOpts();case g.styleOpt:return e?this.createStylePropertyMenuOpts(this.styleOpts[e]):[]}}createMenu(e,t){var s;this.state=e,this.menu.classList.toggle("fp-submenu",e>0),this.menuTitle.textContent=t||this.getMenuTitle(),this.render(this.createMenuOpts(t)),null===(s=this.menu.querySelector("li"))||void 0===s||s.focus()}createTvMainMenuOpts(){return[{text:this.player.i18n("cc.tracks","Tracks"),onclick:this.createMenu.bind(this,g.tracks)},{text:this.player.i18n("cc.options","Options"),onclick:this.createMenu.bind(this,g.style)}]}createTracksMenuOpts(){return Array.isArray(null==this?void 0:this.tracks)?this.tracks.map((e,t)=>({text:e.text,onclick:()=>{e.onclick(),this.selectedTrackIdx=this.selectedTrackIdx===t?-1:t},selected:this.selectedTrackIdx===t})):[]}createStyleMenuOpts(){const e=Object.keys(this.styleOpts).map(e=>({text:e,onclick:this.createMenu.bind(this,g.styleOpt,e)}));return e.push({text:this.player.i18n("cc.reset","Reset"),onclick:()=>Object.values(this.styleOpts).forEach(e=>e.selected=e.default_value)}),e}createStylePropertyMenuOpts(e){return e.labels.map((t,s)=>({text:t,onclick:()=>{e.selected=e.values[s]},selected:s===e.values.indexOf(e.selected)}))}select_item(e){if(this.state!==g.style)return this.state===g.styleOpt?super.select_item(e):void this.options.forEach((t,s)=>{t.classList.toggle(l,s===e&&!t.classList.contains(l))})}}class FlowplayerIcon extends FlowplayerComponent{constructor(e,t){super(e),this.classList.add("fp-icon",t.name),t.title&&this.setAttribute("title",t.title),t.title&&this.setAttribute("aria-label",t.title),t.translation_key&&this.setAttribute("aria-label",e.i18n(t.translation_key)),this.setAttribute("tabindex","0"),this.setAttribute("focusable","true")}}function k(e){return!document.fullscreenEnabled&&"function"==typeof e.webkitEnterFullScreen&&"function"==typeof e.webkitExitFullScreen}const x="subs:tracks",E="subs:change";var A,w=Object.freeze({__proto__:null,TRACK_UPDATED:"tracks:text:updated",TRACKS:x,SWITCH:E,CUES_PARSED:"cues:parsed",TEXT_TRACKS:"tracks:text:all"});function _(e,t){if(function(e){return Object.values(A).includes(e)}(t=t||A.Anonymous))return e instanceof HTMLVideoElement&&(e.poster="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="),"crossOrigin"in e?e.crossOrigin=t:e.setAttribute("crossorigin",t),e}function T(e){const t=document.createElement("a");return t.href=e,t.origin}function C(e,t){const n=document.createElement("track");n.className="fp-track renderable",n.kind=t.kind||"captions",n.label=t.label||t.lang||"",n.lang=t.lang||"",n.id=["fp",t.lang].join("-");const i=n.track;return i.removeCue=s,"string"!=typeof t.crossorigin&&function(e,t){try{return e.src.startsWith("blob:"),T(e.src)!==T(t)}catch(e){return console.error(e),!0}}(e,t.src)&&(_(e),t.crossorigin=e.getAttribute("crossorigin")),"crossorigin"in t&&_(e,t.crossorigin),Object.keys(t).forEach(e=>{"default"!==e&&(n[e]=t[e])}),i.mode=t.default?"hidden":"disabled",e.appendChild(n),n}!function(e){e.Anonymous="anonymous",e.UseCredentials="use-credentials",e.Empty=""}(A||(A={}));const O={translation_key:"cc.menu_title",name:"fp-subtitles-menu"},S={name:"fp-menu-back"};var L;const M=((L=class Subtitles{constructor(e){r(e,"flowplayer-subtitles-menu",FlowplayerSubtitlesMenu),r(e,"flowplayer-subs-menu-icon",class extends FlowplayerIcon{constructor(e){super(e,O)}}),r(e,"flowplayer-menu-back",class extends FlowplayerIcon{constructor(e){super(e,S)}})}init(r,l,c){var u,d;const p=i(c,"flowplayer-subtitles-menu");p instanceof FlowplayerSubtitlesMenu&&p.setMenuAttrs({class:"fp-cc",summaryTitle:c.i18n("cc.button","CC"),menuTitle:c.i18n("cc.menu_title","Subtitles"),options_event:(null===(u=r.subtitles)||void 0===u?void 0:u.native)?x:void 0,item_selected_event:(null===(d=r.subtitles)||void 0===d?void 0:d.native)?E:void 0});const m=function(e){const t=document.createElement("div");return t.classList.add("fp-captions"),t.ontouchend=t=>e.emit(t.type),t.onclick=t=>e.emit(t.type),t}(c);let h,f=[],y=[];function v(){return Array.from(c.textTracks).filter(e=>~["captions","subtitles","descriptions"].indexOf(e.kind)&&!e.removed&&e.label)}function b(){return v().find(e=>e.is_active)}function g(e){Array.from(e.querySelectorAll("track")).forEach(t=>{["captions","subtitles","descriptions"].includes(t.kind)&&e.removeChild(t)})}function A(e,t,s){a(t,x,s.map((function(t){return{text:t.label,onclick:w.bind(0,e,t)}})));const n=b();return n?v().find(e=>e===n)?void a(t,E,{selected_index:s.indexOf(n)}):_():e.emit("tracks:text:updated")}function w(e,t){var s,n;if(t==b())return _();_(),t.is_hls_embedded&&"number"==typeof t.track_id&&e.hls&&(e.hls.subtitleTrack=t.track_id),t.mode=(null===(s=e.opts.subtitles)||void 0===s?void 0:s.native)?"showing":"hidden",t.is_active=!0,e.emit("tracks:text:updated",t),(null===(n=e.opts.subtitles)||void 0===n?void 0:n.native)||e.emit("cuechange",{track:t})}function _(){const e=b();e&&(c.emit("tracks:text:updated"),e.mode="disabled",e.is_active=!1,t(m,[]))}!function(e){if(!k(e))return;e.on("webkitbeginfullscreen",()=>{const e=b();e&&(e.mode="showing")}),e.on("webkitendfullscreen",()=>{var t;const s=v().find(e=>"showing"===e.mode);s&&!(null===(t=e.opts.subtitles)||void 0===t?void 0:t.native)&&(s.mode="hidden"),s!==b()&&(s?w(e,s):_(),a(p,E,{selected_index:s?y.indexOf(s):-1}))})}(c),c.on("mount",(function(){var e,t;const s=o(c,"flowplayer-control");if(!s)return null===(e=o(c,"flowplayer-ui"))||void 0===e?void 0:e.appendChild(m);s.insertAdjacentElement("beforebegin",m),null===(t=c.hasState("is-tv")?o(c,"flowplayer-tv-menu"):s)||void 0===t||t.append(p)})),c.on("config",(function(e){var t,s;const n=null===(s=null===(t=e.data)||void 0===t?void 0:t.subtitles)||void 0===s?void 0:s.tracks;n&&f!==n&&(f=n,g(c),y=v(),A(c,p,y),f.forEach(e=>C(c,e)))})),c.on("tracks:text:all",e=>{const t=e.detail.tracks;t!==h&&(h=t,y=y.flatMap(e=>e.is_hls_embedded?(e.removed=!0,[]):e),A(c,p,y),t.filter(e=>{var t,s;return~["subtitles","captions"].indexOf((null==e?void 0:e.kind)||(null===(s=null===(t=null==e?void 0:e.subtitleTrack)||void 0===t?void 0:t.type)||void 0===s?void 0:s.toLocaleLowerCase())||"")}).forEach(e=>{var t,n,i,r,a,o,l;const u=c.addTextTrack("captions"===e.kind?"captions":"subtitles",(null===(t=e.subtitleTrack)||void 0===t?void 0:t.name)||e.label,null===(n=e.subtitleTrack)||void 0===n?void 0:n.lang);u.is_hls_embedded=!0,u.default=void 0!==(null===(i=e.subtitleTrack)||void 0===i?void 0:i.default)?null===(r=e.subtitleTrack)||void 0===r?void 0:r.default:e.default,u.track_id=null!==(o=null===(a=e.subtitleTrack)||void 0===a?void 0:a.id)&&void 0!==o?o:e._id,u.mode=u.default?"hidden":"disabled",u.removeCue=s,u.attr=null===(l=e.subtitleTrack)||void 0===l?void 0:l.attrs}))}),c.on("cues:parsed",e=>{const t=e.detail,s=y.find(e=>e.is_hls_embedded&&!e.removed&&(e.default&&"default"===t.track||e.track_id===t.track||"subtitles"+e.track_id===t.track||"captions"+e.track_id===t.track));s&&t.cues.forEach(e=>s.addCue(e))}),c.textTracks.addEventListener("addtrack",()=>{const e=v();if(y.length===e.length&&y.every((t,s)=>t===e[s]))return;let t=b();if(e.map((function(e){return~["showing","hidden"].indexOf(e.mode)&&(t=e,e.mode="disabled",e.is_active=!1),e.oncuechange=function(t){var s;if(!(e===b()||k(c)&&c.hasState("is-fullscreen")))return e.mode="disabled";(null===(s=r.subtitles)||void 0===s?void 0:s.native)||c.emit(t.type,{track:t.target})},e})),a(p,x,e.map((function(e){return{text:e.label,onclick:w.bind(0,c,e)}}))),y=e,!t)return _();w(c,t),a(p,E,{selected_index:y.indexOf(t)})}),c.on("cuechange",(function(s){var n;const i=null===(n=s.data)||void 0===n?void 0:n.track;if(!i||!["captions","subtitles","descriptions"].includes(i.kind))return;const r=Array.from(e(i,"activeCues",[])).filter((e,t,s)=>t===s.findIndex(t=>e.id===t.id)).sort((e,t)=>"number"!=typeof e.line||"number"!=typeof t.line?0:e.line-t.line);t(m,r)})),c.on(["playlist/advance","src"],e=>{c.currentSrc&&("src"===e.type&&["is-playlist",n].some(e=>c.root.classList.contains(e))||(delete c.opts.subtitles,g(c),f=[],_(),y=[],h=[],v().forEach(e=>e.removed=!0),a(p,x,[])))})}}).events=w,L);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 s=e.flowplayer;return"function"==typeof s?(s(t),t):(Array.isArray(s.extensions)||(s.extensions=[]),~s.extensions.indexOf(t)||s.extensions.push(t),t)}(window,M)}));
|
package/plugins/thumbnails.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { MediaKeyFunc } from 'hls.js';
|
|
2
2
|
|
|
3
|
-
declare type ArrayToIntersection<T extends Array<unknown>> = T extends [
|
|
3
|
+
declare type ArrayToIntersection<T extends Array<unknown>> = T extends [
|
|
4
|
+
infer Current,
|
|
5
|
+
...infer Remaining
|
|
6
|
+
] ? Current & ArrayToIntersection<Remaining> : unknown;
|
|
4
7
|
|
|
5
8
|
declare type Autoplay = BitOpts | boolean;
|
|
6
9
|
|
|
@@ -225,11 +228,11 @@ declare type PlayerState = string;
|
|
|
225
228
|
|
|
226
229
|
declare type PlayerWith<T> = T & Player;
|
|
227
230
|
|
|
228
|
-
declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue,
|
|
231
|
+
declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
|
|
229
232
|
/**
|
|
230
233
|
* a plugin must always implement the init method so a player instance knows how to initialize it
|
|
231
234
|
*/
|
|
232
|
-
init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player:
|
|
235
|
+
init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player: PlayerWith<PluginPlayerAPIExtension>): void;
|
|
233
236
|
}
|
|
234
237
|
|
|
235
238
|
declare interface PluginCtor<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
|
package/plugins/tizen.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { MediaKeyFunc } from 'hls.js';
|
|
2
2
|
|
|
3
|
-
declare type ArrayToIntersection<T extends Array<unknown>> = T extends [
|
|
3
|
+
declare type ArrayToIntersection<T extends Array<unknown>> = T extends [
|
|
4
|
+
infer Current,
|
|
5
|
+
...infer Remaining
|
|
6
|
+
] ? Current & ArrayToIntersection<Remaining> : unknown;
|
|
4
7
|
|
|
5
8
|
declare type Autoplay = BitOpts | boolean;
|
|
6
9
|
|
|
@@ -225,11 +228,11 @@ declare type PlayerState = string;
|
|
|
225
228
|
|
|
226
229
|
declare type PlayerWith<T> = T & Player;
|
|
227
230
|
|
|
228
|
-
declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue,
|
|
231
|
+
declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
|
|
229
232
|
/**
|
|
230
233
|
* a plugin must always implement the init method so a player instance knows how to initialize it
|
|
231
234
|
*/
|
|
232
|
-
init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player:
|
|
235
|
+
init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player: PlayerWith<PluginPlayerAPIExtension>): void;
|
|
233
236
|
}
|
|
234
237
|
|
|
235
238
|
declare interface PluginCtor<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
|
package/plugins/vtsel.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { MediaKeyFunc } from 'hls.js';
|
|
2
2
|
|
|
3
|
-
declare type ArrayToIntersection<T extends Array<unknown>> = T extends [
|
|
3
|
+
declare type ArrayToIntersection<T extends Array<unknown>> = T extends [
|
|
4
|
+
infer Current,
|
|
5
|
+
...infer Remaining
|
|
6
|
+
] ? Current & ArrayToIntersection<Remaining> : unknown;
|
|
4
7
|
|
|
5
8
|
declare type Autoplay = BitOpts | boolean;
|
|
6
9
|
|
|
@@ -225,11 +228,11 @@ declare type PlayerState = string;
|
|
|
225
228
|
|
|
226
229
|
declare type PlayerWith<T> = T & Player;
|
|
227
230
|
|
|
228
|
-
declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue,
|
|
231
|
+
declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
|
|
229
232
|
/**
|
|
230
233
|
* a plugin must always implement the init method so a player instance knows how to initialize it
|
|
231
234
|
*/
|
|
232
|
-
init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player:
|
|
235
|
+
init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player: PlayerWith<PluginPlayerAPIExtension>): void;
|
|
233
236
|
}
|
|
234
237
|
|
|
235
238
|
declare interface PluginCtor<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
|
package/plugins/webos.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { MediaKeyFunc } from 'hls.js';
|
|
2
2
|
|
|
3
|
-
declare type ArrayToIntersection<T extends Array<unknown>> = T extends [
|
|
3
|
+
declare type ArrayToIntersection<T extends Array<unknown>> = T extends [
|
|
4
|
+
infer Current,
|
|
5
|
+
...infer Remaining
|
|
6
|
+
] ? Current & ArrayToIntersection<Remaining> : unknown;
|
|
4
7
|
|
|
5
8
|
declare type Autoplay = BitOpts | boolean;
|
|
6
9
|
|
|
@@ -225,11 +228,11 @@ declare type PlayerState = string;
|
|
|
225
228
|
|
|
226
229
|
declare type PlayerWith<T> = T & Player;
|
|
227
230
|
|
|
228
|
-
declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue,
|
|
231
|
+
declare interface Plugin_2<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
|
|
229
232
|
/**
|
|
230
233
|
* a plugin must always implement the init method so a player instance knows how to initialize it
|
|
231
234
|
*/
|
|
232
|
-
init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player:
|
|
235
|
+
init(config: ConfigWith<PluginOwnConfig>, container: PlayerRoot, player: PlayerWith<PluginPlayerAPIExtension>): void;
|
|
233
236
|
}
|
|
234
237
|
|
|
235
238
|
declare interface PluginCtor<PluginOwnConfig extends KeyValue = KeyValue, PluginPlayerAPIExtension extends KeyValue = KeyValue> {
|