@flowplayer/player 3.17.0-rc.2 → 3.17.1

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 (54) hide show
  1. package/core/events.d.ts +49 -0
  2. package/core/events.js +22 -2
  3. package/core.js +1 -1
  4. package/default.js +1 -1
  5. package/embed.js +2 -2
  6. package/index.d.ts +53 -1
  7. package/package.json +1 -1
  8. package/plugins/ads.d.ts +53 -1
  9. package/plugins/ads.js +2 -2
  10. package/plugins/airplay.d.ts +53 -1
  11. package/plugins/analytics.d.ts +53 -1
  12. package/plugins/analytics.js +1 -1
  13. package/plugins/asel.d.ts +53 -1
  14. package/plugins/audio.d.ts +53 -1
  15. package/plugins/chapters.d.ts +53 -1
  16. package/plugins/chromecast.d.ts +53 -1
  17. package/plugins/chromecast.js +1 -1
  18. package/plugins/comscore.d.ts +53 -1
  19. package/plugins/consent.d.ts +53 -1
  20. package/plugins/context-menu.d.ts +53 -1
  21. package/plugins/cuepoints.d.ts +59 -7
  22. package/plugins/dash.d.ts +53 -1
  23. package/plugins/drm.d.ts +53 -1
  24. package/plugins/endscreen.d.ts +53 -1
  25. package/plugins/fas.d.ts +53 -1
  26. package/plugins/float-on-scroll.d.ts +53 -1
  27. package/plugins/ga4.d.ts +53 -1
  28. package/plugins/gemius.d.ts +53 -1
  29. package/plugins/google-analytics.d.ts +53 -1
  30. package/plugins/health.d.ts +53 -1
  31. package/plugins/health.js +1 -1
  32. package/plugins/hls.d.ts +53 -1
  33. package/plugins/hls.js +1 -1
  34. package/plugins/id3.d.ts +53 -1
  35. package/plugins/iframe.d.ts +53 -1
  36. package/plugins/keyboard.d.ts +53 -1
  37. package/plugins/media-session.d.ts +53 -1
  38. package/plugins/message.d.ts +53 -1
  39. package/plugins/ovp.d.ts +53 -1
  40. package/plugins/playlist.d.ts +53 -1
  41. package/plugins/preview.d.ts +53 -1
  42. package/plugins/qsel.d.ts +53 -1
  43. package/plugins/qul.d.ts +53 -1
  44. package/plugins/rts.d.ts +53 -1
  45. package/plugins/share.d.ts +53 -1
  46. package/plugins/speed.d.ts +53 -1
  47. package/plugins/ssai.d.ts +53 -1
  48. package/plugins/ssai.js +1 -1
  49. package/plugins/subtitles.d.ts +53 -1
  50. package/plugins/thumbnails.d.ts +53 -1
  51. package/plugins/tizen.d.ts +53 -1
  52. package/plugins/vtsel.d.ts +53 -1
  53. package/plugins/webos.d.ts +53 -1
  54. package/util/loader.d.ts +53 -1
@@ -167,6 +167,55 @@ CONTEXT_MENU = "contextmenu";
167
167
  */
168
168
  declare type ContextMenuEventDetail = null;
169
169
 
170
+ /**
171
+ * @public
172
+ * @deprecated
173
+ * when a cuepoint becomes inactive
174
+ */
175
+ declare const /**
176
+ @public
177
+ * when a new player is inserted into the HTML
178
+ */ /**
179
+ * @public
180
+ * @deprecated
181
+ * when a cuepoint becomes inactive
182
+ */
183
+ CUEPOINT_END = "cuepointend";
184
+
185
+ /**
186
+ * @public
187
+ * @deprecated
188
+ * when a cuepoint is active
189
+ */
190
+ declare const /**
191
+ @public
192
+ * when a new player is inserted into the HTML
193
+ */ /**
194
+ * @public
195
+ * @deprecated
196
+ * when a cuepoint is active
197
+ */
198
+ CUEPOINT_START = "cuepointstart";
199
+
200
+ /**
201
+ * @public
202
+ * @deprecated
203
+ * cuepoints parsing is asynchronous
204
+ * you cannot rely on them existing until
205
+ * this event is emitted
206
+ */
207
+ declare const /**
208
+ @public
209
+ * when a new player is inserted into the HTML
210
+ */ /**
211
+ * @public
212
+ * @deprecated
213
+ * cuepoints parsing is asynchronous
214
+ * you cannot rely on them existing until
215
+ * this event is emitted
216
+ */
217
+ CUEPOINTS = "cuepoints";
218
+
170
219
  /**
171
220
  * @public
172
221
  */
@@ -351,7 +400,10 @@ declare namespace events {
351
400
  PORTRAIT,
352
401
  DVR,
353
402
  LIVE,
354
- RECOVER
403
+ RECOVER,
404
+ CUEPOINTS,
405
+ CUEPOINT_START,
406
+ CUEPOINT_END
355
407
  }
356
408
  }
357
409
 
@@ -163,6 +163,55 @@ CONTEXT_MENU = "contextmenu";
163
163
  */
164
164
  declare type ContextMenuEventDetail = null;
165
165
 
166
+ /**
167
+ * @public
168
+ * @deprecated
169
+ * when a cuepoint becomes inactive
170
+ */
171
+ declare const /**
172
+ @public
173
+ * when a new player is inserted into the HTML
174
+ */ /**
175
+ * @public
176
+ * @deprecated
177
+ * when a cuepoint becomes inactive
178
+ */
179
+ CUEPOINT_END = "cuepointend";
180
+
181
+ /**
182
+ * @public
183
+ * @deprecated
184
+ * when a cuepoint is active
185
+ */
186
+ declare const /**
187
+ @public
188
+ * when a new player is inserted into the HTML
189
+ */ /**
190
+ * @public
191
+ * @deprecated
192
+ * when a cuepoint is active
193
+ */
194
+ CUEPOINT_START = "cuepointstart";
195
+
196
+ /**
197
+ * @public
198
+ * @deprecated
199
+ * cuepoints parsing is asynchronous
200
+ * you cannot rely on them existing until
201
+ * this event is emitted
202
+ */
203
+ declare const /**
204
+ @public
205
+ * when a new player is inserted into the HTML
206
+ */ /**
207
+ * @public
208
+ * @deprecated
209
+ * cuepoints parsing is asynchronous
210
+ * you cannot rely on them existing until
211
+ * this event is emitted
212
+ */
213
+ CUEPOINTS = "cuepoints";
214
+
166
215
  /**
167
216
  * @public
168
217
  */
@@ -347,7 +396,10 @@ declare namespace events {
347
396
  PORTRAIT,
348
397
  DVR,
349
398
  LIVE,
350
- RECOVER
399
+ RECOVER,
400
+ CUEPOINTS,
401
+ CUEPOINT_START,
402
+ CUEPOINT_END
351
403
  }
352
404
  }
353
405
 
