@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
@@ -157,6 +157,55 @@ CONTEXT_MENU = "contextmenu";
157
157
  */
158
158
  declare type ContextMenuEventDetail = null;
159
159
 
160
+ /**
161
+ * @public
162
+ * @deprecated
163
+ * when a cuepoint becomes inactive
164
+ */
165
+ declare const /**
166
+ @public
167
+ * when a new player is inserted into the HTML
168
+ */ /**
169
+ * @public
170
+ * @deprecated
171
+ * when a cuepoint becomes inactive
172
+ */
173
+ CUEPOINT_END = "cuepointend";
174
+
175
+ /**
176
+ * @public
177
+ * @deprecated
178
+ * when a cuepoint is active
179
+ */
180
+ declare const /**
181
+ @public
182
+ * when a new player is inserted into the HTML
183
+ */ /**
184
+ * @public
185
+ * @deprecated
186
+ * when a cuepoint is active
187
+ */
188
+ CUEPOINT_START = "cuepointstart";
189
+
190
+ /**
191
+ * @public
192
+ * @deprecated
193
+ * cuepoints parsing is asynchronous
194
+ * you cannot rely on them existing until
195
+ * this event is emitted
196
+ */
197
+ declare const /**
198
+ @public
199
+ * when a new player is inserted into the HTML
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
+ CUEPOINTS = "cuepoints";
208
+
160
209
  /**
161
210
  * @public
162
211
  */
@@ -341,7 +390,10 @@ declare namespace events {
341
390
  PORTRAIT,
342
391
  DVR,
343
392
  LIVE,
344
- RECOVER
393
+ RECOVER,
394
+ CUEPOINTS,
395
+ CUEPOINT_START,
396
+ CUEPOINT_END
345
397
  }
346
398
  }
347
399
 
@@ -157,6 +157,55 @@ CONTEXT_MENU = "contextmenu";
157
157
  */
158
158
  declare type ContextMenuEventDetail = null;
159
159
 
160
+ /**
161
+ * @public
162
+ * @deprecated
163
+ * when a cuepoint becomes inactive
164
+ */
165
+ declare const /**
166
+ @public
167
+ * when a new player is inserted into the HTML
168
+ */ /**
169
+ * @public
170
+ * @deprecated
171
+ * when a cuepoint becomes inactive
172
+ */
173
+ CUEPOINT_END = "cuepointend";
174
+
175
+ /**
176
+ * @public
177
+ * @deprecated
178
+ * when a cuepoint is active
179
+ */
180
+ declare const /**
181
+ @public
182
+ * when a new player is inserted into the HTML
183
+ */ /**
184
+ * @public
185
+ * @deprecated
186
+ * when a cuepoint is active
187
+ */
188
+ CUEPOINT_START = "cuepointstart";
189
+
190
+ /**
191
+ * @public
192
+ * @deprecated
193
+ * cuepoints parsing is asynchronous
194
+ * you cannot rely on them existing until
195
+ * this event is emitted
196
+ */
197
+ declare const /**
198
+ @public
199
+ * when a new player is inserted into the HTML
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
+ CUEPOINTS = "cuepoints";
208
+
160
209
  /**
161
210
  * @public
162
211
  */
@@ -353,7 +402,10 @@ declare namespace events {
353
402
  PORTRAIT,
354
403
  DVR,
355
404
  LIVE,
356
- RECOVER
405
+ RECOVER,
406
+ CUEPOINTS,
407
+ CUEPOINT_START,
408
+ CUEPOINT_END
357
409
  }
358
410
  }
359
411
 
