@flowplayer/player 3.32.1-rc → 3.32.1-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/core.js +1 -1
  2. package/default.js +1 -1
  3. package/embed.js +2 -2
  4. package/index.d.ts +126 -1
  5. package/package.json +2 -2
  6. package/plugins/ads.d.ts +126 -1
  7. package/plugins/ads.js +2 -2
  8. package/plugins/airplay.d.ts +126 -1
  9. package/plugins/analytics.d.ts +126 -1
  10. package/plugins/analytics.js +1 -1
  11. package/plugins/asel.d.ts +126 -1
  12. package/plugins/asel.js +1 -1
  13. package/plugins/audio.d.ts +126 -1
  14. package/plugins/chapters.d.ts +126 -1
  15. package/plugins/chromecast.d.ts +126 -1
  16. package/plugins/comscore.d.ts +126 -1
  17. package/plugins/consent.d.ts +126 -1
  18. package/plugins/context-menu.d.ts +126 -1
  19. package/plugins/cuepoints.d.ts +126 -1
  20. package/plugins/dash.d.ts +126 -1
  21. package/plugins/drm.d.ts +126 -1
  22. package/plugins/endscreen.d.ts +126 -1
  23. package/plugins/fas.d.ts +126 -1
  24. package/plugins/float-on-scroll.d.ts +126 -1
  25. package/plugins/ga4.d.ts +126 -1
  26. package/plugins/gemius.d.ts +126 -1
  27. package/plugins/google-analytics.d.ts +126 -1
  28. package/plugins/hls.d.ts +126 -1
  29. package/plugins/id3.d.ts +126 -1
  30. package/plugins/iframe.d.ts +126 -1
  31. package/plugins/keyboard.d.ts +126 -1
  32. package/plugins/media-session.d.ts +126 -1
  33. package/plugins/message.d.ts +126 -1
  34. package/plugins/message.js +1 -1
  35. package/plugins/ovp.d.ts +126 -1
  36. package/plugins/playlist.d.ts +126 -1
  37. package/plugins/preview.d.ts +126 -1
  38. package/plugins/qsel.d.ts +126 -1
  39. package/plugins/qsel.js +1 -1
  40. package/plugins/qul.d.ts +126 -1
  41. package/plugins/rts.d.ts +126 -1
  42. package/plugins/rts.js +1 -1
  43. package/plugins/share.d.ts +126 -1
  44. package/plugins/share.js +1 -1
  45. package/plugins/speed.d.ts +126 -1
  46. package/plugins/speed.js +1 -1
  47. package/plugins/ssai.d.ts +126 -1
  48. package/plugins/ssai.js +1 -1
  49. package/plugins/subtitles.d.ts +126 -1
  50. package/plugins/subtitles.js +1 -1
  51. package/plugins/thumbnails.d.ts +126 -1
  52. package/plugins/tizen.d.ts +126 -1
  53. package/plugins/vtsel.d.ts +126 -1
  54. package/plugins/vtsel.js +1 -1
  55. package/plugins/webos.d.ts +126 -1
  56. package/util/loader.d.ts +126 -1
@@ -1,7 +1,9 @@
1
1
  import type { Get } from 'type-fest';
2
2
  import type { HlsConfig } from 'hls.js';
3
3
  import type { Level } from 'hls.js';
4
+ import type { Paths } from 'type-fest';
4
5
  import type { Representation } from 'dashjs';
6
+ import type { Translation } from '@flowplayer/translations';
5
7
  import type { TupleToUnion } from 'type-fest';
6
8
 
7
9
  /**
@@ -775,6 +777,13 @@ declare interface FlowplayerUMDBase {
775
777
  /* Excluded from this release type: support */
776
778
  /* Excluded from this release type: jwt */
777
779
  /* Excluded from this release type: loaders */
780
+ /**
781
+ * @public
782
+ * Translations dictionaries to be used with `@flowplayer/translations` package
783
+ *
784
+ * See [official documentation](https://developer.wowza.com/docs/wowza-flowplayer/player/translations/)
785
+ */
786
+ i18n: typeof I18n;
778
787
  }
779
788
 
780
789
  /**
@@ -854,6 +863,112 @@ declare type HasSrcExtensions<PluginBareConfigs extends unknown[]> = TupleToUnio
854
863
 
855
864
  declare const HOVERED = "is-hovered";
856
865
 
866
+ declare class I18n implements Plugin_2 {
867
+ static pluginName: string;
868
+ static en: {
869
+ ads: {
870
+ ad: string;
871
+ ads: string;
872
+ advertisement: string;
873
+ indicator: string;
874
+ adchoices: string;
875
+ };
876
+ audio: {
877
+ button_txt: string;
878
+ menu_title: string;
879
+ };
880
+ cc: {
881
+ button: string;
882
+ menu_title: string;
883
+ options: string;
884
+ tracks: string;
885
+ reset: string;
886
+ colors: {
887
+ Black: string;
888
+ Blue: string;
889
+ Cyan: string;
890
+ Green: string;
891
+ Magenta: string;
892
+ Red: string;
893
+ White: string;
894
+ Yellow: string;
895
+ };
896
+ edgeStyle: {
897
+ None: string;
898
+ "Drop shadow": string;
899
+ Raised: string;
900
+ Depressed: string;
901
+ Outline: string;
902
+ };
903
+ fontFamily: {
904
+ "Monospaced Serif": string;
905
+ "Proportional Serif": string;
906
+ "Monospaced Sans-Serif": string;
907
+ "Proportional Sans-Serif": string;
908
+ Casual: string;
909
+ Cursive: string;
910
+ };
911
+ properties: {
912
+ fontFamily: string;
913
+ fontSize: string;
914
+ fontColor: string;
915
+ fontOpacity: string;
916
+ backgroundColor: string;
917
+ backgroundOpacity: string;
918
+ characterEdgeStyle: string;
919
+ };
920
+ };
921
+ chromecast: {
922
+ start: string;
923
+ stop: string;
924
+ };
925
+ core: {
926
+ exit_fullscreen: string;
927
+ fullscreen: string;
928
+ mute: string;
929
+ muted: string;
930
+ pause: string;
931
+ play: string;
932
+ seconds: string;
933
+ timeline_aria_label: string;
934
+ unmute: string;
935
+ volume: string;
936
+ close: string;
937
+ "skip-next": string;
938
+ "skip-prev": string;
939
+ };
940
+ ovp: {
941
+ starting_in: string;
942
+ };
943
+ playlist: {
944
+ cancel: string;
945
+ up_next: string;
946
+ autoplay: string;
947
+ now_playing: string;
948
+ turn_off_autoplay: string;
949
+ playlist: string;
950
+ };
951
+ qsel: {
952
+ menu_title: string;
953
+ };
954
+ share: {
955
+ clipboard_failure: string;
956
+ clipboard_success: string;
957
+ embed: string;
958
+ link: string;
959
+ menu_title: string;
960
+ };
961
+ speed: {
962
+ menu_title: string;
963
+ };
964
+ vtsel: {
965
+ button_txt: string;
966
+ menu_title: string;
967
+ };
968
+ };
969
+ init(config: Config, _root: never, video: Player): void;
970
+ }
971
+
857
972
  declare const IN_VIEWPORT = "is-in-viewport";
858
973
 
859
974
  /* Excluded from this release type: INTERSECTIONCHANGE */