@@ -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";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function t(e){var t={exports:{}};return e(t,t.exports),t.exports}var n,r=t((function(t,n){var r=e&&e.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};n.__esModule=!0,n.remove=n.downcase=n.pluck=n.merge=void 0,n.merge=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e.reduce((function(e,t){return r(r({},e),t)}),{})},n.pluck=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return Object.keys(e).filter((function(e){return~t.indexOf(e)})).reduce((function(t,r){var i;return n.merge(t,((i={})[r]=e[r],i))}),{})},n.downcase=function(e){return(e||"").toString().toLowerCase()},n.remove=function(e,t){var n=e.lastIndexOf(t);return~n&&e.splice(n,1),e}})),i=t((function(t,n){var i=e&&e.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=e&&e.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.hasOwnProperty.call(e,n)&&i(t,e,n);return o(t,e),t};n.__esModule=!0;var u=a(r),s=function(){function e(){this.pending=[],this.open=[],this.stats={failures:0,ttl:0}}return e.of=function(){return new e},e.is_empty=function(e){return 0==e.pending.length},e.is_high_water=function(t){return t.open.length==e.MAX_OPEN_REQUESTS},e.maybe_spawn_req=function(t){if(e.is_empty(t))return t;if(e.is_high_water(t))return t;try{var n=e.lpop(t);n&&e.request(t,n)}catch(e){}},e.increment_failures=function(t){return t.stats.failures++,t.stats.failures>e.MAX_FAILURE_COUNT&&(t.stats.ttl=Date.now()+e.REQUEST_TTL_MS),t},e.handle_error=function(t,n){e.rm(t,n),e.increment_failures(t)},e.request=function(t,n){var r=n[0],i=n[1],o=n[2];if(!(Date.now()<t.stats.ttl)){var a=new XMLHttpRequest;t.open.push(a),a.timeout=e.REQUEST_TIMEOUT_MS,a.ontimeout=function(){e.handle_error(t,a)},a.onerror=function(n){e.handle_error(t,a)},a.onreadystatechange=function(){a.readyState==XMLHttpRequest.DONE&&e.rm(t,a),Math.floor(a.status/100)},a.onload=function(){e.rm(t,a),t.stats.failures&&t.stats.failures--},a.open(i,r),a.setRequestHeader("Content-Type","text/plain;charset=UTF-8");try{a.send(JSON.stringify(o))}catch(e){}}},e.rpush=function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];return n.forEach((function(n){t.pending.length>=e.MAX_PENDING||(t.pending.push(n),e.maybe_spawn_req(t))})),t},e.lpop=function(e){return e.pending.shift()},e.rm=function(e,t){return u.remove(e.open,t),e},e.MAX_OPEN_REQUESTS=3,e.MAX_PENDING=5,e.REQUEST_TIMEOUT_MS=4e3,e.REQUEST_TTL_MS=5e3,e.MAX_FAILURE_COUNT=3,e}();n.default=s})),o=t((function(t,n){var r=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};n.__esModule=!0;var o=r(i);n.default=o.default.of()})),a=t((function(e,t){t.__esModule=!0,t.prepare_url=t.URL_PARAM=void 0,t.URL_PARAM=/:([a-zA-Z_]+)/g,t.prepare_url=function(e,n){return e.url.replace(t.URL_PARAM,(function(t){if((t=t.slice(1,t.length))in n)return n[t].toString();e.log.error(new Error("\n preparing url["+e.url+"] failed\n \n parameter["+t+"] not detected in params:\n \n "+JSON.stringify(n,null,2)+"\n "))}))}})),u=t((function(e,t){t.__esModule=!0,t.Log=void 0;var n=function(){function e(e){this.emitter=e}return e.prepare=function(e,t){var n=document.createEvent("Event");return n.initEvent(e,!1,!0),n.ns=e,n.data=t,n},e.of=function(t){return new e(t)},e.prototype.info=function(t){this.emitter.dispatchEvent(e.prepare(e.NAMESPACE.INFO,t))},e.prototype.error=function(t){this.emitter.dispatchEvent(e.prepare(e.NAMESPACE.ERROR,t))},e.prototype.warn=function(t){this.emitter.dispatchEvent(e.prepare(e.NAMESPACE.WARN,t))},e.NAMESPACE={INFO:"tracker:info",ERROR:"tracker:err",WARN:"tracker:warn"},e}();t.Log=n})),s=t((function(e,t){var n;t.__esModule=!0,t.Verb=void 0,(n=t.Verb||(t.Verb={})).POST="POST",n.PUT="PUT",n.GET="GET"})),d=t((function(t,n){var d=e&&e.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),c=e&&e.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),f=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.hasOwnProperty.call(e,n)&&d(t,e,n);return c(t,e),t},l=e&&e.__spreadArrays||function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),i=0;for(t=0;t<n;t++)for(var o=arguments[t],a=0,u=o.length;a<u;a++,i++)r[i]=o[a];return r},p=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};n.__esModule=!0;var _=p(o),v=p(i),m=f(a),h=f(r),y=function(){function e(t,n){var r=this;void 0===n&&(n={});var i=this;if(this.emitter=t,this.url=n.url,this.log=u.Log.of(this.emitter),this.verb=n.verb,this.metadata=h.merge({},n.metadata||{}),this.rq=n.rq||_.default,this.events=n.events||[],this.required_keys=n.required_keys||[],this.optional_keys=n.optional_keys||[],this.listeners=[],this.valid_keys=this.required_keys.slice(0).concat(this.optional_keys),e.assert_emitter_api(this.emitter),void 0===e.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");e.TRACKERS.push(this),i.events.forEach((function(t){e.create_listener(r,t,(function(n){void 0===n&&(n={});var o=h.merge(i.metadata,{event_type:t},n.data||n),a=m.prepare_url(i,o),u=e.pluck_valid_keys(i,o),s=e.ensure_required_keys(i,u);if(s.length)return i.log.error("Tracker.validate_metadata() failed for \n Event["+t+"]\n missing keys: "+s+"\n payload:\n "+JSON.stringify(u,null,2));v.default.rpush(r.rq,[a,r.verb,u])}))}))}return e.of=function(t,n){return new e(t,n)},e.ensure_required_keys=function(e,t){return e.required_keys.filter((function(e){return!(e in t)}))},e.pluck_valid_keys=function(e,t){return h.pluck.apply(h,l([t],e.valid_keys))},e.merge_metadata=function(t,n){return void 0===n&&(n={}),t.metadata=e.pluck_valid_keys(t,h.merge(t.metadata,n)),t},e.assert_emitter_api=function(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")},e.create_listener=function(e,t,n){e.listeners.push([t,n]),e.emitter.addEventListener(t,n)},e.prototype.destroy=function(){var t=this;this.listeners.forEach((function(e){var n=e[0],r=e[1];return t.emitter.removeEventListener(n,r)})),delete this.rq,delete this.emitter,h.remove(e.TRACKERS,this)},e.prototype.put=function(t){return void 0===t&&(t={}),e.merge_metadata(this,t),this},e.TRACKERS=[],e.QUEUE=_.default,e.verb=s.Verb,e}();n.default=y})),c=t((function(t,n){var r=e&&e.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=e&&e.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.hasOwnProperty.call(e,n)&&r(t,e,n);return i(t,e),t},u=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};n.__esModule=!0,n.API=n.Tracker=void 0;var s=u(d);n.Tracker=s.default;var c=o(a);n.API=c}));!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"}(n||(n={}));const f=["localhost","127.0.0.1","0.0.0.0","s.codepen.io","cdpn.io","try.flowplayer.com"];function l(e,t){return!!~f.indexOf(e)||e.indexOf(t)===e.length-t.length}l.check_whitelist=function(e){return!!~f.indexOf(e)};function p(e){this.message=e}p.prototype=new Error,p.prototype.name="InvalidCharacterError";var _="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new p("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,r,i=0,o=0,a="";r=t.charAt(o++);~r&&(n=i%4?64*n+r:r,i++%4)?a+=String.fromCharCode(255&n>>(-2*i&6)):0)r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(r);return a};var v=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(_(e).replace(/(.)/g,(function(e,t){var n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return _(t)}};function m(e){this.message=e}m.prototype=new Error,m.prototype.name="InvalidTokenError";var h=function(e,t){if("string"!=typeof e)throw new m("Invalid token specified");var n=!0===(t=t||{}).header?0:1;try{return JSON.parse(v(e.split(".")[n]))}catch(e){throw new m("Invalid token specified: "+e.message)}};h.InvalidTokenError=m;const y="production";function g(e,t){const n={valid_jwt:!1,raw:"",data:{acl:0},exp:0};let r={c:"{}",exp:0};t=t||{};try{r=h(e),n.valid_jwt=!0}catch(e){}return n.raw=e,n.data=JSON.parse(r.c),n.exp=r.exp,t.require_valid_token&&g.validate(n),n}function w(e){return{grant:e,is_granted:t=>(e&t)===t}}function k(e,t,n){const r=function(e){return Array.isArray(e)?e.slice(0):e.split(".")}(t);for(;r.length;){if(null==e)return n;const t=r.shift();if("string"!=typeof t)return n;e=e[t]}return null==e?n:e}g.validate=function(e){if("string"==typeof e&&(e=g(e)),!e||!e.raw){if(l.check_whitelist(window.location.hostname)||"dev"===y.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,n=l.bind(null,t);if("dev"!==y.toString()&&e.data.domain&&e.data.domain.length&&!e.data.domain.some(n))throw new Error("Domain not allowed");if("dev"!==y.toString()&&1e3*e.exp-Date.now()<0)throw new Error("Expired token");return!0},g.id=function(e){if(e)return"string"==typeof e&&(e=g(e)),e.data.id},w.of=w,w.from_token=function(e){const t=g(e,{require_valid_token:!0});return w.of(t.data.acl)},w.permissions=n;var E="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};var b="ping",O="display",A="view";const T=["sitegroup_id","session_id","media_id","site_id","player_id","video_type"],S=["created","position"],M=["player_version","created","source","category","category_id","autoplay","muted","customer_user_id"];function P(e,t){return e.duration/1===e.duration&&Object.assign(t,function(e){const t=e/100;return{segment_duration:t,breakpoints:Array(...Array(100)).map((function(e,n){return Math.floor(n*t*1e3)/1e3}))}}(e.duration))}function R(e,t,n){if(!t.segment_duration&&!P(e,t))return;const r=function(e,t,n){const r=t.last_idx,i=n?99:x(e,t);return t.last_idx=i,i<=r?[]:t.breakpoints.slice(r,99==i?100:i).map((function(e){return t.breakpoints.indexOf(e)}))}(e,t,n);0!=r.length&&e.emit(b,{position:r})}function x(e,t){return Math.min(Math.floor(e.currentTime/t.segment_duration),99)}function N(){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}}const I="vod",L="live",j=[O,b,A];function q(e,t,n){switch(null==t?void 0:t.kind){case"live":return function(e,t){const n=Date.now();n-t.last_tracked_ts<6e4||(t.last_tracked_ts=n,++t.ticks,e.emit(b,{position:60*t.ticks}))}(e,t);case"vod":return R(e,t,"boolean"==typeof n&&n)}}function U(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))))}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)}("undefined"!=typeof window?window:void 0!==E?E:{},class Analytics{init(e,t,n){if(!w.from_token(e.token||"").is_granted(w.permissions.ANALYTICS))return;if(n.hasState("consent-no-tracking"))return;if(n.analytics)return;const r=n.analytics={ticker:void 0,last_media_id:"",ended:!1},i={locked:!1,ttl:6e3,task:()=>{q(n,r.ticker)}};const o={session_id:n.deviceId(),autoplay:n.autoplay,muted:n.muted,player_id:e.player_id,customer_user_id:e.customer_user_id,player_version:"3.17.0-rc.2"},a=c.Tracker.of(n,{verb:c.Tracker.verb.POST,url:"https://ptm.flowplayer.com/:video_type/:sitegroup_id/:event_type",events:j,required_keys:T,optional_keys:M.concat(S).slice(0),metadata:o});n.on("reap",(function(){a&&a.destroy()})),n.on("config",(function(t){if(!a)return;const i=k(t,"data.metadata",{});if(!i.media_id)return;const o=k(a,"metadata.media_id");if(o&&i.media_id==o)return;const u=k(e,"analytics",{});a.put(i),a.put(u);const s=k(e,"metadata.live_start_time",e.live)?L:I;a.put({video_type:s,source:e.source||N()||""}),r.ticker=e.live?{ticks:0,last_tracked_ts:Date.now(),kind:"live"}:{last_idx:0,segment_duration:0,breakpoints:[],kind:"vod"},r.ended=!1,n.emit(O)}));let u=0;n.on("playing",(function(){if(!a)return;if(u||function(e,t){return e.metadata.media_id&&e.metadata.media_id==t.last_media_id}(a,r))return;a.put({muted:n.muted});const e=U(n);if(e)return u=Promise.resolve(e).then((function(){r.last_media_id=a.metadata.media_id,n.emit(A),u=0})).catch((function(){u=0}));r.last_media_id=a.metadata.media_id,n.emit(A)})),n.on("timeupdate",(function(){var t;a&&(u||U(n)||r.ended||(!e.live&&n.currentTime+.25>=n.duration&&q(n,r.ticker,!0),(t=i).locked||(t.locked=setTimeout((function(){return t.task(),function(e){return e.locked=!1,e}(t)}),t.ttl))))})),n.on("seeked",(function(){a&&r.ticker&&"vod"==r.ticker.kind&&function(e,t){P(e,t),t.last_idx=x(e,t)}(n,r.ticker)})),n.on("ended",(function(){a&&function(e,t){t.ended||(t.ended=!0,q(e,t.ticker))}(n,r)}))}})}));
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";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function t(e){var t={exports:{}};return e(t,t.exports),t.exports}var n,r=t((function(t,n){var r=e&&e.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};n.__esModule=!0,n.remove=n.downcase=n.pluck=n.merge=void 0,n.merge=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e.reduce((function(e,t){return r(r({},e),t)}),{})},n.pluck=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return Object.keys(e).filter((function(e){return~t.indexOf(e)})).reduce((function(t,r){var i;return n.merge(t,((i={})[r]=e[r],i))}),{})},n.downcase=function(e){return(e||"").toString().toLowerCase()},n.remove=function(e,t){var n=e.lastIndexOf(t);return~n&&e.splice(n,1),e}})),i=t((function(t,n){var i=e&&e.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=e&&e.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.hasOwnProperty.call(e,n)&&i(t,e,n);return o(t,e),t};n.__esModule=!0;var u=a(r),s=function(){function e(){this.pending=[],this.open=[],this.stats={failures:0,ttl:0}}return e.of=function(){return new e},e.is_empty=function(e){return 0==e.pending.length},e.is_high_water=function(t){return t.open.length==e.MAX_OPEN_REQUESTS},e.maybe_spawn_req=function(t){if(e.is_empty(t))return t;if(e.is_high_water(t))return t;try{var n=e.lpop(t);n&&e.request(t,n)}catch(e){}},e.increment_failures=function(t){return t.stats.failures++,t.stats.failures>e.MAX_FAILURE_COUNT&&(t.stats.ttl=Date.now()+e.REQUEST_TTL_MS),t},e.handle_error=function(t,n){e.rm(t,n),e.increment_failures(t)},e.request=function(t,n){var r=n[0],i=n[1],o=n[2];if(!(Date.now()<t.stats.ttl)){var a=new XMLHttpRequest;t.open.push(a),a.timeout=e.REQUEST_TIMEOUT_MS,a.ontimeout=function(){e.handle_error(t,a)},a.onerror=function(n){e.handle_error(t,a)},a.onreadystatechange=function(){a.readyState==XMLHttpRequest.DONE&&e.rm(t,a),Math.floor(a.status/100)},a.onload=function(){e.rm(t,a),t.stats.failures&&t.stats.failures--},a.open(i,r),a.setRequestHeader("Content-Type","text/plain;charset=UTF-8");try{a.send(JSON.stringify(o))}catch(e){}}},e.rpush=function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];return n.forEach((function(n){t.pending.length>=e.MAX_PENDING||(t.pending.push(n),e.maybe_spawn_req(t))})),t},e.lpop=function(e){return e.pending.shift()},e.rm=function(e,t){return u.remove(e.open,t),e},e.MAX_OPEN_REQUESTS=3,e.MAX_PENDING=5,e.REQUEST_TIMEOUT_MS=4e3,e.REQUEST_TTL_MS=5e3,e.MAX_FAILURE_COUNT=3,e}();n.default=s})),o=t((function(t,n){var r=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};n.__esModule=!0;var o=r(i);n.default=o.default.of()})),a=t((function(e,t){t.__esModule=!0,t.prepare_url=t.URL_PARAM=void 0,t.URL_PARAM=/:([a-zA-Z_]+)/g,t.prepare_url=function(e,n){return e.url.replace(t.URL_PARAM,(function(t){if((t=t.slice(1,t.length))in n)return n[t].toString();e.log.error(new Error("\n preparing url["+e.url+"] failed\n \n parameter["+t+"] not detected in params:\n \n "+JSON.stringify(n,null,2)+"\n "))}))}})),u=t((function(e,t){t.__esModule=!0,t.Log=void 0;var n=function(){function e(e){this.emitter=e}return e.prepare=function(e,t){var n=document.createEvent("Event");return n.initEvent(e,!1,!0),n.ns=e,n.data=t,n},e.of=function(t){return new e(t)},e.prototype.info=function(t){this.emitter.dispatchEvent(e.prepare(e.NAMESPACE.INFO,t))},e.prototype.error=function(t){this.emitter.dispatchEvent(e.prepare(e.NAMESPACE.ERROR,t))},e.prototype.warn=function(t){this.emitter.dispatchEvent(e.prepare(e.NAMESPACE.WARN,t))},e.NAMESPACE={INFO:"tracker:info",ERROR:"tracker:err",WARN:"tracker:warn"},e}();t.Log=n})),s=t((function(e,t){var n;t.__esModule=!0,t.Verb=void 0,(n=t.Verb||(t.Verb={})).POST="POST",n.PUT="PUT",n.GET="GET"})),d=t((function(t,n){var d=e&&e.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),c=e&&e.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),f=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.hasOwnProperty.call(e,n)&&d(t,e,n);return c(t,e),t},l=e&&e.__spreadArrays||function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),i=0;for(t=0;t<n;t++)for(var o=arguments[t],a=0,u=o.length;a<u;a++,i++)r[i]=o[a];return r},p=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};n.__esModule=!0;var _=p(o),v=p(i),m=f(a),h=f(r),y=function(){function e(t,n){var r=this;void 0===n&&(n={});var i=this;if(this.emitter=t,this.url=n.url,this.log=u.Log.of(this.emitter),this.verb=n.verb,this.metadata=h.merge({},n.metadata||{}),this.rq=n.rq||_.default,this.events=n.events||[],this.required_keys=n.required_keys||[],this.optional_keys=n.optional_keys||[],this.listeners=[],this.valid_keys=this.required_keys.slice(0).concat(this.optional_keys),e.assert_emitter_api(this.emitter),void 0===e.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");e.TRACKERS.push(this),i.events.forEach((function(t){e.create_listener(r,t,(function(n){void 0===n&&(n={});var o=h.merge(i.metadata,{event_type:t},n.data||n),a=m.prepare_url(i,o),u=e.pluck_valid_keys(i,o),s=e.ensure_required_keys(i,u);if(s.length)return i.log.error("Tracker.validate_metadata() failed for \n Event["+t+"]\n missing keys: "+s+"\n payload:\n "+JSON.stringify(u,null,2));v.default.rpush(r.rq,[a,r.verb,u])}))}))}return e.of=function(t,n){return new e(t,n)},e.ensure_required_keys=function(e,t){return e.required_keys.filter((function(e){return!(e in t)}))},e.pluck_valid_keys=function(e,t){return h.pluck.apply(h,l([t],e.valid_keys))},e.merge_metadata=function(t,n){return void 0===n&&(n={}),t.metadata=e.pluck_valid_keys(t,h.merge(t.metadata,n)),t},e.assert_emitter_api=function(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")},e.create_listener=function(e,t,n){e.listeners.push([t,n]),e.emitter.addEventListener(t,n)},e.prototype.destroy=function(){var t=this;this.listeners.forEach((function(e){var n=e[0],r=e[1];return t.emitter.removeEventListener(n,r)})),delete this.rq,delete this.emitter,h.remove(e.TRACKERS,this)},e.prototype.put=function(t){return void 0===t&&(t={}),e.merge_metadata(this,t),this},e.TRACKERS=[],e.QUEUE=_.default,e.verb=s.Verb,e}();n.default=y})),c=t((function(t,n){var r=e&&e.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=e&&e.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.hasOwnProperty.call(e,n)&&r(t,e,n);return i(t,e),t},u=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};n.__esModule=!0,n.API=n.Tracker=void 0;var s=u(d);n.Tracker=s.default;var c=o(a);n.API=c}));!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"}(n||(n={}));const f=["localhost","127.0.0.1","0.0.0.0","s.codepen.io","cdpn.io","try.flowplayer.com"];function l(e,t){return!!~f.indexOf(e)||e.indexOf(t)===e.length-t.length}l.check_whitelist=function(e){return!!~f.indexOf(e)};function p(e){this.message=e}p.prototype=new Error,p.prototype.name="InvalidCharacterError";var _="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new p("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,r,i=0,o=0,a="";r=t.charAt(o++);~r&&(n=i%4?64*n+r:r,i++%4)?a+=String.fromCharCode(255&n>>(-2*i&6)):0)r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(r);return a};var v=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(_(e).replace(/(.)/g,(function(e,t){var n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return _(t)}};function m(e){this.message=e}m.prototype=new Error,m.prototype.name="InvalidTokenError";var h=function(e,t){if("string"!=typeof e)throw new m("Invalid token specified");var n=!0===(t=t||{}).header?0:1;try{return JSON.parse(v(e.split(".")[n]))}catch(e){throw new m("Invalid token specified: "+e.message)}};h.InvalidTokenError=m;const y="production";function g(e,t){const n={valid_jwt:!1,raw:"",data:{acl:0},exp:0};let r={c:"{}",exp:0};t=t||{};try{r=h(e),n.valid_jwt=!0}catch(e){}return n.raw=e,n.data=JSON.parse(r.c),n.exp=r.exp,t.require_valid_token&&g.validate(n),n}function w(e){return{grant:e,is_granted:t=>(e&t)===t}}function k(e,t,n){const r=function(e){return Array.isArray(e)?e.slice(0):e.split(".")}(t);for(;r.length;){if(null==e)return n;const t=r.shift();if("string"!=typeof t)return n;e=e[t]}return null==e?n:e}g.validate=function(e){if("string"==typeof e&&(e=g(e)),!e||!e.raw){if(l.check_whitelist(window.location.hostname)||"dev"===y.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,n=l.bind(null,t);if("dev"!==y.toString()&&e.data.domain&&e.data.domain.length&&!e.data.domain.some(n))throw new Error("Domain not allowed");if("dev"!==y.toString()&&1e3*e.exp-Date.now()<0)throw new Error("Expired token");return!0},g.id=function(e){if(e)return"string"==typeof e&&(e=g(e)),e.data.id},w.of=w,w.from_token=function(e){const t=g(e,{require_valid_token:!0});return w.of(t.data.acl)},w.permissions=n;var E="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};var b="ping",O="display",A="view";const T=["sitegroup_id","session_id","media_id","site_id","player_id","video_type"],S=["created","position"],M=["player_version","created","source","category","category_id","autoplay","muted","customer_user_id"];function P(e,t){return e.duration/1===e.duration&&Object.assign(t,function(e){const t=e/100;return{segment_duration:t,breakpoints:Array(...Array(100)).map((function(e,n){return Math.floor(n*t*1e3)/1e3}))}}(e.duration))}function R(e,t,n){if(!t.segment_duration&&!P(e,t))return;const r=function(e,t,n){const r=t.last_idx,i=n?99:x(e,t);return t.last_idx=i,i<=r?[]:t.breakpoints.slice(r,99==i?100:i).map((function(e){return t.breakpoints.indexOf(e)}))}(e,t,n);0!=r.length&&e.emit(b,{position:r})}function x(e,t){return Math.min(Math.floor(e.currentTime/t.segment_duration),99)}function N(){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}}const I="vod",L="live",j=[O,b,A];function q(e,t,n){switch(null==t?void 0:t.kind){case"live":return function(e,t){const n=Date.now();n-t.last_tracked_ts<6e4||(t.last_tracked_ts=n,++t.ticks,e.emit(b,{position:60*t.ticks}))}(e,t);case"vod":return R(e,t,"boolean"==typeof n&&n)}}function U(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))))}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)}("undefined"!=typeof window?window:void 0!==E?E:{},class Analytics{init(e,t,n){if(!w.from_token(e.token||"").is_granted(w.permissions.ANALYTICS))return;if(n.hasState("consent-no-tracking"))return;if(n.analytics)return;const r=n.analytics={ticker:void 0,last_media_id:"",ended:!1},i={locked:!1,ttl:6e3,task:()=>{q(n,r.ticker)}};const o={session_id:n.deviceId(),autoplay:n.autoplay,muted:n.muted,player_id:e.player_id,customer_user_id:e.customer_user_id,player_version:"3.17.1"},a=c.Tracker.of(n,{verb:c.Tracker.verb.POST,url:"https://ptm.flowplayer.com/:video_type/:sitegroup_id/:event_type",events:j,required_keys:T,optional_keys:M.concat(S).slice(0),metadata:o});n.on("reap",(function(){a&&a.destroy()})),n.on("config",(function(t){if(!a)return;const i=k(t,"data.metadata",{});if(!i.media_id)return;const o=k(a,"metadata.media_id");if(o&&i.media_id==o)return;const u=k(e,"analytics",{});a.put(i),a.put(u);const s=k(e,"metadata.live_start_time",e.live)?L:I;a.put({video_type:s,source:e.source||N()||""}),r.ticker=e.live?{ticks:0,last_tracked_ts:Date.now(),kind:"live"}:{last_idx:0,segment_duration:0,breakpoints:[],kind:"vod"},r.ended=!1,n.emit(O)}));let u=0;n.on("playing",(function(){if(!a)return;if(u||function(e,t){return e.metadata.media_id&&e.metadata.media_id==t.last_media_id}(a,r))return;a.put({muted:n.muted});const e=U(n);if(e)return u=Promise.resolve(e).then((function(){r.last_media_id=a.metadata.media_id,n.emit(A),u=0})).catch((function(){u=0}));r.last_media_id=a.metadata.media_id,n.emit(A)})),n.on("timeupdate",(function(){var t;a&&(u||U(n)||r.ended||(!e.live&&n.currentTime+.25>=n.duration&&q(n,r.ticker,!0),(t=i).locked||(t.locked=setTimeout((function(){return t.task(),function(e){return e.locked=!1,e}(t)}),t.ttl))))})),n.on("seeked",(function(){a&&r.ticker&&"vod"==r.ticker.kind&&function(e,t){P(e,t),t.last_idx=x(e,t)}(n,r.ticker)})),n.on("ended",(function(){a&&function(e,t){t.ended||(t.ended=!0,q(e,t.ticker))}(n,r)}))}})}));
package/plugins/asel.d.ts CHANGED
@@ -272,6 +272,55 @@ CONTEXT_MENU = "contextmenu";
272
272
  */
273
273
  declare type ContextMenuEventDetail = null;
274
274
 
275
+ /**
276
+ * @public
277
+ * @deprecated
278
+ * when a cuepoint becomes inactive
279
+ */
280
+ declare const /**
281
+ @public
282
+ * when a new player is inserted into the HTML
283
+ */ /**
284
+ * @public
285
+ * @deprecated
286
+ * when a cuepoint becomes inactive
287
+ */
288
+ CUEPOINT_END = "cuepointend";
289
+
290
+ /**
291
+ * @public
292
+ * @deprecated
293
+ * when a cuepoint is active
294
+ */
295
+ declare const /**
296
+ @public
297
+ * when a new player is inserted into the HTML
298
+ */ /**
299
+ * @public
300
+ * @deprecated
301
+ * when a cuepoint is active
302
+ */
303
+ CUEPOINT_START = "cuepointstart";
304
+
305
+ /**
306
+ * @public
307
+ * @deprecated
308
+ * cuepoints parsing is asynchronous
309
+ * you cannot rely on them existing until
310
+ * this event is emitted
311
+ */
312
+ declare const /**
313
+ @public
314
+ * when a new player is inserted into the HTML
315
+ */ /**
316
+ * @public
317
+ * @deprecated
318
+ * cuepoints parsing is asynchronous
319
+ * you cannot rely on them existing until
320
+ * this event is emitted
321
+ */
322
+ CUEPOINTS = "cuepoints";
323
+
275
324
  /**
276
325
  * @public
277
326
  */
@@ -456,7 +505,10 @@ declare namespace events {
456
505
  PORTRAIT,
457
506
  DVR,
458
507
  LIVE,
459
- RECOVER
508
+ RECOVER,
509
+ CUEPOINTS,
510
+ CUEPOINT_START,
511
+ CUEPOINT_END
460
512
  }
461
513
  }
462
514
 
@@ -163,6 +163,55 @@ CONTEXT_MENU = "contextmenu";
163
163
  */
164
164
  declare type ContextMenuEventDetail = null;
165
165
 
166
+ /**
167
+ * @public
168
+ * @deprecated
169
+ * when a cuepoint becomes inactive
170
+ */
171
+ declare const /**
172
+ @public
173
+ * when a new player is inserted into the HTML
174
+ */ /**
175
+ * @public
176
+ * @deprecated
177
+ * when a cuepoint becomes inactive
178
+ */
179
+ CUEPOINT_END = "cuepointend";
180
+
181
+ /**
182
+ * @public
183
+ * @deprecated
184
+ * when a cuepoint is active
185
+ */
186
+ declare const /**
187
+ @public
188
+ * when a new player is inserted into the HTML
189
+ */ /**
190
+ * @public
191
+ * @deprecated
192
+ * when a cuepoint is active
193
+ */
194
+ CUEPOINT_START = "cuepointstart";
195
+
196
+ /**
197
+ * @public
198
+ * @deprecated
199
+ * cuepoints parsing is asynchronous
200
+ * you cannot rely on them existing until
201
+ * this event is emitted
202
+ */
203
+ declare const /**
204
+ @public
205
+ * when a new player is inserted into the HTML
206
+ */ /**
207
+ * @public
208
+ * @deprecated
209
+ * cuepoints parsing is asynchronous
210
+ * you cannot rely on them existing until
211
+ * this event is emitted
212
+ */
213
+ CUEPOINTS = "cuepoints";
214
+
166
215
  /**
167
216
  * @public
168
217
  */
@@ -347,7 +396,10 @@ declare namespace events {
347
396
  PORTRAIT,
348
397
  DVR,
349
398
  LIVE,
350
- RECOVER
399
+ RECOVER,
400
+ CUEPOINTS,
401
+ CUEPOINT_START,
402
+ CUEPOINT_END
351
403
  }
352
404
  }
353
405
 
@@ -165,6 +165,55 @@ CONTEXT_MENU = "contextmenu";
165
165
  */
166
166
  declare type ContextMenuEventDetail = null;
167
167
 
168
+ /**
169
+ * @public
170
+ * @deprecated
171
+ * when a cuepoint becomes inactive
172
+ */
173
+ declare const /**
174
+ @public
175
+ * when a new player is inserted into the HTML
176
+ */ /**
177
+ * @public
178
+ * @deprecated
179
+ * when a cuepoint becomes inactive
180
+ */
181
+ CUEPOINT_END = "cuepointend";
182
+
183
+ /**
184
+ * @public
185
+ * @deprecated
186
+ * when a cuepoint is active
187
+ */
188
+ declare const /**
189
+ @public
190
+ * when a new player is inserted into the HTML
191
+ */ /**
192
+ * @public
193
+ * @deprecated
194
+ * when a cuepoint is active
195
+ */
196
+ CUEPOINT_START = "cuepointstart";
197
+
198
+ /**
199
+ * @public
200
+ * @deprecated
201
+ * cuepoints parsing is asynchronous
202
+ * you cannot rely on them existing until
203
+ * this event is emitted
204
+ */
205
+ declare const /**
206
+ @public
207
+ * when a new player is inserted into the HTML
208
+ */ /**
209
+ * @public
210
+ * @deprecated
211
+ * cuepoints parsing is asynchronous
212
+ * you cannot rely on them existing until
213
+ * this event is emitted
214
+ */
215
+ CUEPOINTS = "cuepoints";
216
+
168
217
  /**
169
218
  * @public
170
219
  */
@@ -349,7 +398,10 @@ declare namespace events {
349
398
  PORTRAIT,
350
399
  DVR,
351
400
  LIVE,
352
- RECOVER
401
+ RECOVER,
402
+ CUEPOINTS,
403
+ CUEPOINT_START,
404
+ CUEPOINT_END
353
405
  }
354
406
  }
355
407
 
@@ -213,6 +213,55 @@ CONTEXT_MENU = "contextmenu";
213
213
  */
214
214
  declare type ContextMenuEventDetail = null;
215
215
 
216
+ /**
217
+ * @public
218
+ * @deprecated
219
+ * when a cuepoint becomes inactive
220
+ */
221
+ declare const /**
222
+ @public
223
+ * when a new player is inserted into the HTML
224
+ */ /**
225
+ * @public
226
+ * @deprecated
227
+ * when a cuepoint becomes inactive
228
+ */
229
+ CUEPOINT_END = "cuepointend";
230
+
231
+ /**
232
+ * @public
233
+ * @deprecated
234
+ * when a cuepoint is active
235
+ */
236
+ declare const /**
237
+ @public
238
+ * when a new player is inserted into the HTML
239
+ */ /**
240
+ * @public
241
+ * @deprecated
242
+ * when a cuepoint is active
243
+ */
244
+ CUEPOINT_START = "cuepointstart";
245
+
246
+ /**
247
+ * @public
248
+ * @deprecated
249
+ * cuepoints parsing is asynchronous
250
+ * you cannot rely on them existing until
251
+ * this event is emitted
252
+ */
253
+ declare const /**
254
+ @public
255
+ * when a new player is inserted into the HTML
256
+ */ /**
257
+ * @public
258
+ * @deprecated
259
+ * cuepoints parsing is asynchronous
260
+ * you cannot rely on them existing until
261
+ * this event is emitted
262
+ */
263
+ CUEPOINTS = "cuepoints";
264
+
216
265
  /**
217
266
  * @public
218
267
  */
@@ -397,7 +446,10 @@ declare namespace events {
397
446
  PORTRAIT,
398
447
  DVR,
399
448
  LIVE,
400
- RECOVER
449
+ RECOVER,
450
+ CUEPOINTS,
451
+ CUEPOINT_START,
452
+ CUEPOINT_END
401
453
  }
402
454
  }