package/plugins/health.js CHANGED
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((t="undefined"!=typeof globalThis?globalThis:t||self).flowplayer=t.flowplayer||{},t.flowplayer.health=e())}(this,(function(){"use strict";const t="rebuffer",e="rebuffer:ended",i="insights:ttff",n="insights:time_to_first_frag_loaded",s="insights:watched_interval";var a=Object.freeze({__proto__:null,RECORD:"health:record",REBUFFER:t,REBUFFER_ENDED:e,DISPLAY:"display",TIME_TO_FIRST_FRAME:i,TIME_TO_FIRST_FRAGMENT_LOADED:n,WATCHED_INTERVAL:s});const r="fullscreenenter",o="fullscreenexit",d="loadedmetadata",c="loadeddata",l="progress",h="loadstart",u="pause",_="playing",m="waiting",p="canplay",f="ended",y="seeked",g="seeking",v="content:loadstart",E=[v,"error","src"];function T(t){try{return!!new URL(t)}catch(t){return!1}}function S(t,e){const i=function(){try{return localStorage.getItem("flowplayer/debug")}catch(t){return""}}(),n=(n,...s)=>{try{const a=(null==e?void 0:e.debug)||i;a&&t.match(a)&&console.log(`flowplayer/${t} -- ${n}`,...s)}catch(t){console.warn(t)}};return n.log=n,n}const w=navigator;function R(t){var e,i;const n=null===(e=t.hls)||void 0===e?void 0:e.bandwidthEstimate;return n?1e-6*n:(null===(i=w.connection)||void 0===i?void 0:i.downlink)||-1}function A(t,e){return async function(t,e){try{await fetch(t,{body:e,method:"POST",mode:"no-cors"})}catch(t){}}(t,JSON.stringify({events:e}))}var I;!function(t){t[t.OFF=0]="OFF",t[t.ON=1]="ON",t[t.AUDIO_REQUIRED=2]="AUDIO_REQUIRED"}(I||(I={}));const W=t=>{switch(t){case!0:return I.ON;case!1:return I.OFF;default:return t}};function O(){try{const t=window.location!==window.parent.location?document.referrer:document.location.href;return"string"==typeof t&&t.slice(0,200)}catch(t){return!1}}const D=[],N="https://ihi.flowplayer.com/v1/health/events";function M(t){if(t.suspended)return;const e=D.slice(0);D.length=0,0!=e.length&&(t.logger.log(`:dispatch events={${e.length}}`),A(function(){try{return"undefined"==typeof window?N:window.__FLOWPLAYER_INSIGHTS_URL?window.__FLOWPLAYER_INSIGHTS_URL:N}catch(t){return N}}(),e))}async function b(t,e,i){const n=await C();D.push(Object.assign(e,n)),t.logger.log(":enqueue",e.event,e),D.length<10&&!i||M(t)}const U=()=>{var t,e;try{const i=window;return null===(e=null===(t=null==i?void 0:i.google)||void 0===t?void 0:t.ima)||void 0===e?void 0:e.VERSION}catch(t){return}},C=async()=>({client_time:Date.now()}),F=(t,e)=>Object.assign(t,{detail:e}),L=(t,{event:e,media_session_id:i,session_id:n,play_range_id:s})=>({event:e,media_session_id:i,session_id:n,play_range_id:s,device_id:t.deviceId(),version:"3.17.0-rc.2",commit:"3774131d2f3855e4b90ddf2aae704e2736d394be",ima_sdk_version:U(),preload:t.opt("preload"),autoplay:W(t.opt("autoplay")),live:t.opt("live"),dvr:!!t.live_state.dvr,source:t.original_src,downlink_mbs:R(t),page_url:O(),player_id:t.opt("metadata.player_id"),media_id:t.opt("metadata.media_id"),site_id:t.opt("metadata.site_id"),category_id:t.opt("metadata.category_id"),sitegroup_id:t.opt("metadata.sitegroup_id"),token:t.token,plugins:t.plugins.map(t=>t.constructor.name).sort((t,e)=>t.localeCompare(e)),current_time:t.currentTime,external_media_id:t.opt("external_media_id")}),k=t=>({bitrate:null==t?void 0:t.bitrate,resolution:null==t?void 0:t.attrs.RESOLUTION,frame_rate:null==t?void 0:t.attrs["FRAME-RATE"]});function P(t,e,i,n){const s=L(e,t.eventInfo(i)),{before:a,after:r}=n;b(t,((t,e,i)=>Object.assign(t,{state:{before:e,after:i}}))(s,k(a),k(r)))}const x=[1e7]+""+-1e3+-4e3+-8e3+-1e11,B=()=>"undefined"==typeof crypto?"":x.replace(/[018]/g,t=>(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16));var H;function G(t){switch(t){case H.MEDIA_PLAYBACK_ABORTED:return"media playback was aborted";case H.MEDIA_ERR_NETWORK:return"a network error occurred";case H.MEDIA_ERR_DECODE:return"unable to decode media content";case H.MEDIA_ERR_SRC_NOT_SUPPORTED:return"unsupported media type";case H.NO_INTERNET:return"no internet connection detected";case H.MIXED_CONTENT:return"cannot load insecure content in a secure context";default:return"an unknown error occurred"}}!function(t){t[t.UNKNOWN=-1]="UNKNOWN",t[t.MEDIA_PLAYBACK_ABORTED=1]="MEDIA_PLAYBACK_ABORTED",t[t.MEDIA_ERR_NETWORK=2]="MEDIA_ERR_NETWORK",t[t.MEDIA_ERR_DECODE=3]="MEDIA_ERR_DECODE",t[t.MEDIA_ERR_SRC_NOT_SUPPORTED=4]="MEDIA_ERR_SRC_NOT_SUPPORTED",t[t.MIXED_CONTENT=1001]="MIXED_CONTENT",t[t.NO_INTERNET=1002]="NO_INTERNET"}(H||(H={}));const j=(t,e)=>{let i=null;return(...n)=>{null!==i&&(clearTimeout(i),i=null),i=setTimeout(()=>e(...n),t)}};var K;!function(t){t[t.Starting=0]="Starting",t[t.ConfigFinalized=1]="ConfigFinalized",t[t.TimerStartedWithAdsAutoplay=2]="TimerStartedWithAdsAutoplay",t[t.TimerStartedWithContentAutoplay=3]="TimerStartedWithContentAutoplay",t[t.TimerStartedWithUserGesture=4]="TimerStartedWithUserGesture",t[t.MetricReported=5]="MetricReported"}(K||(K={}));class TimeToFirstFrame{constructor(t=K.Starting,e=!1,i=!1){this.state=t,this.loadedAd=e,this.requiresUserGesture=i}reset(){this.state=K.Starting,this.loadedAd=!1,this.elapsed=void 0}toJSON(){var t;return{ad_was_requested:this.loadedAd,ms_to_first_frame:Math.round((null===(t=this.elapsed)||void 0===t?void 0:t.duration)||-1)}}startTimer(t){this.state==K.ConfigFinalized&&(this.state=t,performance.mark("ttff:start"))}hasStarted(){return[K.TimerStartedWithAdsAutoplay,K.TimerStartedWithContentAutoplay,K.TimerStartedWithUserGesture].includes(this.state)}stopTimer(t){if(this.hasStarted()){performance.mark("ttff:end");const e=this.elapsed=performance.measure("ttff","ttff:start","ttff:end");this.state=K.MetricReported,t(e)}}}function z(t){return Math.round(1e3*t)/1e3}class EWMA{constructor(t){this.tickInterval=t,this.ewma=0,this.startTime=Date.now()}decay(){const t=Date.now()-this.startTime;return Math.pow(2,-t/(4*this.tickInterval))}update(t){const e=this.decay();return this.ewma=e*this.ewma+(1-e)*t,this.ewma}toJSON(){return this.ewma}}class WatchedState{constructor(t){this.player=t,this.marchingInterval=void 0,this.lastWatchedPoint=void 0,this.watchedSum=0,this.lastReportedSum=0,this.ewmaTickWatched=new EWMA(WatchedState.AccuracyMilliseconds)}reset(){this.onNotWatching(),this.watchedSum=0,this.lastReportedSum=0,this.lastWatchedPoint=void 0}onNotWatching(){this.marchingInterval&&(this.updateWatched(),this.marchingInterval=clearInterval(this.marchingInterval))}onWatching(){this.marchingInterval||(this.lastWatchedPoint=this.createWatchedPoint(),this.marchingInterval=setInterval(()=>{this.updateWatched()},WatchedState.AccuracyMilliseconds))}createWatchedPoint(){return{currentTime:this.player.currentTime,paused:this.player.paused}}updateWatched(){const t=this.createWatchedPoint();this.lastWatchedPoint&&this.calculateTimeWatched(this.lastWatchedPoint,t),this.lastWatchedPoint=t}calculateTimeWatched(t,e){const i=e.currentTime-t.currentTime,n=this.ewmaTickWatched.update(i);if(!(i<0)&&!(1e3*i>1.3*WatchedState.AccuracyMilliseconds)&&(this.watchedSum+=i,this.watchedSum!=this.lastReportedSum&&(this.watchedSum>this.lastReportedSum+WatchedState.ReportingIntervalSeconds||this.player.ended))){const t=z(n),e={total_watched_seconds:z(this.watchedSum),tick_watched_seconds:t,batch_watched_seconds:z(this.watchedSum-this.lastReportedSum)};this.lastReportedSum=this.watchedSum,this.player.emit(s,e)}}}WatchedState.ReportingIntervalSeconds=5,WatchedState.AccuracyMilliseconds=160;const q=B();class Health{constructor(t,e){let i;this.session_id=q,this.suspended=!1,this.logger=S("health",e.opts),this.media_session_id=B(),this.play_range_id=B(),this.analyticsLoop=setInterval(()=>M(this),2e3),e.on("reap",()=>clearInterval(this.analyticsLoop)),e.on(_,()=>{i!==this.media_session_id&&(i=this.media_session_id,this.first_playing_event_timestamp=Date.now()),this.play_range_id=B()});let n=Date.now()-1e3;e.on("timeupdate",t=>{if(i!==this.media_session_id)return;const s=Date.now();if(s<n)return;n=Date.now()+5e3;const a=L(e,this.eventInfo(t.type)),r=F(a,{duration:(o=e.duration,Number.isFinite(o)?o:o===1/0?-1:void 0)});var o;this.first_playing_event_timestamp&&(Object.assign(r,{ms_since_first_playing:s-this.first_playing_event_timestamp}),this.first_playing_event_timestamp=void 0),b(this,r)});const s=this;if(e.health={get media_session_id(){return s.media_session_id},set media_session_id(t){s.media_session_id=t},get session_id(){return s.session_id},set session_id(t){s.session_id=t},toggle(t){t?s.resume():s.suspend()}},!Health._UNLOAD_SUBSCRIBED){Health._UNLOAD_SUBSCRIBED=!0;const e=e=>t.instances.forEach(t=>t.emit(e.type));document.addEventListener("visibilitychange",t=>{"hidden"==document.visibilityState&&e(t)}),window.addEventListener("pagehide",e)}}eventInfo(t){return{event:t,media_session_id:this.media_session_id,session_id:this.session_id,play_range_id:this.play_range_id}}suspend(){this.suspended=!0,clearInterval(this.analyticsLoop)}resume(){this.suspended=!1,this.analyticsLoop=setInterval(()=>M(this),2e3)}init(a,S,w){if(O().toString().startsWith("data:"))return this.suspend();!function(i){let n=null;const s=()=>{n=null};i.on(m,(function(e){i.seeking||i.networkState===i.NETWORK_LOADING&&(i.readyState<HTMLMediaElement.HAVE_CURRENT_DATA||i.emit(t))})),i.on(t,t=>{n=t}),i.on(p,t=>{if(n){const a=t.timeStamp-n.timeStamp;if(s(),a<31)return;if(a>3e5)return;i.emit(e,{rebuffer_duration:a/1e3})}}),E.forEach(t=>i.on(t,s))}(w),function(t){let e;[p,v].forEach(i=>{t.on(i,i=>{const s=Date.now();switch(i.type){case v:return e=s;case p:if(e)return t.emit(n,{ms_since_loading_started:s-e}),e=null}})})}(w),function(t){if(void 0===window.performance)return;const e=new TimeToFirstFrame;t.on("ovp:config:finalized",t=>{e.reset(),e.state=K.ConfigFinalized,e.requiresUserGesture=!t.detail.autoplay}),t.on(v,()=>{t.root.classList.contains("ad-hide-first-frame")&&e.startTimer(K.TimerStartedWithAdsAutoplay),t.opt("autoplay")&&e.startTimer(K.TimerStartedWithContentAutoplay)}),t.on("click",()=>{t.opt("autoplay")||e.startTimer(K.TimerStartedWithUserGesture)}),t.on("ad-requested",()=>{e.loadedAd=!0}),t.on("timeupdate",()=>{if(!(t.readyState<HTMLMediaElement.HAVE_CURRENT_DATA))switch(e.state){case K.TimerStartedWithContentAutoplay:case K.TimerStartedWithUserGesture:return e.stopTimer(()=>t.emit(i,e.toJSON()))}}),t.on("ad-started",()=>{switch(e.state){case K.TimerStartedWithAdsAutoplay:case K.TimerStartedWithUserGesture:return e.stopTimer(()=>t.emit(i,e.toJSON()))}})}(w),function(t){const e=new WatchedState(t);t.on(v,()=>e.reset()),t.on(_,()=>e.onWatching()),t.on(u,()=>e.onNotWatching()),t.on(g,()=>e.onNotWatching()),t.on(f,()=>e.updateWatched()),t.on("visibilitychange",()=>e.updateWatched())}(w),w.on("display",t=>{b(this,L(w,this.eventInfo(t.type)),!0)}),w.on("health:record",({detail:t})=>{const e=L(w,this.eventInfo(t.event));Object.assign(e,t.detail||{}),b(this,e)}),[h,d,c,l,m,t].forEach(t=>{w.on(t,t=>{b(this,L(w,this.eventInfo(t.type)))})}),[e,i,n,s].forEach(t=>{w.on(t,t=>{const e=L(w,this.eventInfo(t.type));b(this,Object.assign(e,t.detail))})}),[_,u,g,y,f,r,o,p,v].forEach(t=>{w.on(t,t=>{b(this,L(w,this.eventInfo(t.type)))})}),w.on("volumechange",j(800,t=>{const e=L(w,this.eventInfo(t.type));b(this,F(e,{volume:parseFloat(w.volume.toFixed(2)),muted:w.muted}))})),w.on("resize",j(800,t=>{const e=L(w,this.eventInfo(t.type));b(this,F(e,{height:S.clientHeight,width:S.clientWidth}))})),w.on("hls/failover",t=>{const e=L(w,this.eventInfo(t.type)),i=t.detail,{reason:n,from:s}=i;b(this,F(e,{reason:n,from:s}))}),w.on("qualitychange",({type:t,detail:e})=>{switch(e.kind){case"hls":return P(this,w,t,e)}}),w.addEventListener("error",t=>{const e=L(w,this.eventInfo(t.type)),i=t.error||w.error;if(!i)return b(this,e,!0);const n=i.code,s={error_message:i.message||G(n),error_code:n,error_stack:i.stack||""};return b(this,F(e,s),!0)}),w.on("src",t=>{var e;const i=null===(e=t.detail)||void 0===e?void 0:e.src;if("string"!=typeof i)return;if(!T(w.original_src))return;if(!T(i))return;if(i==w.original_src)return;this.media_session_id=B();b(this,L(w,this.eventInfo(t.type))),M(this)}),w.on("visibilitychange",t=>{b(this,L(w,this.eventInfo(t.type))),M(this)})}}return Health.events=a,Health._UNLOAD_SUBSCRIBED=!1,function(t,e){if("object"==typeof exports&&"undefined"!=typeof module)return e;if(null===document.currentScript)return e;"flowplayer"in t||(t.flowplayer={extensions:[]});const i=t.flowplayer;return"function"==typeof i?(i(e),e):(Array.isArray(i.extensions)||(i.extensions=[]),~i.extensions.indexOf(e)||i.extensions.push(e),e)}(window,Health)}));
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((t="undefined"!=typeof globalThis?globalThis:t||self).flowplayer=t.flowplayer||{},t.flowplayer.health=e())}(this,(function(){"use strict";const t="rebuffer",e="rebuffer:ended",i="insights:ttff",n="insights:time_to_first_frag_loaded",s="insights:watched_interval";var a=Object.freeze({__proto__:null,RECORD:"health:record",REBUFFER:t,REBUFFER_ENDED:e,DISPLAY:"display",TIME_TO_FIRST_FRAME:i,TIME_TO_FIRST_FRAGMENT_LOADED:n,WATCHED_INTERVAL:s});const r="fullscreenenter",o="fullscreenexit",d="loadedmetadata",c="loadeddata",l="progress",h="loadstart",u="pause",_="playing",m="waiting",p="canplay",f="ended",y="seeked",g="seeking",v="content:loadstart",E=[v,"error","src"];function T(t){try{return!!new URL(t)}catch(t){return!1}}function S(t,e){const i=function(){try{return localStorage.getItem("flowplayer/debug")}catch(t){return""}}(),n=(n,...s)=>{try{const a=(null==e?void 0:e.debug)||i;a&&t.match(a)&&console.log(`flowplayer/${t} -- ${n}`,...s)}catch(t){console.warn(t)}};return n.log=n,n}const w=navigator;function R(t){var e,i;const n=null===(e=t.hls)||void 0===e?void 0:e.bandwidthEstimate;return n?1e-6*n:(null===(i=w.connection)||void 0===i?void 0:i.downlink)||-1}function A(t,e){return async function(t,e){try{await fetch(t,{body:e,method:"POST",mode:"no-cors"})}catch(t){}}(t,JSON.stringify({events:e}))}var I;!function(t){t[t.OFF=0]="OFF",t[t.ON=1]="ON",t[t.AUDIO_REQUIRED=2]="AUDIO_REQUIRED"}(I||(I={}));const W=t=>{switch(t){case!0:return I.ON;case!1:return I.OFF;default:return t}};function O(){try{const t=window.location!==window.parent.location?document.referrer:document.location.href;return"string"==typeof t&&t.slice(0,200)}catch(t){return!1}}const D=[],N="https://ihi.flowplayer.com/v1/health/events";function M(t){if(t.suspended)return;const e=D.slice(0);D.length=0,0!=e.length&&(t.logger.log(`:dispatch events={${e.length}}`),A(function(){try{return"undefined"==typeof window?N:window.__FLOWPLAYER_INSIGHTS_URL?window.__FLOWPLAYER_INSIGHTS_URL:N}catch(t){return N}}(),e))}async function b(t,e,i){const n=await C();D.push(Object.assign(e,n)),t.logger.log(":enqueue",e.event,e),D.length<10&&!i||M(t)}const U=()=>{var t,e;try{const i=window;return null===(e=null===(t=null==i?void 0:i.google)||void 0===t?void 0:t.ima)||void 0===e?void 0:e.VERSION}catch(t){return}},C=async()=>({client_time:Date.now()}),F=(t,e)=>Object.assign(t,{detail:e}),L=(t,{event:e,media_session_id:i,session_id:n,play_range_id:s})=>({event:e,media_session_id:i,session_id:n,play_range_id:s,device_id:t.deviceId(),version:"3.17.1",commit:"a470c80308623312bd4a81d3ff6897ca77b160a0",ima_sdk_version:U(),preload:t.opt("preload"),autoplay:W(t.opt("autoplay")),live:t.opt("live"),dvr:!!t.live_state.dvr,source:t.original_src,downlink_mbs:R(t),page_url:O(),player_id:t.opt("metadata.player_id"),media_id:t.opt("metadata.media_id"),site_id:t.opt("metadata.site_id"),category_id:t.opt("metadata.category_id"),sitegroup_id:t.opt("metadata.sitegroup_id"),token:t.token,plugins:t.plugins.map(t=>t.constructor.name).sort((t,e)=>t.localeCompare(e)),current_time:t.currentTime,external_media_id:t.opt("external_media_id")}),k=t=>({bitrate:null==t?void 0:t.bitrate,resolution:null==t?void 0:t.attrs.RESOLUTION,frame_rate:null==t?void 0:t.attrs["FRAME-RATE"]});function P(t,e,i,n){const s=L(e,t.eventInfo(i)),{before:a,after:r}=n;b(t,((t,e,i)=>Object.assign(t,{state:{before:e,after:i}}))(s,k(a),k(r)))}const x=[1e7]+""+-1e3+-4e3+-8e3+-1e11,B=()=>"undefined"==typeof crypto?"":x.replace(/[018]/g,t=>(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16));var H;function G(t){switch(t){case H.MEDIA_PLAYBACK_ABORTED:return"media playback was aborted";case H.MEDIA_ERR_NETWORK:return"a network error occurred";case H.MEDIA_ERR_DECODE:return"unable to decode media content";case H.MEDIA_ERR_SRC_NOT_SUPPORTED:return"unsupported media type";case H.NO_INTERNET:return"no internet connection detected";case H.MIXED_CONTENT:return"cannot load insecure content in a secure context";default:return"an unknown error occurred"}}!function(t){t[t.UNKNOWN=-1]="UNKNOWN",t[t.MEDIA_PLAYBACK_ABORTED=1]="MEDIA_PLAYBACK_ABORTED",t[t.MEDIA_ERR_NETWORK=2]="MEDIA_ERR_NETWORK",t[t.MEDIA_ERR_DECODE=3]="MEDIA_ERR_DECODE",t[t.MEDIA_ERR_SRC_NOT_SUPPORTED=4]="MEDIA_ERR_SRC_NOT_SUPPORTED",t[t.MIXED_CONTENT=1001]="MIXED_CONTENT",t[t.NO_INTERNET=1002]="NO_INTERNET"}(H||(H={}));const j=(t,e)=>{let i=null;return(...n)=>{null!==i&&(clearTimeout(i),i=null),i=setTimeout(()=>e(...n),t)}};var K;!function(t){t[t.Starting=0]="Starting",t[t.ConfigFinalized=1]="ConfigFinalized",t[t.TimerStartedWithAdsAutoplay=2]="TimerStartedWithAdsAutoplay",t[t.TimerStartedWithContentAutoplay=3]="TimerStartedWithContentAutoplay",t[t.TimerStartedWithUserGesture=4]="TimerStartedWithUserGesture",t[t.MetricReported=5]="MetricReported"}(K||(K={}));class TimeToFirstFrame{constructor(t=K.Starting,e=!1,i=!1){this.state=t,this.loadedAd=e,this.requiresUserGesture=i}reset(){this.state=K.Starting,this.loadedAd=!1,this.elapsed=void 0}toJSON(){var t;return{ad_was_requested:this.loadedAd,ms_to_first_frame:Math.round((null===(t=this.elapsed)||void 0===t?void 0:t.duration)||-1)}}startTimer(t){this.state==K.ConfigFinalized&&(this.state=t,performance.mark("ttff:start"))}hasStarted(){return[K.TimerStartedWithAdsAutoplay,K.TimerStartedWithContentAutoplay,K.TimerStartedWithUserGesture].includes(this.state)}stopTimer(t){if(this.hasStarted()){performance.mark("ttff:end");const e=this.elapsed=performance.measure("ttff","ttff:start","ttff:end");this.state=K.MetricReported,t(e)}}}function z(t){return Math.round(1e3*t)/1e3}class EWMA{constructor(t){this.tickInterval=t,this.ewma=0,this.startTime=Date.now()}decay(){const t=Date.now()-this.startTime;return Math.pow(2,-t/(4*this.tickInterval))}update(t){const e=this.decay();return this.ewma=e*this.ewma+(1-e)*t,this.ewma}toJSON(){return this.ewma}}class WatchedState{constructor(t){this.player=t,this.marchingInterval=void 0,this.lastWatchedPoint=void 0,this.watchedSum=0,this.lastReportedSum=0,this.ewmaTickWatched=new EWMA(WatchedState.AccuracyMilliseconds)}reset(){this.onNotWatching(),this.watchedSum=0,this.lastReportedSum=0,this.lastWatchedPoint=void 0}onNotWatching(){this.marchingInterval&&(this.updateWatched(),this.marchingInterval=clearInterval(this.marchingInterval))}onWatching(){this.marchingInterval||(this.lastWatchedPoint=this.createWatchedPoint(),this.marchingInterval=setInterval(()=>{this.updateWatched()},WatchedState.AccuracyMilliseconds))}createWatchedPoint(){return{currentTime:this.player.currentTime,paused:this.player.paused}}updateWatched(){const t=this.createWatchedPoint();this.lastWatchedPoint&&this.calculateTimeWatched(this.lastWatchedPoint,t),this.lastWatchedPoint=t}calculateTimeWatched(t,e){const i=e.currentTime-t.currentTime,n=this.ewmaTickWatched.update(i);if(!(i<0)&&!(1e3*i>1.3*WatchedState.AccuracyMilliseconds)&&(this.watchedSum+=i,this.watchedSum!=this.lastReportedSum&&(this.watchedSum>this.lastReportedSum+WatchedState.ReportingIntervalSeconds||this.player.ended))){const t=z(n),e={total_watched_seconds:z(this.watchedSum),tick_watched_seconds:t,batch_watched_seconds:z(this.watchedSum-this.lastReportedSum)};this.lastReportedSum=this.watchedSum,this.player.emit(s,e)}}}WatchedState.ReportingIntervalSeconds=5,WatchedState.AccuracyMilliseconds=160;const q=B();class Health{constructor(t,e){let i;this.session_id=q,this.suspended=!1,this.logger=S("health",e.opts),this.media_session_id=B(),this.play_range_id=B(),this.analyticsLoop=setInterval(()=>M(this),2e3),e.on("reap",()=>clearInterval(this.analyticsLoop)),e.on(_,()=>{i!==this.media_session_id&&(i=this.media_session_id,this.first_playing_event_timestamp=Date.now()),this.play_range_id=B()});let n=Date.now()-1e3;e.on("timeupdate",t=>{if(i!==this.media_session_id)return;const s=Date.now();if(s<n)return;n=Date.now()+5e3;const a=L(e,this.eventInfo(t.type)),r=F(a,{duration:(o=e.duration,Number.isFinite(o)?o:o===1/0?-1:void 0)});var o;this.first_playing_event_timestamp&&(Object.assign(r,{ms_since_first_playing:s-this.first_playing_event_timestamp}),this.first_playing_event_timestamp=void 0),b(this,r)});const s=this;if(e.health={get media_session_id(){return s.media_session_id},set media_session_id(t){s.media_session_id=t},get session_id(){return s.session_id},set session_id(t){s.session_id=t},toggle(t){t?s.resume():s.suspend()}},!Health._UNLOAD_SUBSCRIBED){Health._UNLOAD_SUBSCRIBED=!0;const e=e=>t.instances.forEach(t=>t.emit(e.type));document.addEventListener("visibilitychange",t=>{"hidden"==document.visibilityState&&e(t)}),window.addEventListener("pagehide",e)}}eventInfo(t){return{event:t,media_session_id:this.media_session_id,session_id:this.session_id,play_range_id:this.play_range_id}}suspend(){this.suspended=!0,clearInterval(this.analyticsLoop)}resume(){this.suspended=!1,this.analyticsLoop=setInterval(()=>M(this),2e3)}init(a,S,w){if(O().toString().startsWith("data:"))return this.suspend();!function(i){let n=null;const s=()=>{n=null};i.on(m,(function(e){i.seeking||i.networkState===i.NETWORK_LOADING&&(i.readyState<HTMLMediaElement.HAVE_CURRENT_DATA||i.emit(t))})),i.on(t,t=>{n=t}),i.on(p,t=>{if(n){const a=t.timeStamp-n.timeStamp;if(s(),a<31)return;if(a>3e5)return;i.emit(e,{rebuffer_duration:a/1e3})}}),E.forEach(t=>i.on(t,s))}(w),function(t){let e;[p,v].forEach(i=>{t.on(i,i=>{const s=Date.now();switch(i.type){case v:return e=s;case p:if(e)return t.emit(n,{ms_since_loading_started:s-e}),e=null}})})}(w),function(t){if(void 0===window.performance)return;const e=new TimeToFirstFrame;t.on("ovp:config:finalized",t=>{e.reset(),e.state=K.ConfigFinalized,e.requiresUserGesture=!t.detail.autoplay}),t.on(v,()=>{t.root.classList.contains("ad-hide-first-frame")&&e.startTimer(K.TimerStartedWithAdsAutoplay),t.opt("autoplay")&&e.startTimer(K.TimerStartedWithContentAutoplay)}),t.on("click",()=>{t.opt("autoplay")||e.startTimer(K.TimerStartedWithUserGesture)}),t.on("ad-requested",()=>{e.loadedAd=!0}),t.on("timeupdate",()=>{if(!(t.readyState<HTMLMediaElement.HAVE_CURRENT_DATA))switch(e.state){case K.TimerStartedWithContentAutoplay:case K.TimerStartedWithUserGesture:return e.stopTimer(()=>t.emit(i,e.toJSON()))}}),t.on("ad-started",()=>{switch(e.state){case K.TimerStartedWithAdsAutoplay:case K.TimerStartedWithUserGesture:return e.stopTimer(()=>t.emit(i,e.toJSON()))}})}(w),function(t){const e=new WatchedState(t);t.on(v,()=>e.reset()),t.on(_,()=>e.onWatching()),t.on(u,()=>e.onNotWatching()),t.on(g,()=>e.onNotWatching()),t.on(f,()=>e.updateWatched()),t.on("visibilitychange",()=>e.updateWatched())}(w),w.on("display",t=>{b(this,L(w,this.eventInfo(t.type)),!0)}),w.on("health:record",({detail:t})=>{const e=L(w,this.eventInfo(t.event));Object.assign(e,t.detail||{}),b(this,e)}),[h,d,c,l,m,t].forEach(t=>{w.on(t,t=>{b(this,L(w,this.eventInfo(t.type)))})}),[e,i,n,s].forEach(t=>{w.on(t,t=>{const e=L(w,this.eventInfo(t.type));b(this,Object.assign(e,t.detail))})}),[_,u,g,y,f,r,o,p,v].forEach(t=>{w.on(t,t=>{b(this,L(w,this.eventInfo(t.type)))})}),w.on("volumechange",j(800,t=>{const e=L(w,this.eventInfo(t.type));b(this,F(e,{volume:parseFloat(w.volume.toFixed(2)),muted:w.muted}))})),w.on("resize",j(800,t=>{const e=L(w,this.eventInfo(t.type));b(this,F(e,{height:S.clientHeight,width:S.clientWidth}))})),w.on("hls/failover",t=>{const e=L(w,this.eventInfo(t.type)),i=t.detail,{reason:n,from:s}=i;b(this,F(e,{reason:n,from:s}))}),w.on("qualitychange",({type:t,detail:e})=>{switch(e.kind){case"hls":return P(this,w,t,e)}}),w.addEventListener("error",t=>{const e=L(w,this.eventInfo(t.type)),i=t.error||w.error;if(!i)return b(this,e,!0);const n=i.code,s={error_message:i.message||G(n),error_code:n,error_stack:i.stack||""};return b(this,F(e,s),!0)}),w.on("src",t=>{var e;const i=null===(e=t.detail)||void 0===e?void 0:e.src;if("string"!=typeof i)return;if(!T(w.original_src))return;if(!T(i))return;if(i==w.original_src)return;this.media_session_id=B();b(this,L(w,this.eventInfo(t.type))),M(this)}),w.on("visibilitychange",t=>{b(this,L(w,this.eventInfo(t.type))),M(this)})}}return Health.events=a,Health._UNLOAD_SUBSCRIBED=!1,function(t,e){if("object"==typeof exports&&"undefined"!=typeof module)return e;if(null===document.currentScript)return e;"flowplayer"in t||(t.flowplayer={extensions:[]});const i=t.flowplayer;return"function"==typeof i?(i(e),e):(Array.isArray(i.extensions)||(i.extensions=[]),~i.extensions.indexOf(e)||i.extensions.push(e),e)}(window,Health)}));
package/plugins/hls.d.ts CHANGED
@@ -161,6 +161,55 @@ CONTEXT_MENU = "contextmenu";
161
161
  */