@@ -1214,7 +1329,8 @@ declare type Player = HTMLVideoElement & PlayerEventOverloads & {
1214
1329
  /**
1215
1330
  * Adds a language to the project. See {@link https://developer.wowza.com/docs/wowza-flowplayer/player/translations/#using-npm| Official documentation}
1216
1331
  */
1217
- i18n(k: string, fallback?: string): string;
1332
+ i18n(k: TranslationKey): string;
1333
+ i18n(k: string, fallback: string): string;
1218
1334
  /* Excluded from this release type: deviceId */
1219
1335
  /* Excluded from this release type: live_state */
1220
1336
  /**
@@ -1913,6 +2029,15 @@ TOUCH_START = "touchstart";
1913
2029
 
1914
2030
  declare const TOUCHED = "is-touched";
1915
2031
 
2032
+ /**
2033
+ * @public
2034
+ * All possible full paths to each translation, i.e. "core.mute"| "core.play" | "ads.ad" etc.
2035
+ * This type is useful for developers using translation querying based on path, like in lodash's get()
2036
+ */
2037
+ declare type TranslationKey = Paths<Translation, {
2038
+ leavesOnly: true;
2039
+ }>;
2040
+
1916
2041
  declare type TSampleRate = typeof SampleRate;
1917
2042
 
1918
2043
  declare const TV = "is-tv";
@@ -1,6 +1,8 @@
1
1
  import type { Get } from 'type-fest';
2
2
  import type { Level } from 'hls.js';
3
+ import type { Paths } from 'type-fest';
3
4
  import type { Representation } from 'dashjs';
5
+ import type { Translation } from '@flowplayer/translations';
4
6
  import type { TupleToUnion } from 'type-fest';
5
7
 
6
8
  /**
@@ -771,6 +773,13 @@ declare interface FlowplayerUMDBase {
771
773
  /* Excluded from this release type: support */
772
774
  /* Excluded from this release type: jwt */
773
775
  /* Excluded from this release type: loaders */
776
+ /**
777
+ * @public
778
+ * Translations dictionaries to be used with `@flowplayer/translations` package
779
+ *
780
+ * See [official documentation](https://developer.wowza.com/docs/wowza-flowplayer/player/translations/)
781
+ */
782
+ i18n: typeof I18n;
774
783
  }
775
784
 
776
785
  /**
@@ -848,6 +857,112 @@ declare type HasSrcExtensions<PluginBareConfigs extends unknown[]> = TupleToUnio
848
857
 
849
858
  declare const HOVERED = "is-hovered";
850
859
 
860
+ declare class I18n implements Plugin_2 {
861
+ static pluginName: string;
862
+ static en: {
863
+ ads: {
864
+ ad: string;
865
+ ads: string;
866
+ advertisement: string;
867
+ indicator: string;
868
+ adchoices: string;
869
+ };
870
+ audio: {
871
+ button_txt: string;
872
+ menu_title: string;
873
+ };
874
+ cc: {
875
+ button: string;
876
+ menu_title: string;
877
+ options: string;
878
+ tracks: string;
879
+ reset: string;
880
+ colors: {
881
+ Black: string;
882
+ Blue: string;
883
+ Cyan: string;
884
+ Green: string;
885
+ Magenta: string;
886
+ Red: string;
887
+ White: string;
888
+ Yellow: string;
889
+ };
890
+ edgeStyle: {
891
+ None: string;
892
+ "Drop shadow": string;
893
+ Raised: string;
894
+ Depressed: string;
895
+ Outline: string;
896
+ };
897
+ fontFamily: {
898
+ "Monospaced Serif": string;
899
+ "Proportional Serif": string;
900
+ "Monospaced Sans-Serif": string;
901
+ "Proportional Sans-Serif": string;
902
+ Casual: string;
903
+ Cursive: string;
904
+ };
905
+ properties: {
906
+ fontFamily: string;
907
+ fontSize: string;
908
+ fontColor: string;
909
+ fontOpacity: string;
910
+ backgroundColor: string;
911
+ backgroundOpacity: string;
912
+ characterEdgeStyle: string;
913
+ };
914
+ };
915
+ chromecast: {
916
+ start: string;
917
+ stop: string;
918
+ };
919
+ core: {
920
+ exit_fullscreen: string;
921
+ fullscreen: string;
922
+ mute: string;
923
+ muted: string;
924
+ pause: string;
925
+ play: string;
926
+ seconds: string;
927
+ timeline_aria_label: string;
928
+ unmute: string;
929
+ volume: string;
930
+ close: string;
931
+ "skip-next": string;
932
+ "skip-prev": string;
933
+ };
934
+ ovp: {
935
+ starting_in: string;
936
+ };
937
+ playlist: {
938
+ cancel: string;
939
+ up_next: string;
940
+ autoplay: string;
941
+ now_playing: string;
942
+ turn_off_autoplay: string;
943
+ playlist: string;
944
+ };
945
+ qsel: {
946
+ menu_title: string;
947
+ };
948
+ share: {
949
+ clipboard_failure: string;
950
+ clipboard_success: string;
951
+ embed: string;
952
+ link: string;
953
+ menu_title: string;
954
+ };
955
+ speed: {
956
+ menu_title: string;
957
+ };
958
+ vtsel: {
959
+ button_txt: string;
960
+ menu_title: string;
961
+ };
962
+ };
963
+ init(config: Config, _root: never, video: Player): void;
964
+ }
965
+
851
966
  declare const IN_VIEWPORT = "is-in-viewport";
852
967
 
853
968
  /* Excluded from this release type: INTERSECTIONCHANGE */