403
455
 
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.chromecast=t())}(this,(function(){"use strict";function e(e){const t=document.createElement("a");t.href=e;const n=t.pathname&&t.pathname.split(".");return n.length>1&&n[n.length-1]}function t(e){switch(e){case"video/mpd":return"application/dash+xml";case"video/m3u8":return"application/x-mpegurl";default:return e}}const n=n=>{var{src:r}=n,o=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(n,["src"]);return[Object.assign({src:r,type:r?t("video/"+e(r)):""},o)]};function r(e){return n({src:e})}class Pipe{constructor(e){this.data=e}static of(e){return new Pipe(e)}static maybe(e,t,...n){return null==e?e:t.apply(e,[e,...n])}tap(e,...t){return e.apply(this,[this.data,...t]),new Pipe(this.data)}fmap(e,...t){const n=e.apply(this,[this.data,...t]);return new Pipe(n)}unwrap(){return this.data}}const o="chromecast:idle";var a=Object.freeze({__proto__:null,CAST_AVAILABLE:"chromecast:available",CAST_UNAVAILABLE:"chromecast:unavailable",CAST_START_CASTING:"chromecast:start",CAST_IDLE:o,CAST_STATE_CHANGED:"chromecast:state:changed",CAST_SESSION_CHANGED:"chromecast:session:changed",CAST_FIELD_UPDATE:"chromecast:field:update",CAST_MEDIA_LOAD_REQUEST:"chromecast:media"});const s=/(video\/mp4)|(application\/x-mpegurl)|(video\/mpd)|(application\/dash\+xml)/;function i(){var e;return(null===(e=f())||void 0===e?void 0:e.getCurrentSession())||null}function c(e){return p(e).unwrap().shift()}function l(){var e;return(null===(e=i())||void 0===e?void 0:e.getMediaSession())||null}function u(e){var t,n;const r=p(e).unwrap().map((function(e){return null==e?void 0:e.src})),o=null===(n=null===(t=l())||void 0===t?void 0:t.media)||void 0===n?void 0:n.contentId;return!!o&&!!~r.indexOf(o)}function d(e){var t;return(null===(t=e.type)||void 0===t?void 0:t.match(s))||!1}function m(e,t){if(!t.opts.src)return e;const n=(Array.isArray(t.opts.src)?t.opts.src:[t.opts.src]).map(e=>"string"==typeof e?r(e)[0]:e);return e.map(e=>{const t=n.find(t=>t.src===e.src);return t&&t.drm?Object.assign(Object.assign({},e),{drm:t.drm}):e})}function p(e){return Pipe.of(e).fmap(()=>e.original_src||[]).fmap((function(e){return"string"==typeof e?r(e):e})).fmap(m,e).fmap((function(e){return e.filter(d)}))}function f(){var e,t,n;return null===(n=null===(t=null===(e=window.cast)||void 0===e?void 0:e.framework)||void 0===t?void 0:t.CastContext)||void 0===n?void 0:n.getInstance()}function v(e){return e.filter((function(e){return u(e)}))}function h(e){return e.filter((function(e){return!u(e)}))}function y(e,t,n){v(e).forEach((function(e){e.emit(t,n)}))}function S(e,t,n){h(e).forEach((function(e){e.emit(t,n)}))}function E(e,t,n){e.forEach((function(e){e.emit(t,n)}))}const g={PAUSED:"isPaused",CURRENT_TIME:"currentTime",DURATION:"duration",CONNECTED:"isConnected",PLAYER_STATE:"playerState",SAVED_STATE:"savedPlayerState",DISPLAY_NAME:"displayName",STATUS:"statusText",VOLUME:"volumeLevel",MUTE:"isMuted",LIVE_RANGES:"liveSeekableRange"},w={player:void 0,controller:void 0,listener:void 0};function _(e){w.controller&&w.listener&&w.controller.removeEventListener(cast.framework.RemotePlayerEventType.ANY_CHANGE,w.listener),w.player=new cast.framework.RemotePlayer,w.controller=new cast.framework.RemotePlayerController(w.player),w.listener=T.bind(null,e),w.controller.addEventListener(cast.framework.RemotePlayerEventType.ANY_CHANGE,w.listener)}function T(e,t){if("IDLE"===t.value)return S(e,o);y(e,"chromecast:field:update",t)}function b(e){return Array.from(e.textTracks).filter(e=>["subtitles","captions"].includes(e.kind))}function A(e){return b(e).flatMap((t,n)=>{try{const r=e.querySelector("#"+t.id);if(!(r instanceof HTMLTrackElement&&r.lang))return[];const o=new chrome.cast.media.Track(n+1e3,chrome.cast.media.TrackType.TEXT);return o.trackContentType="text/vtt",o.subtype=chrome.cast.media.TextTrackType.SUBTITLES,o.trackContentId=r.src,o.name=r.label,o.language=r.lang,o}catch(e){return[]}})}function C(e){var t;const n=new chrome.cast.media.EditTracksInfoRequest(e);null===(t=l())||void 0===t||t.editTracksInfo(n,console.debug,console.error)}var k=Object.freeze({__proto__:null,getCurrentSession:i,getMedia:c,getMediaSession:l,isSame:u,is_supported_media:d,injectDRMConfiguration:m,normalizeSrc:p,getCastContext:f,casting_players:v,idle_players:h,broadcast_to_active:y,broadcast_to_idle:S,broadcast:E,FIELDS:g,SINGLETONS:w,refresh_singletons:_,onremotechange:T,tracks:b,cast_tracks:A,editTracks:C});function O(e,t,n,r){var a,s,l,u,d;const m=i();if(!m)return;const p=c(e);if(!p||!p.src)return;const f=new chrome.cast.media.MediaInfo(p.src,p.type||"");f.metadata=new chrome.cast.media.GenericMediaMetadata;const v={health:e.health,text_tracks:A(e),active_tracks:{active_audio:(null===(s=null===(a=null==e?void 0:e.asel)||void 0===a?void 0:a.active_track)||void 0===s?void 0:s.name)||(null===(u=null===(l=null==e?void 0:e.asel)||void 0===l?void 0:l.active_track)||void 0===u?void 0:u.lang),active_text:null===(d=b(e).find(e=>e.is_active))||void 0===d?void 0:d.label}};p.drm&&(v.drm=p.drm),localStorage.__fpChromecastDebug&&(v.debug=!0),e.opt("ads")&&(v.ads=e.opt("ads")),f.customData=v;const h=new chrome.cast.media.LoadRequest(f);isNaN(e.currentTime)||(h.currentTime=e.currentSessionTime),h.customData=e.opt("chromecast",{}),h.customData.metadata=e.opt("metadata"),e.emit("chromecast:media",{request:h}),console.debug("cast:request(%o)",h),m.loadMedia(h).then((function(){_(t);const n=w.player;n&&(e.volume=n.volumeLevel,e.muted=n.isMuted),S(t,o)}),r)}function L(){return!!l()}function I(){return!!i()}function N(){var e;return(null===(e=null==k?void 0:i())||void 0===e?void 0:e.getMediaSession()).getEstimatedLiveSeekableRange()}function D(){var e;return null===(e=l())||void 0===e?void 0:e.media.duration}function P(){var e;return null===(e=l())||void 0===e?void 0:e.playerState}function x(e){var t;return e?M(e):null===(t=l())||void 0===t?void 0:t.getEstimatedTime()}function M(e){const t=l();if(!t)return e;const n=new chrome.cast.media.SeekRequest;return n.currentTime=e,t.seek(n,console.debug,console.error),e}function R(){var e;return null===(e=l())||void 0===e?void 0:e.play(new chrome.cast.media.PlayRequest,console.debug,console.error)}function j(){var e;return null===(e=l())||void 0===e?void 0:e.pause(new chrome.cast.media.PauseRequest,console.debug,console.error)}var U=Object.freeze({__proto__:null,load:O,has_media:L,exists:I,device_name:function(){var e;return null===(e=i())||void 0===e?void 0:e.getCastDevice().friendlyName},seekable_ranges:N,duration:D,state:P,currentTime:x,seek:M,play:R,pause:j});class Sender{constructor(e){this.video=e}static of(e){return e.sender||(e.sender=new Sender(e)),e.sender}static maybe(e,t){e.sender&&t(e.sender,e)}static getEstimatedTime(){var e;return null===(e=l())||void 0===e?void 0:e.getEstimatedTime()}static load(e,t){O(e,t,console.debug,console.error)}static destroy(e){e.video=void 0}}var G=Object.freeze({__proto__:null,STABLE:"940D4BE4",CANARY:"6F71FA7C",LOCAL:"5258CA32"});const q="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1";function H(e,t,n){if(document.querySelector("script[src='"+q+"']"))return F(n);!function(){const e=document.createElement("script");e.async=!0,e.src=q,document.head.appendChild(e)}(),window.__onGCastApiAvailable=function(){!function(e,t,n){var r;if(!V())return;const o=(null===(r=e.chromecast)||void 0===r?void 0:r.app)||"940D4BE4",a=f();if(!a)return;a.setOptions({receiverApplicationId:o,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}),a.addEventListener(cast.framework.CastContextEventType.CAST_STATE_CHANGED,(function(e){E(n,"chromecast:state:changed",e)})),a.addEventListener(cast.framework.CastContextEventType.SESSION_STATE_CHANGED,(function(e){_(n),E(n,"chromecast:session:changed",e)}))}(e,0,n),F(n)}}function V(){return"object"==typeof window.cast&&"object"==typeof chrome.cast}function F(e){if(V())return E(e,"chromecast:available");E(e,"chromecast:unavailable")}function B(e,t){const n={play:function(){return new Promise(n=>u(e)?n(R()):L()?n(Sender.load(e,t)):(Sender.load(e,t),void n()))},pause:function(){return u(e)?j():HTMLMediaElement.prototype.pause.call(e)}};n.currentTime={get:x,set:x},n.seekable={get:()=>{const e=N();return{start:()=>(null==e?void 0:e.start)||0,end:()=>(null==e?void 0:e.end)||0,length:1}}},n.duration={get:D},n.paused={get:function(){return"PAUSED"===P()}},n.playing={get:function(){return"PLAYING"===P()}},Object.keys(n).forEach((function(t){if("object"==typeof n[t])return Object.defineProperty(e,t,{get:function(){var r,o;return u(e)?n[t].get():null===(o=null===(r=Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype,t))||void 0===r?void 0:r.get)||void 0===o?void 0:o.call(this)},set:function(r){var o,a;return u(e)?n[t].set(r):null===(a=null===(o=Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype,t))||void 0===o?void 0:o.set)||void 0===a?void 0:a.call(this,r)}});const r=e[t];e[t]=function(){const o=[].slice.apply(arguments);return I()?n[t].apply(e,o):r.apply(e,o)}}))}const Y=(e,t)=>new(((e,t)=>{const n=e.get(t);if(!n)throw new Error(`no flowplayer component with the name ${t} exists`);const r=window.customElements.get(t);if(!r)throw new Error(`no default flowplayer component with the name ${t} exists`);const o=window.customElements.get(n);return"function"!=typeof o?r:o})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}class FlowplayerChromecastIcon extends FlowplayerComponent{constructor(e){super(e),this.classList.add("fp-cast-button"),this.setAttribute("tabindex","-1"),this.setAttribute("role","button"),this.setAttribute("aria-hidden","true"),this.cast_launcher=document.createElement("google-cast-launcher"),this.cast_launcher.setAttribute("inert","true"),this.append(this.cast_launcher),this.addEventListener("click",t=>{const n=i();if(n)return n.endSession(!0);e.emit("chromecast:start"),t.target===this&&this.cast_launcher.click()}),e.on("chromecast:state:changed",t=>{const n=t.detail.castState;n&&(this.setAttribute("tabindex",n===cast.framework.CastState.NO_DEVICES_AVAILABLE?"-1":"0"),this.setAttribute("aria-hidden",(n===cast.framework.CastState.NO_DEVICES_AVAILABLE)+""),this.setAttribute("aria-label",n===cast.framework.CastState.NOT_CONNECTED?e.i18n("chromecast.start","start casting"):e.i18n("chromecast.stop","stop casting")))})}}function z(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}class ChromecastPlugin{constructor(e){var t,n,r;this.flowplayer=e,t=e,n="flowplayer-chromecast-icon",r=FlowplayerChromecastIcon,window.customElements.get(n)||window.customElements.define(n,r),t.customElements.get(n)||t.customElements.set(n,n)}init(e,t,n){if("https:"!==location.protocol&&"localhost"!==location.hostname&&"127.0.0.1"!==location.hostname)return console.warn("Secure URL required to enable Chromecast");H(e,0,this.flowplayer.instances);const r={pending:void 0};n.on("reap",(function(){Sender.maybe(n,Sender.destroy)})),n.on("mount",(function(){const t=z(n,"flowplayer-middle");t&&function(e,t){const n=document.createElement("div");n.className="fp-chromecast";const r=document.createElement("p");t.poster&&(n.style.backgroundImage=["url(",t.poster,")"].join("")),n.append(r),e.prepend(n)}(t,{poster:e.poster});const r=z(n,"flowplayer-header-right-zone");r&&r.prepend(Y(n,"flowplayer-chromecast-icon"))})),n.on("chromecast:available",()=>{n.setState("is-cast-available",!0),Sender.of(n),B(n,this.flowplayer.instances)}),n.on("chromecast:unavailable",(function(){n.setState("is-cast-available",!1),Sender.maybe(n,Sender.destroy)})),n.on("chromecast:start",()=>{if(this.flowplayer.instances.forEach(e=>{e.togglePlay(!1),e.currentSessionTime=e.hasState("is-ended")?0:e.currentTime}),L())return Sender.load(n,this.flowplayer.instances);r.pending=!0}),n.on("volumechange",()=>{const e=w.player,t=w.controller;if(!L()||!e||!t)return;const r=n.volume,o=n.muted;r!==e.volumeLevel&&(e.volumeLevel=r,t.setVolumeLevel()),o!==e.isMuted&&t.muteOrUnmute()}),n.on("tracks:text:updated",(function(e){var t;if(L())return e.data?void C((null===(t=l())||void 0===t?void 0:t.media.tracks.filter(e=>"TEXT"===e.type).filter(e=>{var t;return e.name===(null===(t=b(n).find(e=>e.is_active))||void 0===t?void 0:t.label)}).map(e=>e.trackId))||[]):C([])})),n.on("audio:update",()=>{L()&&setTimeout(()=>{var e,t,r;const o=null===(e=null==n?void 0:n.asel)||void 0===e?void 0:e.active_track,a=null===(r=null===(t=l())||void 0===t?void 0:t.media.tracks.filter(e=>"AUDIO"===e.type).find(e=>void 0!==e.name?e.name===(null==o?void 0:o.name):e.language===(null==o?void 0:o.lang)))||void 0===r?void 0:r.trackId;"number"==typeof a&&C([a])},0)}),n.on(o,()=>{this.reset_state(n);const e=n.opt("duration");"number"==typeof e&&Math.abs(e-n.currentSessionTime)<=1&&(n.currentSessionTime=0,n.setState("is-paused",!1),n.emit("ended"))}),n.on("chromecast:field:update",(function(e){if(!e.data)return;const{field:t,value:r}=e.data;switch(t){case g.MUTE:return n.muted=r;case g.VOLUME:return n.volume=r;case g.CURRENT_TIME:{Math.abs(r-n.currentSessionTime)>=1.5&&n.emit("seeked"),n.currentSessionTime=r,n.emit("timeupdate",r);const e=N();if(e){n.opts.live||n.setOpts({live:!0});const t=e.end,r=e.start;if("number"!=typeof r||"number"!=typeof t)return;n.emit("dvr/window",t-r)}return}case g.PLAYER_STATE:return"PLAYING"==r?n.emit("playing"):"PAUSED"==r?n.emit("pause"):void 0;case"videoInfo":var o=(r||{}).fake_session||U;return function(e,t){if(!e.root)return;const n=e.root.querySelector(".fp-chromecast p");if(!n)return;let r="";r=e.i18n("chromecast.message","{{state}} on {{device}}").replace("{{device}}",(null==t?void 0:t.device)||"chromecast"),r=r.replace("{{state}}",((null==t?void 0:t.state)||"").toLowerCase()),n.textContent=r}(n,{device:o.device_name(),state:o.state()}),o.hide_controls&&n.setState("no-chromecast-controls",!0),n.setState("is-starting",!1),n.hasState("is-loaded")||-1===n.duration||n.setOpts({duration:n.duration}),n.setState("is-chromecast-playing",!0)}})),n.on("chromecast:session:changed",e=>{if(e.data)switch(e.detail.sessionState){case cast.framework.SessionState.SESSION_ENDED:return n.emit("remotesession:ended",{currentTime:n.currentSessionTime}),n.setState("is-casting",!1),this.reset_state(n);case cast.framework.SessionState.SESSION_RESUMED:case cast.framework.SessionState.SESSION_STARTED:r.pending&&(r.pending=!1,Sender.load(n,this.flowplayer.instances),n.emit("remotesession:started"),n.setState("is-casting",!0))}})}reset_state(e){e.setState("is-chromecast-playing",!1),e.setState("is-playing",!1),e.setState("is-paused",!0),e.setState("is-starting",!0)}}ChromecastPlugin.apps=G,ChromecastPlugin.events=a;return function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;if(null===document.currentScript)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;return"function"==typeof n?(n(t),t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t),t)}(window,ChromecastPlugin)}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.chromecast=t())}(this,(function(){"use strict";function e(e){const t=document.createElement("a");t.href=e;const n=t.pathname&&t.pathname.split(".");return n.length>1&&n[n.length-1]}function t(e){switch(e){case"video/mpd":return"application/dash+xml";case"video/m3u8":return"application/x-mpegurl";default:return e}}const n=n=>{var{src:r}=n,o=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(n,["src"]);return[Object.assign({src:r,type:r?t("video/"+e(r)):""},o)]};function r(e){return n({src:e})}class Pipe{constructor(e){this.data=e}static of(e){return new Pipe(e)}static maybe(e,t,...n){return null==e?e:t.apply(e,[e,...n])}tap(e,...t){return e.apply(this,[this.data,...t]),new Pipe(this.data)}fmap(e,...t){const n=e.apply(this,[this.data,...t]);return new Pipe(n)}unwrap(){return this.data}}const o="chromecast:idle";var a=Object.freeze({__proto__:null,CAST_AVAILABLE:"chromecast:available",CAST_UNAVAILABLE:"chromecast:unavailable",CAST_START_CASTING:"chromecast:start",CAST_IDLE:o,CAST_STATE_CHANGED:"chromecast:state:changed",CAST_SESSION_CHANGED:"chromecast:session:changed",CAST_FIELD_UPDATE:"chromecast:field:update",CAST_MEDIA_LOAD_REQUEST:"chromecast:media"});const i=/(video\/mp4)|(application\/x-mpegurl)|(video\/mpd)|(application\/dash\+xml)/;function s(){var e;return(null===(e=f())||void 0===e?void 0:e.getCurrentSession())||null}function c(e){return p(e).unwrap().shift()}function l(){var e;return(null===(e=s())||void 0===e?void 0:e.getMediaSession())||null}function u(e){var t,n;const r=p(e).unwrap().map((function(e){return null==e?void 0:e.src})),o=null===(n=null===(t=l())||void 0===t?void 0:t.media)||void 0===n?void 0:n.contentId;return!!o&&!!~r.indexOf(o)}function d(e){var t;return(null===(t=e.type)||void 0===t?void 0:t.match(i))||!1}function m(e,t){if(!t.opts.src)return e;const n=(Array.isArray(t.opts.src)?t.opts.src:[t.opts.src]).map(e=>"string"==typeof e?r(e)[0]:e);return e.map(e=>{const t=n.find(t=>t.src===e.src);return t&&t.drm?Object.assign(Object.assign({},e),{drm:t.drm}):e})}function p(e){return Pipe.of(e).fmap(()=>e.original_src||[]).fmap((function(e){return"string"==typeof e?r(e):e})).fmap(m,e).fmap((function(e){return e.filter(d)}))}function f(){var e,t,n;return null===(n=null===(t=null===(e=window.cast)||void 0===e?void 0:e.framework)||void 0===t?void 0:t.CastContext)||void 0===n?void 0:n.getInstance()}function v(e){return e.filter((function(e){return u(e)}))}function h(e){return e.filter((function(e){return!u(e)}))}function y(e,t,n){v(e).forEach((function(e){e.emit(t,n)}))}function S(e,t,n){h(e).forEach((function(e){e.emit(t,n)}))}function g(e,t,n){e.forEach((function(e){e.emit(t,n)}))}const w={player:void 0,controller:void 0,listener:void 0};function _(e){w.controller&&w.listener&&w.controller.removeEventListener(cast.framework.RemotePlayerEventType.ANY_CHANGE,w.listener),w.player=new cast.framework.RemotePlayer,w.controller=new cast.framework.RemotePlayerController(w.player),w.listener=E.bind(null,e),w.controller.addEventListener(cast.framework.RemotePlayerEventType.ANY_CHANGE,w.listener)}function E(e,t){if("IDLE"===t.value)return S(e,o);y(e,"chromecast:field:update",t)}function b(e){return Array.from(e.textTracks).filter(e=>["subtitles","captions"].includes(e.kind))}function T(e){return b(e).flatMap((t,n)=>{try{const r=e.querySelector("#"+t.id);if(!(r instanceof HTMLTrackElement&&r.lang))return[];const o=new chrome.cast.media.Track(n+1e3,chrome.cast.media.TrackType.TEXT);return o.trackContentType="text/vtt",o.subtype=chrome.cast.media.TextTrackType.SUBTITLES,o.trackContentId=r.src,o.name=r.label,o.language=r.lang,o}catch(e){return[]}})}function A(e){var t;const n=new chrome.cast.media.EditTracksInfoRequest(e);null===(t=l())||void 0===t||t.editTracksInfo(n,console.debug,console.error)}var C=Object.freeze({__proto__:null,getCurrentSession:s,getMedia:c,getMediaSession:l,isSame:u,is_supported_media:d,injectDRMConfiguration:m,normalizeSrc:p,getCastContext:f,casting_players:v,idle_players:h,broadcast_to_active:y,broadcast_to_idle:S,broadcast:g,SINGLETONS:w,refresh_singletons:_,onremotechange:E,tracks:b,cast_tracks:T,editTracks:A});const k="is-chromecast-playing";function O(e,t){const n=e.seekable;if("object"!=typeof e.opts||0==n.length)return{head:0,tail:0};const r=function(e){var t;const n=e.seekable;return n.length?e.hasState(k)||!(null===(t=e.hls)||void 0===t?void 0:t.liveSyncPosition)?n.end(n.length-1):e.hls.liveSyncPosition:0}(e),o=t||e.live_state.dvr_window;return{head:r,tail:"number"!=typeof o||r-o<0?n.start(0):r-o}}function L(e){const t=e.currentTime,n=O(e);return{progress:Math.min(100,Math.max(0,(t-n.tail)/(n.head-n.tail)*100)),is_live:t-n.head>=-10}}const I={player:void 0,listener:void 0};function x(e,t,n,r){var a,i,u,d,m;const p=s();if(!p)return;const f=c(e);if(!f||!f.src)return;const v=new chrome.cast.media.MediaInfo(f.src,f.type||"");v.metadata=new chrome.cast.media.GenericMediaMetadata,function(e){I.player&&I.listener&&I.player.off("playing",I.listener);const t={currentTime:e.currentSessionTime,liveState:e.live_state,progress:L(e).progress};I.player=e,I.listener=()=>{setTimeout(()=>{!function(e,t){const n=l();if(!n)return;if(-1!==n.media.duration)return e.currentTime=t.currentTime;const r=n.liveSeekableRange;if(!r||"number"!=typeof r.end||"number"!=typeof r.start)return;if(void 0===t.liveState.dvr_window||!t.liveState.dvr)return;e.currentTime=(r.end-r.start)*(t.progress/100)}(e,t)},1e3)},e.once("playing",I.listener)}(e);const h={health:e.health,text_tracks:T(e),active_tracks:{active_audio:(null===(i=null===(a=null==e?void 0:e.asel)||void 0===a?void 0:a.active_track)||void 0===i?void 0:i.name)||(null===(d=null===(u=null==e?void 0:e.asel)||void 0===u?void 0:u.active_track)||void 0===d?void 0:d.lang),active_text:null===(m=b(e).find(e=>e.is_active))||void 0===m?void 0:m.label}};f.drm&&(h.drm=f.drm),localStorage.__fpChromecastDebug&&(h.debug=!0),e.opt("ads")&&(h.ads=e.opt("ads")),v.customData=h;const y=new chrome.cast.media.LoadRequest(v);y.customData=e.opt("chromecast",{}),y.customData.metadata=e.opt("metadata"),e.emit("chromecast:media",{request:y}),console.debug("cast:request(%o)",y),p.loadMedia(y).then(()=>{e.emit("remotesession:started"),e.setState("has-casted",!0),e.setState("is-casting",!0),_(t);const n=w.player;n&&(e.volume=n.volumeLevel,e.muted=n.isMuted),S(t,o)},r)}function P(){return!!l()}function D(){return!!s()}function N(){var e;return(null===(e=null==C?void 0:s())||void 0===e?void 0:e.getMediaSession()).getEstimatedLiveSeekableRange()}function M(){var e;return null===(e=l())||void 0===e?void 0:e.media.duration}function j(){var e;return null===(e=l())||void 0===e?void 0:e.playerState}function R(e){var t;return e?G(e):null===(t=l())||void 0===t?void 0:t.getEstimatedTime()}function G(e){const t=l();if(!t)return e;const n=new chrome.cast.media.SeekRequest;return n.currentTime=e,t.seek(n,console.debug,console.error),e}function q(){var e;return null===(e=l())||void 0===e?void 0:e.play(new chrome.cast.media.PlayRequest,console.debug,console.error)}function H(){var e;return null===(e=l())||void 0===e?void 0:e.pause(new chrome.cast.media.PauseRequest,console.debug,console.error)}var U=Object.freeze({__proto__:null,load:x,has_media:P,exists:D,device_name:function(){var e;return null===(e=s())||void 0===e?void 0:e.getCastDevice().friendlyName},seekable_ranges:N,duration:M,state:j,currentTime:R,seek:G,play:q,pause:H});class Sender{constructor(e){this.video=e}static of(e){return e.sender||(e.sender=new Sender(e)),e.sender}static maybe(e,t){e.sender&&t(e.sender,e)}static getEstimatedTime(){var e;return null===(e=l())||void 0===e?void 0:e.getEstimatedTime()}static load(e,t){x(e,t,console.debug,console.error)}static destroy(e){e.video=void 0}}var B=Object.freeze({__proto__:null,STABLE:"940D4BE4",CANARY:"6F71FA7C",LOCAL:"5258CA32"});const F="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1";function V(e,t,n){if(document.querySelector("script[src='"+F+"']"))return Y(n);!function(){const e=document.createElement("script");e.async=!0,e.src=F,document.head.appendChild(e)}(),window.__onGCastApiAvailable=function(){!function(e,t,n){var r;if(!z())return;const o=(null===(r=e.chromecast)||void 0===r?void 0:r.app)||"940D4BE4",a=f();if(!a)return;a.setOptions({receiverApplicationId:o,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}),a.addEventListener(cast.framework.CastContextEventType.CAST_STATE_CHANGED,(function(e){g(n,"chromecast:state:changed",e)})),a.addEventListener(cast.framework.CastContextEventType.SESSION_STATE_CHANGED,(function(e){_(n),g(n,"chromecast:session:changed",e)}))}(e,0,n),Y(n)}}function z(){return"object"==typeof window.cast&&"object"==typeof chrome.cast}function Y(e){if(z())return g(e,"chromecast:available");g(e,"chromecast:unavailable")}function J(e,t){const n={play:function(){return new Promise(n=>u(e)?n(q()):P()?n(Sender.load(e,t)):(Sender.load(e,t),void n()))},pause:function(){return u(e)?H():HTMLMediaElement.prototype.pause.call(e)}};n.currentTime={get:R,set:R},n.seekable={get:()=>{const e=N();return{start:()=>(null==e?void 0:e.start)||0,end:()=>(null==e?void 0:e.end)||0,length:1}}},n.duration={get:M},n.paused={get:function(){return"PAUSED"===j()}},n.playing={get:function(){return"PLAYING"===j()}},Object.keys(n).forEach((function(t){if("object"==typeof n[t])return Object.defineProperty(e,t,{get:function(){var r,o;return u(e)?n[t].get():null===(o=null===(r=Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype,t))||void 0===r?void 0:r.get)||void 0===o?void 0:o.call(this)},set:function(r){var o,a;return u(e)?n[t].set(r):null===(a=null===(o=Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype,t))||void 0===o?void 0:o.set)||void 0===a?void 0:a.call(this,r)}});const r=e[t];e[t]=function(){const o=[].slice.apply(arguments);return D()?n[t].apply(e,o):r.apply(e,o)}}))}const X="currentTime",$="duration",Q="playerState",K="videoInfo",W="volumeLevel",Z="isMuted",ee="liveSeekableRange",te=(e,t)=>new(((e,t)=>{const n=e.get(t);if(!n)throw new Error(`no flowplayer component with the name ${t} exists`);const r=window.customElements.get(t);if(!r)throw new Error(`no default flowplayer component with the name ${t} exists`);const o=window.customElements.get(n);return"function"!=typeof o?r:o})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}class FlowplayerChromecastIcon extends FlowplayerComponent{constructor(e){super(e),this.classList.add("fp-cast-button"),this.setAttribute("tabindex","-1"),this.setAttribute("role","button"),this.setAttribute("aria-hidden","true"),this.cast_launcher=document.createElement("google-cast-launcher"),this.cast_launcher.setAttribute("inert","true"),this.append(this.cast_launcher),this.addEventListener("click",t=>{const n=s();if(n)return n.endSession(!0);e.emit("chromecast:start"),t.target===this&&this.cast_launcher.click()}),e.on("chromecast:state:changed",t=>{const n=t.detail.castState;n&&(this.setAttribute("tabindex",n===cast.framework.CastState.NO_DEVICES_AVAILABLE?"-1":"0"),this.setAttribute("aria-hidden",(n===cast.framework.CastState.NO_DEVICES_AVAILABLE)+""),this.setAttribute("aria-label",n===cast.framework.CastState.NOT_CONNECTED?e.i18n("chromecast.start","start casting"):e.i18n("chromecast.stop","stop casting")))})}}function ne(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}class ChromecastPlugin{constructor(e){var t,n,r;this.flowplayer=e,t=e,n="flowplayer-chromecast-icon",r=FlowplayerChromecastIcon,window.customElements.get(n)||window.customElements.define(n,r),t.customElements.get(n)||t.customElements.set(n,n)}init(e,t,n){if("https:"!==location.protocol&&"localhost"!==location.hostname&&"127.0.0.1"!==location.hostname)return console.warn("Secure URL required to enable Chromecast");V(e,0,this.flowplayer.instances);const r={pending:void 0};n.on("reap",(function(){Sender.maybe(n,Sender.destroy)})),n.on("mount",(function(){const t=ne(n,"flowplayer-middle");t&&function(e,t){const n=document.createElement("div");n.className="fp-chromecast";const r=document.createElement("p");t.poster&&(n.style.backgroundImage=["url(",t.poster,")"].join("")),n.append(r),e.prepend(n)}(t,{poster:e.poster});const r=ne(n,"flowplayer-header-right-zone");r&&r.prepend(te(n,"flowplayer-chromecast-icon"))})),n.on("chromecast:available",()=>{n.setState("is-cast-available",!0),Sender.of(n),J(n,this.flowplayer.instances)}),n.on("chromecast:unavailable",(function(){n.setState("is-cast-available",!1),Sender.maybe(n,Sender.destroy)})),n.on("chromecast:start",()=>{if(this.flowplayer.instances.forEach(e=>{e.togglePlay(!1),e.currentSessionTime=e.hasState("is-ended")?0:e.currentTime}),P())return Sender.load(n,this.flowplayer.instances);r.pending=!0}),n.on("volumechange",()=>{const e=w.player,t=w.controller;if(!P()||!e||!t)return;const r=n.volume,o=n.muted;r!==e.volumeLevel&&(e.volumeLevel=r,t.setVolumeLevel()),o!==e.isMuted&&t.muteOrUnmute()}),n.on("tracks:text:updated",(function(e){var t;if(P())return e.data?void A((null===(t=l())||void 0===t?void 0:t.media.tracks.filter(e=>"TEXT"===e.type).filter(e=>{var t;return e.name===(null===(t=b(n).find(e=>e.is_active))||void 0===t?void 0:t.label)}).map(e=>e.trackId))||[]):A([])})),n.on("audio:update",()=>{P()&&setTimeout(()=>{var e,t,r;const o=null===(e=null==n?void 0:n.asel)||void 0===e?void 0:e.active_track,a=null===(r=null===(t=l())||void 0===t?void 0:t.media.tracks.filter(e=>"AUDIO"===e.type).find(e=>void 0!==e.name?e.name===(null==o?void 0:o.name):e.language===(null==o?void 0:o.lang)))||void 0===r?void 0:r.trackId;"number"==typeof a&&A([a])},0)}),n.on(o,()=>{if(n.setState("is-starting",!0),!n.hasState("is-casting"))return;const e=n.opt("duration");"number"==typeof e&&Math.abs(e-n.currentSessionTime)<=1&&(n.currentSessionTime=0,n.setState("is-paused",!1),n.emit("ended")),n.emit("remotesession:ended",{currentTime:n.currentSessionTime}),this.reset_state(n)}),n.on("chromecast:field:update",(function(e){if(!e.data)return;const{field:t,value:r}=e.data;switch(t){case $:return void(-1!==r||n.opts.live||n.setOpts({live:!0}));case Z:return n.muted=r;case W:return n.volume=r;case ee:return n.emit("dvr/window",r.end-r.start);case X:return Math.abs(r-n.currentSessionTime)>=1.5&&n.emit("seeked"),n.currentSessionTime=r,n.emit("timeupdate",r);case Q:return"PLAYING"==r?n.emit("playing"):"PAUSED"==r?n.emit("pause"):void 0;case K:var o=(r||{}).fake_session||U;return function(e,t){if(!e.root)return;const n=e.root.querySelector(".fp-chromecast p");if(!n)return;let r="";r=e.i18n("chromecast.message","{{state}} on {{device}}").replace("{{device}}",(null==t?void 0:t.device)||"chromecast"),r=r.replace("{{state}}",((null==t?void 0:t.state)||"").toLowerCase()),n.textContent=r}(n,{device:o.device_name(),state:o.state()}),o.hide_controls&&n.setState("no-chromecast-controls",!0),n.setState("is-starting",!1),n.hasState("is-loaded")||-1===n.duration||n.setOpts({duration:n.duration}),n.setState(k,!0)}})),n.on("chromecast:session:changed",e=>{if(e.data)switch(e.detail.sessionState){case cast.framework.SessionState.SESSION_ENDED:if(!n.hasState("is-casting"))return;return n.emit("remotesession:ended",{currentTime:n.currentSessionTime}),this.reset_state(n);case cast.framework.SessionState.SESSION_RESUMED:case cast.framework.SessionState.SESSION_STARTED:r.pending&&(r.pending=!1,Sender.load(n,this.flowplayer.instances))}})}reset_state(e){e.setState(k,!1),e.setState("is-casting",!1),e.setState("is-playing",!1),e.setState("is-paused",!0),e.setState("is-starting",!0)}}ChromecastPlugin.apps=B,ChromecastPlugin.events=a;return function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;if(null===document.currentScript)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;return"function"==typeof n?(n(t),t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t),t)}(window,ChromecastPlugin)}));
@@ -163,6 +163,55 @@ CONTEXT_MENU = "contextmenu";
163
163
  */