162
162
  declare type ContextMenuEventDetail = null;
163
163
 
164
+ /**
165
+ * @public
166
+ * @deprecated
167
+ * when a cuepoint becomes inactive
168
+ */
169
+ declare const /**
170
+ @public
171
+ * when a new player is inserted into the HTML
172
+ */ /**
173
+ * @public
174
+ * @deprecated
175
+ * when a cuepoint becomes inactive
176
+ */
177
+ CUEPOINT_END = "cuepointend";
178
+
179
+ /**
180
+ * @public
181
+ * @deprecated
182
+ * when a cuepoint is active
183
+ */
184
+ declare const /**
185
+ @public
186
+ * when a new player is inserted into the HTML
187
+ */ /**
188
+ * @public
189
+ * @deprecated
190
+ * when a cuepoint is active
191
+ */
192
+ CUEPOINT_START = "cuepointstart";
193
+
194
+ /**
195
+ * @public
196
+ * @deprecated
197
+ * cuepoints parsing is asynchronous
198
+ * you cannot rely on them existing until
199
+ * this event is emitted
200
+ */
201
+ declare const /**
202
+ @public
203
+ * when a new player is inserted into the HTML
204
+ */ /**
205
+ * @public
206
+ * @deprecated
207
+ * cuepoints parsing is asynchronous
208
+ * you cannot rely on them existing until
209
+ * this event is emitted
210
+ */
211
+ CUEPOINTS = "cuepoints";
212
+
164
213
  /**
165
214
  * @public
166
215
  */
@@ -351,7 +400,10 @@ declare namespace events_2 {
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