@@ -1208,7 +1323,8 @@ declare type Player = HTMLVideoElement & PlayerEventOverloads & {
1208
1323
  /**
1209
1324
  * Adds a language to the project. See {@link https://developer.wowza.com/docs/wowza-flowplayer/player/translations/#using-npm| Official documentation}
1210
1325
  */
1211
- i18n(k: string, fallback?: string): string;
1326
+ i18n(k: TranslationKey): string;
1327
+ i18n(k: string, fallback: string): string;
1212
1328
  /* Excluded from this release type: deviceId */
1213
1329
  /* Excluded from this release type: live_state */
1214
1330
  /**
@@ -1907,6 +2023,15 @@ TOUCH_START = "touchstart";
1907
2023
 
1908
2024
  declare const TOUCHED = "is-touched";
1909
2025
 
2026
+ /**
2027
+ * @public
2028
+ * All possible full paths to each translation, i.e. "core.mute"| "core.play" | "ads.ad" etc.
2029
+ * This type is useful for developers using translation querying based on path, like in lodash's get()
2030
+ */
2031
+ declare type TranslationKey = Paths<Translation, {
2032
+ leavesOnly: true;
2033
+ }>;
2034
+
1910
2035
  declare type TSampleRate = typeof SampleRate;
1911
2036
 
1912
2037
  declare const TV = "is-tv";
@@ -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.analytics=t())}(this,function(){"use strict";const e=(...e)=>e.reduce((e,t)=>Object.assign(Object.assign({},e),t),{}),t=(e,t)=>{const r=e.lastIndexOf(t);return~r&&e.splice(r,1),e};class RequestQueue{static of(){return new RequestQueue}static is_empty(e){return 0==e.pending.length}static is_high_water(e){return e.open.length==RequestQueue.MAX_OPEN_REQUESTS}static maybe_spawn_req(e){if(RequestQueue.is_empty(e))return e;if(RequestQueue.is_high_water(e))return e;try{const t=RequestQueue.lpop(e);t&&RequestQueue.request(e,t)}catch(e){}}static increment_failures(e){return e.stats.failures++,e.stats.failures>RequestQueue.MAX_FAILURE_COUNT&&(e.stats.ttl=Date.now()+RequestQueue.REQUEST_TTL_MS),e}static handle_error(e,t){RequestQueue.rm(e,t),RequestQueue.increment_failures(e)}static request(e,[t,r,n]){if(Date.now()<e.stats.ttl)return;const i=new XMLHttpRequest;e.open.push(i),i.timeout=RequestQueue.REQUEST_TIMEOUT_MS,i.ontimeout=function(){RequestQueue.handle_error(e,i)},i.onerror=function(t){RequestQueue.handle_error(e,i)},i.onreadystatechange=function(){i.readyState==XMLHttpRequest.DONE&&RequestQueue.rm(e,i),Math.floor(i.status/100)},i.onload=function(){RequestQueue.rm(e,i),e.stats.failures&&e.stats.failures--},i.open(r,t),i.setRequestHeader("Content-Type","text/plain;charset=UTF-8");try{i.send(JSON.stringify(n))}catch(e){}}static rpush(e,...t){return t.forEach(t=>{e.pending.length>=RequestQueue.MAX_PENDING||(e.pending.push(t),RequestQueue.maybe_spawn_req(e))}),e}static lpop(e){return e.pending.shift()}static rm(e,r){return t(e.open,r),e}constructor(){this.pending=[],this.open=[],this.stats={failures:0,ttl:0}}}RequestQueue.MAX_OPEN_REQUESTS=3,RequestQueue.MAX_PENDING=5,RequestQueue.REQUEST_TIMEOUT_MS=4e3,RequestQueue.REQUEST_TTL_MS=5e3,RequestQueue.MAX_FAILURE_COUNT=3;var r=RequestQueue.of();const n=/:([a-zA-Z_]+)/g;class Log{static prepare(e,t){const r=document.createEvent("Event");return r.initEvent(e,!1,!0),r.ns=e,r.data=t,r}static of(e){return new Log(e)}constructor(e){this.emitter=e}info(e){this.emitter.dispatchEvent(Log.prepare(Log.NAMESPACE.INFO,e))}error(e){this.emitter.dispatchEvent(Log.prepare(Log.NAMESPACE.ERROR,e))}warn(e){this.emitter.dispatchEvent(Log.prepare(Log.NAMESPACE.WARN,e))}}var i,o;Log.NAMESPACE={INFO:"tracker:info",ERROR:"tracker:err",WARN:"tracker:warn"},function(e){e.POST="POST",e.PUT="PUT",e.GET="GET"}(i||(i={}));class Tracker{static of(e,t){return new Tracker(e,t)}static ensure_required_keys(e,t){return e.required_keys.filter(e=>!(e in t))}static pluck_valid_keys(t,r){return((t,...r)=>Object.keys(t).filter(e=>~r.indexOf(e)).reduce((r,n)=>e(r,{[n]:t[n]}),{}))(r,...t.valid_keys)}static merge_metadata(t,r={}){return t.metadata=Tracker.pluck_valid_keys(t,e(t.metadata,r)),t}static assert_emitter_api(e){if("function"!=typeof(e||{}).addEventListener)throw new Error("Tracker() received an emitter that does not implement the addEventListener method");if("function"!=typeof(e||{}).removeEventListener)throw new Error("Tracker() received an emitter that does not implement the removeEventListener method")}static create_listener(e,t,r){var n;e.listeners.push([t,r]),null===(n=e.emitter)||void 0===n||n.addEventListener(t,r)}constructor(t,i={}){const o=this;if(this.emitter=t,this.url=i.url,this.log=Log.of(this.emitter),this.verb=i.verb,this.metadata=e({},i.metadata||{}),this.rq=i.rq||r,this.events=i.events||[],this.required_keys=i.required_keys||[],this.optional_keys=i.optional_keys||[],this.listeners=[],this.valid_keys=this.required_keys.slice(0).concat(this.optional_keys),Tracker.assert_emitter_api(this.emitter),void 0===Tracker.verb[this.verb])throw new Error(`invalid HTTP verb[${this.verb}] passed`);if("string"!=typeof this.url)throw new Error(`invalid API url[${this.url}] passed`);Tracker.TRACKERS.push(this),o.events.forEach(t=>{Tracker.create_listener(this,t,(r={})=>{const i=e(o.metadata,{event_type:t},r.data||r),a=function(e,t){return e.replace(n,e=>{const r=e.slice(1,e.length);return r in t?t[r].toString():e})}(o.url,i),s=Tracker.pluck_valid_keys(o,i),u=Tracker.ensure_required_keys(o,s);if(u.length)return o.log.error(`Tracker.validate_metadata() failed for\n Event[${t}]\n missing keys: ${u}\n payload:\n ${JSON.stringify(s,null,2)}`);this.rq&&RequestQueue.rpush(this.rq,[a,this.verb,s])})})}destroy(){this.listeners.forEach(([e,t])=>{var r;return null===(r=this.emitter)||void 0===r?void 0:r.removeEventListener(e,t)}),delete this.rq,delete this.emitter,t(Tracker.TRACKERS,this)}put(e={}){return Tracker.merge_metadata(this,e),this}}Tracker.TRACKERS=[],Tracker.QUEUE=r,Tracker.verb=i,function(e){e[e.ADS=2]="ADS",e[e.ANALYTICS=4]="ANALYTICS",e[e.NO_METERING=8]="NO_METERING",e[e.DEVELOPER_PLAN=16]="DEVELOPER_PLAN",e[e.WOWZA_VIDEO=32]="WOWZA_VIDEO"}(o||(o={}));const a=["localhost","127.0.0.1","0.0.0.0","s.codepen.io","cdpn.io","try.flowplayer.com"];function s(e,t){return!!~a.indexOf(e)||e.indexOf(t)===e.length-t.length}s.check_whitelist=function(e){return!!~a.indexOf(e)};function u(e){this.message=e}u.prototype=new Error,u.prototype.name="InvalidCharacterError";var d="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new u("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,i=0,o=0,a="";n=t.charAt(o++);~n&&(r=i%4?64*r+n:n,i++%4)?a+=String.fromCharCode(255&r>>(-2*i&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return a};var c=function(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(d(e).replace(/(.)/g,function(e,t){var r=t.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r}))}(t)}catch(e){return d(t)}};function l(e){this.message=e}l.prototype=new Error,l.prototype.name="InvalidTokenError";var f=function(e,t){if("string"!=typeof e)throw new l("Invalid token specified");var r=!0===(t=t||{}).header?0:1;try{return JSON.parse(c(e.split(".")[r]))}catch(e){throw new l("Invalid token specified: "+e.message)}};f.InvalidTokenError=l;const p="production";function _(e,t){const r={valid_jwt:!1,raw:"",data:{acl:0},exp:0};let n={c:"{}",exp:0};t=t||{};try{n=f(e),r.valid_jwt=!0}catch(e){}return r.raw=e,r.data=JSON.parse(n.c),r.exp=n.exp,t.require_valid_token&&_.validate(r),r}function h(e){return{grant:e,is_granted:t=>(e&t)===t}}function m(e,t,r){const n=function(e){return Array.isArray(e)?e.slice(0):e.split(".")}(t);for(;n.length;){if(null==e)return r;const t=n.shift();if("string"!=typeof t)return r;e=e[t]}return null==e?r:e}_.validate=function(e){if("string"==typeof e&&(e=_(e)),!e||!e.raw){if(s.check_whitelist(window.location.hostname)||"dev"===p.toString())return!0;throw new Error("No token provided in configuration")}if(!e.valid_jwt)throw new Error("Invalid token provided");const t=window.location.hostname,r=s.bind(null,t);if("dev"!==p.toString()&&e.data.domain&&e.data.domain.length&&!e.data.domain.some(r))throw new Error("Domain not allowed");if("dev"!==p.toString()&&1e3*e.exp-Date.now()<0)throw new Error("Expired token");return!0},_.id=function(e){if(e)return"string"==typeof e&&(e=_(e)),e.data.id},h.of=h,h.from_token=function(e){const t=_(e,{require_valid_token:!0});return h.of(t.data.acl)},h.permissions=o;var v="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};var y="ping",k="display",g="view";const w=["sitegroup_id","session_id","media_id","site_id","player_id","video_type"],E=["created","position"],T=["player_version","created","source","category","category_id","autoplay","muted","customer_user_id"];const R=100,q=1e3;function A(e,t){return e.duration/1===e.duration&&Object.assign(t,function(e){const t=e/R;return{segment_duration:t,breakpoints:Array(...Array(R)).map(function(e,r){return Math.floor(r*t*q)/q})}}(e.duration))}function S(e,t,r){if(!t.segment_duration&&!A(e,t))return;const n=function(e,t,r){const n=t.last_idx,i=r?99:O(e,t);return t.last_idx=i,i<=n?[]:t.breakpoints.slice(n,99==i?100:i).map(function(e){return t.breakpoints.indexOf(e)})}(e,t,r);0!=n.length&&e.emit(y,{position:n})}function O(e,t){return Math.min(Math.floor(e.currentTime/t.segment_duration),99)}function b(){try{const e=window.location!==window.parent.location?document.referrer:document.location.href;return"string"==typeof e&&e.slice(0,200)}catch(e){return!1}}var N;const Q="vod",x="live",L=[k,y,g];function I(e,t,r){switch(null==t?void 0:t.kind){case"live":return function(e,t){const r=Date.now();r-t.last_tracked_ts<6e4||(t.last_tracked_ts=r,++t.ticks,e.emit(y,{position:60*t.ticks}))}(e,t);case"vod":return S(e,t,"boolean"==typeof r&&r)}}function M(e){const t=e.ads;return void 0!==t&&(void 0!==t.schedule&&("function"==typeof t.hasPreroll&&(t.currentRequests?t.currentRequests:!!t.adPlaying||!(!t.hasPreroll()||0!=t.nextIndex))))}const P=((N=class Analytics{init(e,t,r){if(!h.from_token(e.token||"").is_granted(h.permissions.ANALYTICS))return;if(r.hasState("consent-no-tracking"))return;if(r.analytics)return;const n=r.analytics={ticker:void 0,last_media_id:"",ended:!1},i={locked:void 0,ttl:6e3,task:()=>{I(r,n.ticker)}};const o={session_id:r.deviceId(),autoplay:r.autoplay,muted:r.muted,player_id:e.player_id,customer_user_id:e.customer_user_id,player_version:"3.32.1-rc"},a=Tracker.of(r,{verb:Tracker.verb.POST,url:"https://ptm.flowplayer.com/:video_type/:sitegroup_id/:event_type",events:L,required_keys:w,optional_keys:T.concat(E).slice(0),metadata:o});r.on("reap",function(){a&&a.destroy()}),r.on("config",function(t){if(!a)return;const i=m(t,"data.metadata",{});if(!i.media_id&&i.stream_target_id&&(i.media_id=i.stream_target_id),!i.media_id)return;const o=m(a,"metadata.media_id");if(o&&i.media_id==o)return;const s=m(e,"analytics",{});a.put(i),a.put(s);const u=m(e,"metadata.live_start_time",e.live)?x:Q;a.put({video_type:u,source:e.source||b()||""}),n.ticker=e.live?{ticks:0,last_tracked_ts:Date.now(),kind:"live"}:{last_idx:0,segment_duration:0,breakpoints:[],kind:"vod"},n.ended=!1,r.emit(k)});let s=0;r.on("playing",function(){if(!a)return;if(s||function(e,t){return e.metadata.media_id&&e.metadata.media_id==t.last_media_id}(a,n))return;a.put({muted:r.muted});const e=M(r);if(e)return s=Promise.resolve(e).then(function(){n.last_media_id=a.metadata.media_id,r.emit(g),s=0}).catch(function(){s=0});n.last_media_id=a.metadata.media_id,r.emit(g)}),r.on("timeupdate",function(){var t;a&&(s||M(r)||n.ended||(!e.live&&r.currentTime+.25>=r.duration&&I(r,n.ticker,!0),(t=i).locked||(t.locked=setTimeout(function(){return t.task(),function(e){return e.locked=void 0,e}(t)},t.ttl))))}),r.on("seeked",function(){a&&n.ticker&&"vod"==n.ticker.kind&&function(e,t){A(e,t),t.last_idx=O(e,t)}(r,n.ticker)}),r.on("ended",function(){a&&function(e,t){t.ended||(t.ended=!0,I(e,t.ticker))}(r,n)})}}).pluginName="analytics",N),C=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 r=e.flowplayer;return"function"==typeof r?(r(t),t):(Array.isArray(r.extensions)||(r.extensions=[]),~r.extensions.indexOf(t)||r.extensions.push(t),t)}("undefined"!=typeof window?window:void 0!==v?v:{},P);return C});
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.analytics=t())}(this,function(){"use strict";const e=(...e)=>e.reduce((e,t)=>Object.assign(Object.assign({},e),t),{}),t=(e,t)=>{const r=e.lastIndexOf(t);return~r&&e.splice(r,1),e};class RequestQueue{static of(){return new RequestQueue}static is_empty(e){return 0==e.pending.length}static is_high_water(e){return e.open.length==RequestQueue.MAX_OPEN_REQUESTS}static maybe_spawn_req(e){if(RequestQueue.is_empty(e))return e;if(RequestQueue.is_high_water(e))return e;try{const t=RequestQueue.lpop(e);t&&RequestQueue.request(e,t)}catch(e){}}static increment_failures(e){return e.stats.failures++,e.stats.failures>RequestQueue.MAX_FAILURE_COUNT&&(e.stats.ttl=Date.now()+RequestQueue.REQUEST_TTL_MS),e}static handle_error(e,t){RequestQueue.rm(e,t),RequestQueue.increment_failures(e)}static request(e,[t,r,n]){if(Date.now()<e.stats.ttl)return;const i=new XMLHttpRequest;e.open.push(i),i.timeout=RequestQueue.REQUEST_TIMEOUT_MS,i.ontimeout=function(){RequestQueue.handle_error(e,i)},i.onerror=function(t){RequestQueue.handle_error(e,i)},i.onreadystatechange=function(){i.readyState==XMLHttpRequest.DONE&&RequestQueue.rm(e,i),Math.floor(i.status/100)},i.onload=function(){RequestQueue.rm(e,i),e.stats.failures&&e.stats.failures--},i.open(r,t),i.setRequestHeader("Content-Type","text/plain;charset=UTF-8");try{i.send(JSON.stringify(n))}catch(e){}}static rpush(e,...t){return t.forEach(t=>{e.pending.length>=RequestQueue.MAX_PENDING||(e.pending.push(t),RequestQueue.maybe_spawn_req(e))}),e}static lpop(e){return e.pending.shift()}static rm(e,r){return t(e.open,r),e}constructor(){this.pending=[],this.open=[],this.stats={failures:0,ttl:0}}}RequestQueue.MAX_OPEN_REQUESTS=3,RequestQueue.MAX_PENDING=5,RequestQueue.REQUEST_TIMEOUT_MS=4e3,RequestQueue.REQUEST_TTL_MS=5e3,RequestQueue.MAX_FAILURE_COUNT=3;var r=RequestQueue.of();const n=/:([a-zA-Z_]+)/g;class Log{static prepare(e,t){const r=document.createEvent("Event");return r.initEvent(e,!1,!0),r.ns=e,r.data=t,r}static of(e){return new Log(e)}constructor(e){this.emitter=e}info(e){this.emitter.dispatchEvent(Log.prepare(Log.NAMESPACE.INFO,e))}error(e){this.emitter.dispatchEvent(Log.prepare(Log.NAMESPACE.ERROR,e))}warn(e){this.emitter.dispatchEvent(Log.prepare(Log.NAMESPACE.WARN,e))}}var i,o;Log.NAMESPACE={INFO:"tracker:info",ERROR:"tracker:err",WARN:"tracker:warn"},function(e){e.POST="POST",e.PUT="PUT",e.GET="GET"}(i||(i={}));class Tracker{static of(e,t){return new Tracker(e,t)}static ensure_required_keys(e,t){return e.required_keys.filter(e=>!(e in t))}static pluck_valid_keys(t,r){return((t,...r)=>Object.keys(t).filter(e=>~r.indexOf(e)).reduce((r,n)=>e(r,{[n]:t[n]}),{}))(r,...t.valid_keys)}static merge_metadata(t,r={}){return t.metadata=Tracker.pluck_valid_keys(t,e(t.metadata,r)),t}static assert_emitter_api(e){if("function"!=typeof(e||{}).addEventListener)throw new Error("Tracker() received an emitter that does not implement the addEventListener method");if("function"!=typeof(e||{}).removeEventListener)throw new Error("Tracker() received an emitter that does not implement the removeEventListener method")}static create_listener(e,t,r){var n;e.listeners.push([t,r]),null===(n=e.emitter)||void 0===n||n.addEventListener(t,r)}constructor(t,i={}){const o=this;if(this.emitter=t,this.url=i.url,this.log=Log.of(this.emitter),this.verb=i.verb,this.metadata=e({},i.metadata||{}),this.rq=i.rq||r,this.events=i.events||[],this.required_keys=i.required_keys||[],this.optional_keys=i.optional_keys||[],this.listeners=[],this.valid_keys=this.required_keys.slice(0).concat(this.optional_keys),Tracker.assert_emitter_api(this.emitter),void 0===Tracker.verb[this.verb])throw new Error(`invalid HTTP verb[${this.verb}] passed`);if("string"!=typeof this.url)throw new Error(`invalid API url[${this.url}] passed`);Tracker.TRACKERS.push(this),o.events.forEach(t=>{Tracker.create_listener(this,t,(r={})=>{const i=e(o.metadata,{event_type:t},r.data||r),a=function(e,t){return e.replace(n,e=>{const r=e.slice(1,e.length);return r in t?t[r].toString():e})}(o.url,i),s=Tracker.pluck_valid_keys(o,i),u=Tracker.ensure_required_keys(o,s);if(u.length)return o.log.error(`Tracker.validate_metadata() failed for\n Event[${t}]\n missing keys: ${u}\n payload:\n ${JSON.stringify(s,null,2)}`);this.rq&&RequestQueue.rpush(this.rq,[a,this.verb,s])})})}destroy(){this.listeners.forEach(([e,t])=>{var r;return null===(r=this.emitter)||void 0===r?void 0:r.removeEventListener(e,t)}),delete this.rq,delete this.emitter,t(Tracker.TRACKERS,this)}put(e={}){return Tracker.merge_metadata(this,e),this}}Tracker.TRACKERS=[],Tracker.QUEUE=r,Tracker.verb=i,function(e){e[e.ADS=2]="ADS",e[e.ANALYTICS=4]="ANALYTICS",e[e.NO_METERING=8]="NO_METERING",e[e.DEVELOPER_PLAN=16]="DEVELOPER_PLAN",e[e.WOWZA_VIDEO=32]="WOWZA_VIDEO"}(o||(o={}));const a=["localhost","127.0.0.1","0.0.0.0","s.codepen.io","cdpn.io","try.flowplayer.com"];function s(e,t){return!!~a.indexOf(e)||e.indexOf(t)===e.length-t.length}s.check_whitelist=function(e){return!!~a.indexOf(e)};function u(e){this.message=e}u.prototype=new Error,u.prototype.name="InvalidCharacterError";var d="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new u("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,i=0,o=0,a="";n=t.charAt(o++);~n&&(r=i%4?64*r+n:n,i++%4)?a+=String.fromCharCode(255&r>>(-2*i&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return a};var c=function(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(d(e).replace(/(.)/g,function(e,t){var r=t.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r}))}(t)}catch(e){return d(t)}};function l(e){this.message=e}l.prototype=new Error,l.prototype.name="InvalidTokenError";var f=function(e,t){if("string"!=typeof e)throw new l("Invalid token specified");var r=!0===(t=t||{}).header?0:1;try{return JSON.parse(c(e.split(".")[r]))}catch(e){throw new l("Invalid token specified: "+e.message)}};f.InvalidTokenError=l;const p="production";function _(e,t){const r={valid_jwt:!1,raw:"",data:{acl:0},exp:0};let n={c:"{}",exp:0};t=t||{};try{n=f(e),r.valid_jwt=!0}catch(e){}return r.raw=e,r.data=JSON.parse(n.c),r.exp=n.exp,t.require_valid_token&&_.validate(r),r}function h(e){return{grant:e,is_granted:t=>(e&t)===t}}function m(e,t,r){const n=function(e){return Array.isArray(e)?e.slice(0):e.split(".")}(t);for(;n.length;){if(null==e)return r;const t=n.shift();if("string"!=typeof t)return r;e=e[t]}return null==e?r:e}_.validate=function(e){if("string"==typeof e&&(e=_(e)),!e||!e.raw){if(s.check_whitelist(window.location.hostname)||"dev"===p.toString())return!0;throw new Error("No token provided in configuration")}if(!e.valid_jwt)throw new Error("Invalid token provided");const t=window.location.hostname,r=s.bind(null,t);if("dev"!==p.toString()&&e.data.domain&&e.data.domain.length&&!e.data.domain.some(r))throw new Error("Domain not allowed");if("dev"!==p.toString()&&1e3*e.exp-Date.now()<0)throw new Error("Expired token");return!0},_.id=function(e){if(e)return"string"==typeof e&&(e=_(e)),e.data.id},h.of=h,h.from_token=function(e){const t=_(e,{require_valid_token:!0});return h.of(t.data.acl)},h.permissions=o;var v="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};var y="ping",k="display",g="view";const w=["sitegroup_id","session_id","media_id","site_id","player_id","video_type"],E=["created","position"],T=["player_version","created","source","category","category_id","autoplay","muted","customer_user_id"];const R=100,q=1e3;function A(e,t){return e.duration/1===e.duration&&Object.assign(t,function(e){const t=e/R;return{segment_duration:t,breakpoints:Array(...Array(R)).map(function(e,r){return Math.floor(r*t*q)/q})}}(e.duration))}function S(e,t,r){if(!t.segment_duration&&!A(e,t))return;const n=function(e,t,r){const n=t.last_idx,i=r?99:O(e,t);return t.last_idx=i,i<=n?[]:t.breakpoints.slice(n,99==i?100:i).map(function(e){return t.breakpoints.indexOf(e)})}(e,t,r);0!=n.length&&e.emit(y,{position:n})}function O(e,t){return Math.min(Math.floor(e.currentTime/t.segment_duration),99)}function b(){try{const e=window.location!==window.parent.location?document.referrer:document.location.href;return"string"==typeof e&&e.slice(0,200)}catch(e){return!1}}var N;const Q="vod",x="live",L=[k,y,g];function I(e,t,r){switch(null==t?void 0:t.kind){case"live":return function(e,t){const r=Date.now();r-t.last_tracked_ts<6e4||(t.last_tracked_ts=r,++t.ticks,e.emit(y,{position:60*t.ticks}))}(e,t);case"vod":return S(e,t,"boolean"==typeof r&&r)}}function M(e){const t=e.ads;return void 0!==t&&(void 0!==t.schedule&&("function"==typeof t.hasPreroll&&(t.currentRequests?t.currentRequests:!!t.adPlaying||!(!t.hasPreroll()||0!=t.nextIndex))))}const P=((N=class Analytics{init(e,t,r){if(!h.from_token(e.token||"").is_granted(h.permissions.ANALYTICS))return;if(r.hasState("consent-no-tracking"))return;if(r.analytics)return;const n=r.analytics={ticker:void 0,last_media_id:"",ended:!1},i={locked:void 0,ttl:6e3,task:()=>{I(r,n.ticker)}};const o={session_id:r.deviceId(),autoplay:r.autoplay,muted:r.muted,player_id:e.player_id,customer_user_id:e.customer_user_id,player_version:"3.32.1-rc.2"},a=Tracker.of(r,{verb:Tracker.verb.POST,url:"https://ptm.flowplayer.com/:video_type/:sitegroup_id/:event_type",events:L,required_keys:w,optional_keys:T.concat(E).slice(0),metadata:o});r.on("reap",function(){a&&a.destroy()}),r.on("config",function(t){if(!a)return;const i=m(t,"data.metadata",{});if(!i.media_id&&i.stream_target_id&&(i.media_id=i.stream_target_id),!i.media_id)return;const o=m(a,"metadata.media_id");if(o&&i.media_id==o)return;const s=m(e,"analytics",{});a.put(i),a.put(s);const u=m(e,"metadata.live_start_time",e.live)?x:Q;a.put({video_type:u,source:e.source||b()||""}),n.ticker=e.live?{ticks:0,last_tracked_ts:Date.now(),kind:"live"}:{last_idx:0,segment_duration:0,breakpoints:[],kind:"vod"},n.ended=!1,r.emit(k)});let s=0;r.on("playing",function(){if(!a)return;if(s||function(e,t){return e.metadata.media_id&&e.metadata.media_id==t.last_media_id}(a,n))return;a.put({muted:r.muted});const e=M(r);if(e)return s=Promise.resolve(e).then(function(){n.last_media_id=a.metadata.media_id,r.emit(g),s=0}).catch(function(){s=0});n.last_media_id=a.metadata.media_id,r.emit(g)}),r.on("timeupdate",function(){var t;a&&(s||M(r)||n.ended||(!e.live&&r.currentTime+.25>=r.duration&&I(r,n.ticker,!0),(t=i).locked||(t.locked=setTimeout(function(){return t.task(),function(e){return e.locked=void 0,e}(t)},t.ttl))))}),r.on("seeked",function(){a&&n.ticker&&"vod"==n.ticker.kind&&function(e,t){A(e,t),t.last_idx=O(e,t)}(r,n.ticker)}),r.on("ended",function(){a&&function(e,t){t.ended||(t.ended=!0,I(e,t.ticker))}(r,n)})}}).pluginName="analytics",N),C=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 r=e.flowplayer;return"function"==typeof r?(r(t),t):(Array.isArray(r.extensions)||(r.extensions=[]),~r.extensions.indexOf(t)||r.extensions.push(t),t)}("undefined"!=typeof window?window:void 0!==v?v:{},P);return C});
package/plugins/asel.d.ts CHANGED
@@ -2,7 +2,9 @@ import type { Get } from 'type-fest';
2
2
  import type Hls from 'hls.js';
3
3
  import type { Level } from 'hls.js';
4
4
  import type { LevelAttributes } from 'hls.js';
5
+ import type { Paths } from 'type-fest';
5
6
  import type { Representation } from 'dashjs';
7
+ import type { Translation } from '@flowplayer/translations';
6
8
  import type { TupleToUnion } from 'type-fest';
7
9
 
8
10
  /* Excluded from this release type: AnyLoader */
@@ -888,6 +890,13 @@ declare interface FlowplayerUMDBase {
888
890
  /* Excluded from this release type: support */
889
891
  /* Excluded from this release type: jwt */
890
892
  /* Excluded from this release type: loaders */
893
+ /**
894
+ * @public
895
+ * Translations dictionaries to be used with `@flowplayer/translations` package
896
+ *
897
+ * See [official documentation](https://developer.wowza.com/docs/wowza-flowplayer/player/translations/)
898
+ */
899
+ i18n: typeof I18n;
891
900
  }
892
901
 
893
902
  /**
@@ -965,6 +974,112 @@ declare type HasSrcExtensions<PluginBareConfigs extends unknown[]> = TupleToUnio
965
974
 
966
975
  declare const HOVERED = "is-hovered";
967
976
 
977
+ declare class I18n implements Plugin_2 {
978
+ static pluginName: string;
979
+ static en: {
980
+ ads: {
981
+ ad: string;
982
+ ads: string;
983
+ advertisement: string;
984
+ indicator: string;
985
+ adchoices: string;
986
+ };
987
+ audio: {
988
+ button_txt: string;
989
+ menu_title: string;
990
+ };
991
+ cc: {
992
+ button: string;
993
+ menu_title: string;
994
+ options: string;
995
+ tracks: string;
996
+ reset: string;
997
+ colors: {
998
+ Black: string;
999
+ Blue: string;
1000
+ Cyan: string;
1001
+ Green: string;
1002
+ Magenta: string;
1003
+ Red: string;
1004
+ White: string;
1005
+ Yellow: string;
1006
+ };
1007
+ edgeStyle: {
1008
+ None: string;
1009
+ "Drop shadow": string;
1010
+ Raised: string;
1011
+ Depressed: string;
1012
+ Outline: string;
1013
+ };
1014
+ fontFamily: {
1015
+ "Monospaced Serif": string;
1016
+ "Proportional Serif": string;
1017
+ "Monospaced Sans-Serif": string;
1018
+ "Proportional Sans-Serif": string;
1019
+ Casual: string;
1020
+ Cursive: string;
1021
+ };
1022
+ properties: {
1023
+ fontFamily: string;
1024
+ fontSize: string;
1025
+ fontColor: string;
1026
+ fontOpacity: string;
1027
+ backgroundColor: string;
1028
+ backgroundOpacity: string;
1029
+ characterEdgeStyle: string;
1030
+ };
1031
+ };
1032
+ chromecast: {
1033
+ start: string;
1034
+ stop: string;
1035
+ };
1036
+ core: {
1037
+ exit_fullscreen: string;
1038
+ fullscreen: string;
1039
+ mute: string;
1040
+ muted: string;
1041
+ pause: string;
1042
+ play: string;
1043
+ seconds: string;
1044
+ timeline_aria_label: string;
1045
+ unmute: string;
1046
+ volume: string;
1047
+ close: string;
1048
+ "skip-next": string;
1049
+ "skip-prev": string;
1050
+ };
1051
+ ovp: {
1052
+ starting_in: string;
1053
+ };
1054
+ playlist: {
1055
+ cancel: string;
1056
+ up_next: string;
1057
+ autoplay: string;
1058
+ now_playing: string;
1059
+ turn_off_autoplay: string;
1060
+ playlist: string;
1061
+ };
1062
+ qsel: {
1063
+ menu_title: string;
1064
+ };
1065
+ share: {
1066
+ clipboard_failure: string;
1067
+ clipboard_success: string;
1068
+ embed: string;
1069
+ link: string;
1070
+ menu_title: string;
1071
+ };
1072
+ speed: {
1073
+ menu_title: string;
1074
+ };
1075
+ vtsel: {
1076
+ button_txt: string;
1077
+ menu_title: string;
1078
+ };
1079
+ };
1080
+ init(config: Config, _root: never, video: Player): void;
1081
+ }
1082
+
968
1083
  declare const IN_VIEWPORT = "is-in-viewport";
969
1084
 
970
1085
  /* Excluded from this release type: INTERSECTIONCHANGE */
@@ -1325,7 +1440,8 @@ declare type Player = HTMLVideoElement & PlayerEventOverloads & {
1325
1440
  /**
1326
1441
  * Adds a language to the project. See {@link https://developer.wowza.com/docs/wowza-flowplayer/player/translations/#using-npm| Official documentation}
1327
1442
  */
1328
- i18n(k: string, fallback?: string): string;
1443
+ i18n(k: TranslationKey): string;
1444
+ i18n(k: string, fallback: string): string;
1329
1445
  /* Excluded from this release type: deviceId */
1330
1446
  /* Excluded from this release type: live_state */
1331
1447
  /**
@@ -2054,6 +2170,15 @@ declare const TRACKS = "audio:tracks";
2054
2170
  */
2055
2171
  export declare type TracksEventDetail = AudioTrack[];
2056
2172
 
2173
+ /**
2174
+ * @public
2175
+ * All possible full paths to each translation, i.e. "core.mute"| "core.play" | "ads.ad" etc.
2176
+ * This type is useful for developers using translation querying based on path, like in lodash's get()
2177
+ */
2178
+ declare type TranslationKey = Paths<Translation, {
2179
+ leavesOnly: true;
2180
+ }>;
2181
+
2057
2182
  declare type TSampleRate = typeof SampleRate;
2058
2183
 
2059
2184
  declare const TV = "is-tv";
package/plugins/asel.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.asel=t())}(this,function(){"use strict";const e="click",t="audio:set",n="audio:update",s="audio:tracks";var i=Object.freeze({__proto__:null,SET:t,SWITCH:n,TRACKS:s});function o(e,t,n){const s=function(e){return Array.isArray(e)?e.slice(0):e.split(".")}(t);for(;s.length;){if(null==e)return n;const t=s.shift();if("string"!=typeof t)return n;e=e[t]}return null==e?n:e}const r=navigator.languages||[navigator.language];const a="@flowplayer/audio/track";function l(e,n){e.emit(t,n),n.autoselect&&e._storage.setItem(a,n.lang)}function c(e){return e.toLowerCase()}function u(e,t,n){t=t.slice(0);const s={},i=e.getItem(a);let l=function(){try{return r.reduce((e,t)=>~t.indexOf("-")?e.concat(t,t.split("-")[0]):e.concat(t),[])}catch(e){return[]}}().map(c),u=-1;if("number"==typeof n)return n;for("string"==typeof n&&(n=n.toLowerCase(),~l.indexOf(n)&&l.splice(l.indexOf(n),1),l.unshift(c(n))),Array.isArray(n)&&(l=n.map(c));t.length;){++u;const e=t.shift();if(null==e?void 0:e.autoselect){if(i==e.lang)return console.debug("restoring lang from previous session: ",i),u;if(e.default&&(s.fallback=[u,e]),e.lang&&~l.indexOf(e.lang.toLowerCase())){const t=l.indexOf(e.lang);if(t<o(s,"by_lang.2",1/0)&&(s.by_lang=[u,e,t]),0===t)break}}}return o(s,"by_lang.0",o(s,"fallback.0",void 0))}const d=(e,t)=>new(((e,t)=>{const n=e.get(t);if(!n)throw new Error(`no flowplayer component with the name ${t} exists`);const s=window.customElements.get(t);if(!s)throw new Error(`no default flowplayer component with the name ${t} exists`);const i=window.customElements.get(n);return"function"!=typeof i?s:i})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}const m="has-menu-opened",f="fp-menu-container",h="fp-on",p="fp-invis",y="details[open]."+f;class FlowplayerMenu extends FlowplayerComponent{constructor(t){super(t),this.player=t,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=g(),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(f),this.menuContainer.append(this.summaryEle,this.menu),this.menuContainer.addEventListener(e,e=>{if(e.defaultPrevented)return;e.preventDefault();const n=this.menuContainer.open;n||(v(),document.active_menu=this.menuContainer),this.menuContainer.open=!n,t.root.classList.toggle(m,!n),this.summaryEle.setAttribute("aria-expanded",n?"false":"true")}),this.addEventListener("focusin",e=>{e.target;HTMLLIElement}),this.addEventListener("focusout",e=>{e.target;HTMLLIElement}),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||g()),this.summaryEle.setAttribute("aria-label",e.menuTitle||"Menu"),e.summaryTitle&&(this.summaryEle.textContent=e.summaryTitle),e.summaryIcon){const t=d(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(t,n){const s=document.createElement("li");s.setAttribute("tabindex","0"),t.icon&&s.append(t.icon);const i=document.createElement("span");i.textContent=t.text,s.append(i),this.olEle.appendChild(s),t.isButton?(s.setAttribute("role","menuitem"),s.addEventListener(e,()=>{"function"==typeof t.onclick&&t.onclick()})):(s.setAttribute("role","menuitemradio"),s.setAttribute("aria-checked","false"),s.addEventListener(e,()=>{this.select_item(n),"function"==typeof t.onclick&&t.onclick()}),t.selected&&this.select_item(n))}select_item(e){var t;if(!(null===(t=this.options[e])||void 0===t?void 0:t.hasAttribute("aria-checked")))throw new Error("Cannot select a button-only item");this.options.forEach((t,n)=>{t.hasAttribute("aria-checked")&&(t.classList.toggle(h,n===e),t.setAttribute("aria-checked",n===e?"true":"false"))})}unselect_item(){this.options.forEach(e=>{e.classList.remove(h),e.hasAttribute("aria-checked")&&e.setAttribute("aria-checked","false")})}toggle_visibility(e){this.classList.toggle(p,e),this.menu.style.setProperty("display",e?"none":"flex")}}function v(){Array.from(document.querySelectorAll(".fp-engine")).forEach(e=>{var t;const n=e.root.querySelector(y);n&&(n.open=!1,null===(t=n.querySelector("summary"))||void 0===t||t.removeAttribute("aria-expanded"),e.root.classList.toggle(m,!1))})}function g(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function E(e,t,n){const s=function(e,t){const n=new CustomEvent(e,{detail:t,cancelable:!0});return t&&Object.defineProperty(n,"data",{get:()=>t}),n}(t,n);return e.dispatchEvent(s),e}document.addEventListener(e,function(e){this.active_menu&&!e.composedPath().includes(this.active_menu)&&(v(),this.active_menu=void 0)}),function(){let e=!1;try{const t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("testPassive",null,t),window.removeEventListener("testPassive",null,t)}catch(e){}}();const b="flowplayer-audio-menu";var w;const _=((w=class Asel{constructor(e){((e,t,n)=>{window.customElements.get(t)||window.customElements.define(t,n),e.customElements.get(t)||e.customElements.set(t,t)})(e,b,class extends FlowplayerMenu{})}init(e,r,a){if(!1===e.asel)return;let c=[];const m=d(a,b);m instanceof FlowplayerMenu&&m.setMenuAttrs({summaryTitle:a.i18n("audio.button_txt"),menuTitle:a.i18n("audio.menu_title"),class:"fp-asel",options_event:w.events.TRACKS,item_selected_event:w.events.SWITCH});const f=function(e){const n={tracks:[],events:i};return Object.assign(n,{set:function(s){if(!("number"!=typeof s||s<0||s>n.tracks.length-1))return e.emit(t,n.tracks[s]),n},get:function(e){if("number"==typeof e)return n.tracks[e]}}),n}(a);a.asel=f,a.on("mount",function(){var e;null===(e=function(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}(a,a.hasState("is-tv")?"flowplayer-tv-menu":"flowplayer-control"))||void 0===e||e.append(m)}),a.on("src",()=>{f.tracks=[],f.active_track=void 0,E(m,w.events.TRACKS,[])}),a.on(s,function(t){if(!Array.isArray(t.data)||t.data.length===c.length&&t.data.every((e,t)=>e===c[t]))return;c=t.data,f.tracks=c.slice();const n=o(e,"asel.sort");"function"==typeof n&&f.tracks.sort(n),E(m,w.events.TRACKS,Array.from({length:f.tracks.length}).map((e,t)=>{const n=f.tracks[t];return{text:n.name||n.label||n.lang,onclick:l.bind(0,a,n)}})),f.active_track=f.tracks.find(e=>e.enabled),f.active_track&&E(m,w.events.SWITCH,{selected_index:f.tracks.indexOf(f.active_track)});const s=u(a._storage,f.tracks,o(e,"asel.default_lang",!1));return m instanceof FlowplayerMenu&&m.toggle_visibility(t.data.length<2),void 0!==s?f.set(s):void 0}),a.on(n,function(e){var t;null===(t=a.asel)||void 0===t||t.tracks.find((t,n)=>{var s,i;t!==e.detail&&t.id!==(null!==(i=null===(s=e.detail)||void 0===s?void 0:s.id)&&void 0!==i?i:-1)||(a.asel.active_track=t,E(m,w.events.SWITCH,{selected_index:n}))})}),a.audioTracks&&(a.audioTracks.addEventListener("addtrack",function(){a.hls||a.emit(s,Array.from(a.audioTracks))}),a.on(t,function(e){if(a.hls)return;const t=e.detail;f.active_track=t,t&&Array.from(a.audioTracks).forEach(e=>{e.enabled=t.id===e.id,e.enabled&&E(m,w.events.SWITCH,{selected_index:f.tracks.indexOf(t)})})}))}}).pluginName="asel",w.events=i,w);return function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;if(null===document.currentScript)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;return"function"==typeof n?(n(t),t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t),t)}(window,_)});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.asel=t())}(this,function(){"use strict";const e="click",t="audio:set",n="audio:update",s="audio:tracks";var i=Object.freeze({__proto__:null,SET:t,SWITCH:n,TRACKS:s});function o(e,t,n){const s=function(e){return Array.isArray(e)?e.slice(0):e.split(".")}(t);for(;s.length;){if(null==e)return n;const t=s.shift();if("string"!=typeof t)return n;e=e[t]}return null==e?n:e}const r=navigator.languages||[navigator.language];const a="@flowplayer/audio/track";function l(e,n){e.emit(t,n),n.autoselect&&e._storage.setItem(a,n.lang)}function c(e){return e.toLowerCase()}function u(e,t,n){t=t.slice(0);const s={},i=e.getItem(a);let l=function(){try{return r.reduce((e,t)=>~t.indexOf("-")?e.concat(t,t.split("-")[0]):e.concat(t),[])}catch(e){return[]}}().map(c),u=-1;if("number"==typeof n)return n;for("string"==typeof n&&(n=n.toLowerCase(),~l.indexOf(n)&&l.splice(l.indexOf(n),1),l.unshift(c(n))),Array.isArray(n)&&(l=n.map(c));t.length;){++u;const e=t.shift();if(null==e?void 0:e.autoselect){if(i==e.lang)return console.debug("restoring lang from previous session: ",i),u;if(e.default&&(s.fallback=[u,e]),e.lang&&~l.indexOf(e.lang.toLowerCase())){const t=l.indexOf(e.lang);if(t<o(s,"by_lang.2",1/0)&&(s.by_lang=[u,e,t]),0===t)break}}}return o(s,"by_lang.0",o(s,"fallback.0",void 0))}const d=(e,t)=>new(((e,t)=>{const n=e.get(t);if(!n)throw new Error(`no flowplayer component with the name ${t} exists`);const s=window.customElements.get(t);if(!s)throw new Error(`no default flowplayer component with the name ${t} exists`);const i=window.customElements.get(n);return"function"!=typeof i?s:i})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}const m="has-menu-opened",f="fp-menu-container",h="fp-on",p="fp-invis",y="details[open]."+f;class FlowplayerMenu extends FlowplayerComponent{constructor(t){super(t),this.player=t,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=g(),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(f),this.menuContainer.append(this.summaryEle,this.menu),this.menuContainer.addEventListener(e,e=>{if(e.defaultPrevented)return;e.preventDefault();const n=this.menuContainer.open;n||(v(),document.active_menu=this.menuContainer),this.menuContainer.open=!n,t.root.classList.toggle(m,!n),this.summaryEle.setAttribute("aria-expanded",n?"false":"true")}),this.addEventListener("focusin",e=>{e.target;HTMLLIElement}),this.addEventListener("focusout",e=>{e.target;HTMLLIElement}),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||g()),this.summaryEle.setAttribute("aria-label",e.menuTitle||"Menu"),e.summaryTitle&&(this.summaryEle.textContent=e.summaryTitle),e.summaryIcon){const t=d(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(t,n){const s=document.createElement("li");s.setAttribute("tabindex","0"),t.icon&&s.append(t.icon);const i=document.createElement("span");i.textContent=t.text,s.append(i),this.olEle.appendChild(s),t.isButton?(s.setAttribute("role","menuitem"),s.addEventListener(e,()=>{"function"==typeof t.onclick&&t.onclick()})):(s.setAttribute("role","menuitemradio"),s.setAttribute("aria-checked","false"),s.addEventListener(e,()=>{this.select_item(n),"function"==typeof t.onclick&&t.onclick()}),t.selected&&this.select_item(n))}select_item(e){var t;if(this.options[e]&&!(null===(t=this.options[e])||void 0===t?void 0:t.hasAttribute("aria-checked")))throw new Error("Cannot select a button-only item");this.options.forEach((t,n)=>{t.hasAttribute("aria-checked")&&(t.classList.toggle(h,n===e),t.setAttribute("aria-checked",n===e?"true":"false"))})}unselect_item(){this.options.forEach(e=>{e.classList.remove(h),e.hasAttribute("aria-checked")&&e.setAttribute("aria-checked","false")})}toggle_visibility(e){this.classList.toggle(p,e),this.menu.style.setProperty("display",e?"none":"flex")}}function v(){Array.from(document.querySelectorAll(".fp-engine")).forEach(e=>{var t;const n=e.root.querySelector(y);n&&(n.open=!1,null===(t=n.querySelector("summary"))||void 0===t||t.removeAttribute("aria-expanded"),e.root.classList.toggle(m,!1))})}function g(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function E(e,t,n){const s=function(e,t){const n=new CustomEvent(e,{detail:t,cancelable:!0});return t&&Object.defineProperty(n,"data",{get:()=>t}),n}(t,n);return e.dispatchEvent(s),e}document.addEventListener(e,function(e){this.active_menu&&!e.composedPath().includes(this.active_menu)&&(v(),this.active_menu=void 0)}),function(){let e=!1;try{const t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("testPassive",null,t),window.removeEventListener("testPassive",null,t)}catch(e){}}();const b="flowplayer-audio-menu";var w;const _=((w=class Asel{constructor(e){((e,t,n)=>{window.customElements.get(t)||window.customElements.define(t,n),e.customElements.get(t)||e.customElements.set(t,t)})(e,b,class extends FlowplayerMenu{})}init(e,r,a){if(!1===e.asel)return;let c=[];const m=d(a,b);m instanceof FlowplayerMenu&&m.setMenuAttrs({summaryTitle:a.i18n("audio.button_txt"),menuTitle:a.i18n("audio.menu_title"),class:"fp-asel",options_event:w.events.TRACKS,item_selected_event:w.events.SWITCH});const f=function(e){const n={tracks:[],events:i};return Object.assign(n,{set:function(s){if(!("number"!=typeof s||s<0||s>n.tracks.length-1))return e.emit(t,n.tracks[s]),n},get:function(e){if("number"==typeof e)return n.tracks[e]}}),n}(a);a.asel=f,a.on("mount",function(){var e;null===(e=function(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}(a,a.hasState("is-tv")?"flowplayer-tv-menu":"flowplayer-control"))||void 0===e||e.append(m)}),a.on("src",()=>{f.tracks=[],f.active_track=void 0,E(m,w.events.TRACKS,[])}),a.on(s,function(t){if(!Array.isArray(t.data)||t.data.length===c.length&&t.data.every((e,t)=>e===c[t]))return;c=t.data,f.tracks=c.slice();const n=o(e,"asel.sort");"function"==typeof n&&f.tracks.sort(n),E(m,w.events.TRACKS,Array.from({length:f.tracks.length}).map((e,t)=>{const n=f.tracks[t];return{text:n.name||n.label||n.lang,onclick:l.bind(0,a,n)}})),f.active_track=f.tracks.find(e=>e.enabled),f.active_track&&E(m,w.events.SWITCH,{selected_index:f.tracks.indexOf(f.active_track)});const s=u(a._storage,f.tracks,o(e,"asel.default_lang",!1));return m instanceof FlowplayerMenu&&m.toggle_visibility(t.data.length<2),void 0!==s?f.set(s):void 0}),a.on(n,function(e){var t;null===(t=a.asel)||void 0===t||t.tracks.find((t,n)=>{var s,i;t!==e.detail&&t.id!==(null!==(i=null===(s=e.detail)||void 0===s?void 0:s.id)&&void 0!==i?i:-1)||(a.asel.active_track=t,E(m,w.events.SWITCH,{selected_index:n}))})}),a.audioTracks&&(a.audioTracks.addEventListener("addtrack",function(){a.hls||a.emit(s,Array.from(a.audioTracks))}),a.on(t,function(e){if(a.hls)return;const t=e.detail;f.active_track=t,t&&Array.from(a.audioTracks).forEach(e=>{e.enabled=t.id===e.id,e.enabled&&E(m,w.events.SWITCH,{selected_index:f.tracks.indexOf(t)})})}))}}).pluginName="asel",w.events=i,w);return function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;if(null===document.currentScript)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;return"function"==typeof n?(n(t),t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t),t)}(window,_)});