164
164
  declare type ContextMenuEventDetail = null;
165
165
 
166
+ /**
167
+ * @public
168
+ * @deprecated
169
+ * when a cuepoint becomes inactive
170
+ */
171
+ declare const /**
172
+ @public
173
+ * when a new player is inserted into the HTML
174
+ */ /**
175
+ * @public
176
+ * @deprecated
177
+ * when a cuepoint becomes inactive
178
+ */
179
+ CUEPOINT_END = "cuepointend";
180
+
181
+ /**
182
+ * @public
183
+ * @deprecated
184
+ * when a cuepoint is active
185
+ */
186
+ declare const /**
187
+ @public
188
+ * when a new player is inserted into the HTML
189
+ */ /**
190
+ * @public
191
+ * @deprecated
192
+ * when a cuepoint is active
193
+ */
194
+ CUEPOINT_START = "cuepointstart";
195
+
196
+ /**
197
+ * @public
198
+ * @deprecated
199
+ * cuepoints parsing is asynchronous
200
+ * you cannot rely on them existing until
201
+ * this event is emitted
202
+ */
203
+ declare const /**
204
+ @public
205
+ * when a new player is inserted into the HTML
206
+ */ /**
207
+ * @public
208
+ * @deprecated
209
+ * cuepoints parsing is asynchronous
210
+ * you cannot rely on them existing until
211
+ * this event is emitted
212
+ */
213
+ CUEPOINTS = "cuepoints";
214
+
166
215
  /**
167
216
  * @public
168
217
  */
@@ -347,7 +396,10 @@ declare namespace events {
347
396
  PORTRAIT,
348
397
  DVR,
349
398
  LIVE,
350
- RECOVER
399
+ RECOVER,
400
+ CUEPOINTS,
401
+ CUEPOINT_START,
402
+ CUEPOINT_END
351
403
  }
352
404
  }
353
405