@flowplayer/player 3.0.1-canary.8 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/core/autoplay-enum.d.ts +5 -0
  2. package/core/autoplay-enum.js +9 -0
  3. package/core/events.d.ts +12 -0
  4. package/core/events.js +9 -0
  5. package/core/quality-enum.d.ts +5 -0
  6. package/core/quality-enum.js +9 -0
  7. package/core.js +2 -2
  8. package/default.js +2 -2
  9. package/drm/constants.d.ts +12 -0
  10. package/drm/constants.js +15 -0
  11. package/drm/types.d.ts +46 -0
  12. package/drm/types.js +3 -0
  13. package/embed.js +93 -93
  14. package/flowplayer.css +1 -1
  15. package/index.d.ts +53 -4
  16. package/package.json +15 -2
  17. package/plugins/ads.js +2 -2
  18. package/plugins/airplay.js +1 -1
  19. package/plugins/analytics.js +1 -1
  20. package/plugins/asel.js +1 -1
  21. package/plugins/audio.js +1 -1
  22. package/plugins/chapters.js +1 -1
  23. package/plugins/chromecast.js +1 -1
  24. package/plugins/context-menu.js +1 -1
  25. package/plugins/cuepoints.js +1 -1
  26. package/plugins/dash.js +2 -2
  27. package/plugins/drm.js +1 -1
  28. package/plugins/endscreen.js +1 -1
  29. package/plugins/fas.js +1 -1
  30. package/plugins/float-on-scroll.js +1 -1
  31. package/plugins/gemius.js +1 -1
  32. package/plugins/google-analytics.js +1 -1
  33. package/plugins/health.js +1 -1
  34. package/plugins/hls.js +2 -2
  35. package/plugins/id3.js +1 -1
  36. package/plugins/iframe.js +1 -1
  37. package/plugins/keyboard.js +1 -1
  38. package/plugins/media-session.js +1 -1
  39. package/plugins/message.js +1 -1
  40. package/plugins/ovp.js +1 -1
  41. package/plugins/playlist.js +1 -1
  42. package/plugins/preview.js +1 -1
  43. package/plugins/qsel.js +1 -1
  44. package/plugins/qul.js +1 -1
  45. package/plugins/share.js +1 -1
  46. package/plugins/speed.js +1 -1
  47. package/plugins/ssai.js +1 -0
  48. package/plugins/subtitles.js +1 -1
  49. package/plugins/thumbnails.js +1 -1
  50. package/util/loader.d.ts +8 -0
  51. package/util/loader.js +43 -0
package/plugins/drm.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.drm=t())}(this,(function(){"use strict";const e="com.widevine.alpha",t="com.apple.fps.1_0";var n=Object.freeze({__proto__:null,WIDEVINE:e,PLAYREADY:"com.microsoft.playready",CLEARKEY:"org.w3.clearkey",FAIRPLAY:t,LICENSE_SERVER:"license_server",KEY:"key",KEY_ID:"kid",HTTP_HEADERS:"http_headers",QUERY_PARAMS:"query_params",CERTIFICATE:"certificate",VENDOR:"vendor",REQUEST_MEDIA_KEY_SYSTEM_ACCESS_FUNCTION:"request_media_key_system_access_function"});function r(t){const n={};return Object.keys(t).forEach((function(r){var s;s=r,[e].filter((function(e){return e===s})).length&&function(t,n,r){if(t===e){r.widevineLicenseUrl=n.license_server,r.emeEnabled=!0;const e=n.http_headers;n.request_media_key_system_access_function&&(r.requestMediaKeySystemAccessFunc=n.request_media_key_system_access_function||null),e&&(r.licenseXhrSetup=function(t){Object.keys(e).forEach((function(n){t.setRequestHeader(n,e[n])}))})}}(r,t[r],n)})),n}const s=[e,"com.microsoft.playready","org.w3.clearkey"];function a(e){const t={};return Object.keys(e).forEach((function(n){var r;r=n,s.find((function(e){return e===r}))&&(t[n]=function(e){const t={serverURL:e.license_server};return e.http_headers&&(t.httpRequestHeaders=e.http_headers),t}(e[n]))})),t}const o=(e,t)=>fetch(e,t).then(i).then(e=>new Uint8Array(e)),i=e=>{if(e.ok)return e.arrayBuffer();throw c(e)},c=e=>new Error(`http:error status=${e.status} during key retrieval`);var f=Object.freeze({__proto__:null,fairplay_fetch_certificate:e=>o(e),fairplay_request_license:function(e,t){return o(e+new URLSearchParams(t.queryParams).toString(),{method:"POST",headers:{"Content-Type":"application/octet-stream"},body:t.message})}});var u=Object.freeze({__proto__:null,fairplay_fetch_certificate:e=>o(e),fairplay_request_license:function(e,t){const n=new FormData;var r;return n.set("assetid",t.assetId),n.set("spc",(r=t.message,btoa(Array.prototype.map.call(r,(function(e){return String.fromCharCode(e)})).join("")))),fetch(e,{method:"POST",body:n,headers:t.headers}).then(e=>{if(e.ok)return e.text();throw c(e)}).then(e=>function(e){const t=atob(e),n=new Uint8Array(t.length);return Array.prototype.forEach.call(t,(function(e,t){n[t]=e.charCodeAt(0)})),n}(e))}}),d=Object.freeze({__proto__:null,ezdrm:f,buydrm:u});function l(e,n,r){if(!n[t])return;if(e.src&&0===e.src.indexOf("blob:"))return;const s=n[t].vendor||"ezdrm",a="string"==typeof s?d[s]:s;a.fairplay_fetch_certificate(n[t].certificate||null,(function(s){e.webkitSetMediaKeys(new window.WebkitMediaKeys("com.apple.fps.1_0"));const o=r.initData,i=function(e){const t=function(e){const t=new Uint16Array(e);return String.fromCharCode(...t)}(e.buffer);return t.substring(t.indexOf("skd:")+6).split(";").pop()}(o);if(!i)return console.debug("flowplayer::drm::fairplay - unable to extract content id from init data");const c=function(e,t,n){"string"==typeof t&&(t=function(e){const t=new ArrayBuffer(2*e.length),n=new Uint16Array(t);return Array(...Array(e.length)).map((e,t)=>t).forEach(t=>{n[t]=e.charCodeAt(t)}),n}(t));let r=0;const s=new ArrayBuffer(e.byteLength+4+t.byteLength+4+n.byteLength),a=new DataView(s);new Uint8Array(s,r,e.byteLength).set(e),r+=e.byteLength,a.setUint32(r,t.byteLength,!0),r+=4;const o=new Uint16Array(s,r,t.length);o.set(t),r+=o.byteLength,a.setUint32(r,n.byteLength,!0),r+=4;return new Uint8Array(s,r,n.byteLength).set(n),new Uint8Array(s,0,s.byteLength)}(o,i,s),f=e.webkitKeys.createSession("application/x-mpegurl",c);f.addEventListener("webkitkeyerror",console.debug.bind(console,"webkitkeyerror")),f.addEventListener("webkitkeymessage",(function(e){const r={message:e.message,assetId:i,headers:n[t].http_headers||{},queryParams:n[t].query_params||{}};a.fairplay_request_license(n[t].license_server,r,e=>f.update(e))}))}))}class y{init(e,t,n){n.on("src",(function(t){var s;if(!(null===(s=t.data)||void 0===s?void 0:s.drm))return;const o=e.hls||{},i=t.data.drm?r(t.data.drm):{};n.setOpts({hls:Object.assign(o,i)}),n.on("webkitneedkey",l.bind(null,n,t.data.drm||{}));const c=e.dash||{},f=t.data.drm?a(t.data.drm):{};n.setOpts({dash:Object.assign(c,{drm:f})})}))}}return Object.assign(y,n),function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;"function"==typeof n?n(t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t))}(window,y),y}));
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.drm=t())}(this,(function(){"use strict";const e="com.widevine.alpha",t="com.apple.fps.1_0";var n=Object.freeze({__proto__:null,WIDEVINE:e,PLAYREADY:"com.microsoft.playready",CLEARKEY:"org.w3.clearkey",FAIRPLAY:t,LICENSE_SERVER:"license_server",KEY:"key",KEY_ID:"kid",HTTP_HEADERS:"http_headers",QUERY_PARAMS:"query_params",CERTIFICATE:"certificate",VENDOR:"vendor",REQUEST_MEDIA_KEY_SYSTEM_ACCESS_FUNCTION:"request_media_key_system_access_function"});function r(t){const n={};return Object.keys(t).forEach((function(r){var s;s=r,[e].filter((function(e){return e===s})).length&&function(t,n,r){if(t===e){r.widevineLicenseUrl=n.license_server,r.emeEnabled=!0;const e=n.http_headers;n.request_media_key_system_access_function&&(r.requestMediaKeySystemAccessFunc=n.request_media_key_system_access_function||null),e&&(r.licenseXhrSetup=function(t){Object.keys(e).forEach((function(n){t.setRequestHeader(n,e[n])}))})}}(r,t[r],n)})),n}const s=[e,"com.microsoft.playready","org.w3.clearkey"];function a(e){const t={};return Object.keys(e).forEach((function(n){var r;r=n,s.find((function(e){return e===r}))&&(t[n]=function(e){const t={serverURL:e.license_server};return e.http_headers&&(t.httpRequestHeaders=e.http_headers),t}(e[n]))})),t}const o=(e,t)=>fetch(e,t).then(i).then(e=>new Uint8Array(e)),i=e=>{if(e.ok)return e.arrayBuffer();throw c(e)},c=e=>new Error(`http:error status=${e.status} during key retrieval`);var f=Object.freeze({__proto__:null,fairplay_fetch_certificate:e=>o(e),fairplay_request_license:function(e,t){return o(e+new URLSearchParams(t.queryParams).toString(),{method:"POST",headers:{"Content-Type":"application/octet-stream"},body:t.message})}});var u=Object.freeze({__proto__:null,fairplay_fetch_certificate:e=>o(e),fairplay_request_license:function(e,t){const n=new FormData;var r;return n.set("assetid",t.assetId),n.set("spc",(r=t.message,btoa(Array.prototype.map.call(r,(function(e){return String.fromCharCode(e)})).join("")))),fetch(e,{method:"POST",body:n,headers:t.headers}).then(e=>{if(e.ok)return e.text();throw c(e)}).then(e=>function(e){const t=atob(e),n=new Uint8Array(t.length);return Array.prototype.forEach.call(t,(function(e,t){n[t]=e.charCodeAt(0)})),n}(e))}}),d=Object.freeze({__proto__:null,ezdrm:f,buydrm:u});function l(e,n,r){if(!n[t])return;if(e.src&&0===e.src.indexOf("blob:"))return;const s=n[t].vendor||"ezdrm",a="string"==typeof s?d[s]:s;a.fairplay_fetch_certificate(n[t].certificate||null,(function(s){e.webkitSetMediaKeys(new window.WebkitMediaKeys("com.apple.fps.1_0"));const o=r.initData,i=function(e){const t=function(e){const t=new Uint16Array(e);return String.fromCharCode(...t)}(e.buffer);return t.substring(t.indexOf("skd:")+6).split(";").pop()}(o);if(!i)return console.debug("flowplayer::drm::fairplay - unable to extract content id from init data");const c=function(e,t,n){"string"==typeof t&&(t=function(e){const t=new ArrayBuffer(2*e.length),n=new Uint16Array(t);return Array(...Array(e.length)).map((e,t)=>t).forEach(t=>{n[t]=e.charCodeAt(t)}),n}(t));let r=0;const s=new ArrayBuffer(e.byteLength+4+t.byteLength+4+n.byteLength),a=new DataView(s);new Uint8Array(s,r,e.byteLength).set(e),r+=e.byteLength,a.setUint32(r,t.byteLength,!0),r+=4;const o=new Uint16Array(s,r,t.length);o.set(t),r+=o.byteLength,a.setUint32(r,n.byteLength,!0),r+=4;return new Uint8Array(s,r,n.byteLength).set(n),new Uint8Array(s,0,s.byteLength)}(o,i,s),f=e.webkitKeys.createSession("application/x-mpegurl",c);f.addEventListener("webkitkeyerror",console.debug.bind(console,"webkitkeyerror")),f.addEventListener("webkitkeymessage",(function(e){const r={message:e.message,assetId:i,headers:n[t].http_headers||{},queryParams:n[t].query_params||{}};a.fairplay_request_license(n[t].license_server,r,e=>f.update(e))}))}))}class DRM{init(e,t,n){n.on("src",(function(t){var s;if(!(null===(s=t.data)||void 0===s?void 0:s.drm))return;const o=e.hls||{},i=t.data.drm?r(t.data.drm):{};n.setOpts({hls:Object.assign(o,i)}),n.on("webkitneedkey",l.bind(null,n,t.data.drm||{}));const c=e.dash||{},f=t.data.drm?a(t.data.drm):{};n.setOpts({dash:Object.assign(c,{drm:f})})}))}}return Object.assign(DRM,n),function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;"function"==typeof n?n(t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t))}(window,DRM),DRM}));
@@ -1 +1 @@
1
- !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.endscreen=n())}(this,(function(){"use strict";var e="playlist:ended";class n{constructor(e){this.data=e}static of(e){return new n(e)}static maybe(e,n,...t){return null==e?e:n.apply(e,[e,...t])}tap(e,...t){return e.apply(this,[this.data,...t]),new n(this.data)}fmap(e,...t){const o=e.apply(this,[this.data,...t]);return new n(o)}unwrap(){return this.data}}function t(e,n){if(!n)throw new Error(e)}function o(e){return"invalid recommendations configuration\ndetails: "+e+"\n\tmust match Object of shape:\n"+["\t\t{ playlist: PlaylistId|Array(MediaId|PlayerConfig)"].join("\n\t\t, ")+"\n\t\t}"}function i(e,i){n.of(e).fmap(o).fmap(t,i)}function r(e){return void 0!==e}function s(e){return"string"==typeof e}function a(e){return"object"==typeof e}function l(e){var n;i("Config must be an Object",r(e)&&a(e)),i("property `playlist` is required",r(null==e?void 0:e.playlist)),i("property `playlist` was not an array nor playlist id",(n=null==e?void 0:e.playlist,i("playlist property was not of type PlaylistId|Array(MediaId|PlayerConfig)",Array.isArray(n)),!(null==n?void 0:n.forEach((function(e,n){i("item at playlist["+n+"] was not valid",s(e)||a(e))})))))}function c(e,n,t){const o=function(e){return Array.isArray(e)?e.slice(0):e.split(".")}(n);for(;o.length;){if(null==e)return t;const n=o.shift();if("string"!=typeof n)return t;e=e[n]}return null==e?t:e}function d(e,n){const t=function(e,n){const t=document.createElement("div");t.classList.add("fp-endscreen-cell-thumbnail"),t.addEventListener("click",u.bind(null,e,n)),e.poster&&(t.style.backgroundImage=["url(",e.poster,")"].join(""));return t}(e,n);return t.append(function(e){const n=document.createElement("div");return n.classList.add("fp-endscreen-cell-title"),n.textContent=e.title||"",n}(e)),t}function u(e,n){"object"==typeof e&&n.setOpts(e),function(e,n,t){if(e.setSrc(s(n)?n:n.src),c(t,"should_play",!1))e.play()}(n,e,{should_play:!0})}function f(e){return n=>{setTimeout((function(){if(!n.defaultPrevented)return e(n)}),0)}}class p{init(n,t,o){const i=document.createElement("div");i.classList.add("fp-endscreen"),0!=o.reaper&&o.reaper.set("endscreen",i),o.on("mount",(function(){const e=o.root.querySelector(".fp-middle");e&&e.append(i)})),o.on("recommendationsready",(function(e){const t=e.data;l(t),i.recommendations=t,!o.ended||o.playlist||n.loop||o.emit("recommendations:render")})),o.on(["ended",e],f((function(e){"ended"==e.type&&o.playlist||i.recommendations&&(n.loop||o.emit("recommendations:render"))}))),o.on(["loadstart","playing"],(function(){o.emit("recommendations:hide")})),o.on("recommendations:hide",f((function(){o.setState("is-endscreen",!1)}))),o.on("recommendations:render",f((function(){!function(e,n,t){n.innerHTML="";const o=n.recommendations;if(!o||0===o.playlist.length)return;const i=e.classList.contains("is-small")||e.classList.contains("is-tiny")?6:12,r=[];if(o.playlist.forEach((function(e){if(r.length!==i&&e.poster&&e.title){const n=document.createElement("div");n.classList.add("fp-endscreen-cell"),n.append(d(e,t)),r.push(n)}})),0===r.length)return;const s=document.createElement("div");s.classList.add("fp-endscreen-cells"),s.append(...r),n.append(s)}(t,i,o),o.setState("is-endscreen",!0)})))}}return p.events={RECOMMENDATIONS_RENDER:"recommendations:render",RECOMMENDATIONS_READY:"recommendationsready",RECOMMENDATIONS_HIDE:"recommendations:hide"},function(e,n){if("object"==typeof exports&&"undefined"!=typeof module)return n;"flowplayer"in e||(e.flowplayer={extensions:[]});const t=e.flowplayer;return"function"==typeof t?(t(n),n):(Array.isArray(t.extensions)||(t.extensions=[]),~t.extensions.indexOf(n)||t.extensions.push(n),n)}(window,p)}));
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.endscreen=t())}(this,(function(){"use strict";var e="playlist:ended";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}}function t(e,t){if(!t)throw new Error(e)}function n(e){return"invalid recommendations configuration\ndetails: "+e+"\n\tmust match Object of shape:\n"+["\t\t{ playlist: PlaylistId|Array(MediaId|PlayerConfig)"].join("\n\t\t, ")+"\n\t\t}"}function o(e,o){Pipe.of(e).fmap(n).fmap(t,o)}function i(e){return void 0!==e}function r(e){return"string"==typeof e}function s(e){return"object"==typeof e}function a(e){var t;o("Config must be an Object",i(e)&&s(e)),o("property `playlist` is required",i(null==e?void 0:e.playlist)),o("property `playlist` was not an array nor playlist id",(t=null==e?void 0:e.playlist,o("playlist property was not of type PlaylistId|Array(MediaId|PlayerConfig)",Array.isArray(t)),!(null==t?void 0:t.forEach((function(e,t){o("item at playlist["+t+"] was not valid",r(e)||s(e))})))))}function c(e,t,n){const o=function(e){return Array.isArray(e)?e.slice(0):e.split(".")}(t);for(;o.length;){if(null==e)return n;const t=o.shift();if("string"!=typeof t)return n;e=e[t]}return null==e?n:e}function l(e,t){const n=function(e,t){const n=document.createElement("div");n.classList.add("fp-endscreen-cell-thumbnail"),n.addEventListener("click",d.bind(null,e,t)),e.poster&&(n.style.backgroundImage=["url(",e.poster,")"].join(""));return n}(e,t);return n.append(function(e){const t=document.createElement("div");return t.classList.add("fp-endscreen-cell-title"),t.textContent=e.title||"",t}(e)),n}function d(e,t){"object"==typeof e&&t.setOpts(e),function(e,t,n){if(e.setSrc(r(t)?t:t.src),c(n,"should_play",!1))e.play()}(t,e,{should_play:!0})}function u(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}function p(e,t){const n=e.style;return Object.keys(t).forEach(e=>n[e]=t[e]),e}function f(...e){const t=document.createElement("div");return 0==e.length||t.classList.add(...e),t}function m(e){return t=>{setTimeout((function(){if(!t.defaultPrevented)return e(t)}),0)}}var y;!function(e){e[e.SHUFFLE=1]="SHUFFLE",e[e.FIFO=2]="FIFO",e[e.LOOP=4]="LOOP"}(y||(y={}));const v=(e,t)=>new(((e,t)=>{const n=e.get(t);if(!n)throw new Error(`no flowplayer component with the name ${t} exists`);const o=window.customElements.get(t);if(!o)throw new Error(`no default flowplayer component with the name ${t} exists`);const i=window.customElements.get(n);return"function"!=typeof i?o:i})(e._customElements,t))(e);function h(e,t){if(!t[e])return;const n=document.createElement("span");n.innerText=t[e];const o=f(e);return o.append(n),o}function w(e){return Math.min(100*e,100)+"%"}class Endscreen{init(t,n,o){var i;const r=document.createElement("div");r.classList.add((null===(i=t.endscreen)||void 0===i?void 0:i.interstitial)?"fp-interstitial":"fp-endscreen"),0!=o.reaper&&o.reaper.set("endscreen",r),o.on("mount",(function(){var e;null===(e=u(o,"flowplayer-middle"))||void 0===e||e.append(r)})),o.on("recommendationsready",(function(e){const n=e.data;a(n),r.recommendations=n,!o.ended||o.playlist||t.loop||o.emit("recommendations:render")})),o.on(["ended",e],m((function(e){"ended"==e.type&&o.playlist||r.recommendations&&(t.loop||o.emit("recommendations:render"))}))),o.on(["loadstart","playing"],(function(e){var n;"loadstart"===e.type&&(null===(n=t.endscreen)||void 0===n?void 0:n.interstitial)||o.emit("recommendations:hide")})),o.on("recommendations:hide",m((function(){o.setState("is-endscreen",!1),o.setState("is-interstitial",!1)}))),o.on("recommendations:render",m((function(){var e;(null===(e=t.endscreen)||void 0===e?void 0:e.interstitial)?function(e,t,n){var o,i;if(!(null===(o=t.recommendations)||void 0===o?void 0:o.playlist.length))return;if(n.hasState("is-interstitial"))return;const r=(e,o=!1)=>{var i;const r=null===(i=t.recommendations)||void 0===i?void 0:i.playlist[e];if(!r)return;const{src:s,title:a}=r;n.setSrc(s),n.setOpts({title:a}),o&&n.on("canplay",()=>n.togglePlay(!0))};r(0);const s={config:{advance:!0,delay:2e9},timer:setTimeout(()=>{n.togglePlay(!0)},2e9)},a=u(n,"flowplayer-middle");n.setState("is-interstitial",!0);const{poster:c,src:l,title:d}=null===(i=t.recommendations)||void 0===i?void 0:i.playlist[0];if(s&&a){const e=function(e,t,n,o){const i=f("left");i.append(v(e,"flowplayer-play-icon")),t.poster&&(i.style.backgroundImage=["url(",t.poster,")"].join(""));const r=f("right"),s=f("up-next"),a=document.createElement("span");a.innerText=e.i18n("playlist.up_next");const c=f("fp-color","countdown");s.append(a,c),r.append(s);const l=h("title",t);l&&r.append(l);const d=h("description",t);if(d&&r.append(d),o.timer){const t=f("cancel");t.onclick=function(e){return o.timer&&clearTimeout(o.timer),o.timer=void 0,e.target.remove(),e.preventDefault(),!1};const n=document.createElement("span");n.innerText=e.i18n("playlist.cancel"),t.append(n),r.append(t)}return[i,r]}(n,{poster:c,src:l,title:d},0,s),o=function(e,t){const n=document.createElement("div");return n.classList.add("bottom"),e.length<2||n.append(...e.slice(1).map((e,n)=>{const o=document.createElement("div");o.style.setProperty("background-image",`url('${e.poster}')`),o.addEventListener("click",e=>{e.stopPropagation(),t(n+1)});const i=document.createElement("p");return i.innerHTML=e.title||"",o.append(i),o})),n}(t.recommendations.playlist,e=>r(e,!0));t.append(...e.concat(o))}n.once("play",e=>{t.innerHTML="",t.recommendations={playlist:[]}}),s.config.advance&&function(e,t,n){var o;if(!n)throw new Error("no element to animate was passed");const i=null!==(o=t.config.delay)&&void 0!==o?o:0,r=Date.now()+i;let s=Date.now();const a=Math.ceil(1e3/60);!function o(){const c=Date.now();if(c>r||!e.paused)return;if(!t.timer)return p(n,{width:w(0)});requestAnimationFrame(o),c-s<a||(s=c,p(n,{width:w(1-(r-c)/i)}))}()}(n,s,t.querySelector(".countdown"))}(0,r,o):function(e,t,n){t.innerHTML="";const o=t.recommendations;if(!o||0===o.playlist.length)return;const i=e.classList.contains("is-small")||e.classList.contains("is-tiny")?6:12,r=[];if(o.playlist.forEach((function(e){if(r.length!==i&&e.poster&&e.title){const t=document.createElement("div");t.classList.add("fp-endscreen-cell"),t.append(l(e,n)),r.push(t)}})),0===r.length)return;const s=document.createElement("div");s.classList.add("fp-endscreen-cells"),s.append(...r),t.append(s)}(n,r,o),o.setState("is-endscreen",!0)})))}}return Endscreen.events={RECOMMENDATIONS_RENDER:"recommendations:render",RECOMMENDATIONS_READY:"recommendationsready",RECOMMENDATIONS_HIDE:"recommendations:hide"},function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)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,Endscreen)}));
package/plugins/fas.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.fas=t())}(this,(function(){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var t=function(e){var t={exports:{}};return e(t,t.exports),t.exports}((function(t,r){var o,s;o=e,(s=function(e,t,r){if(!(this instanceof s))return new s(e,t,r);if(void 0===t)this.frameRate=29.97;else{if(!("number"==typeof t&&t>0))throw new Error("Number expected as framerate");this.frameRate=t}if(23.976!==this.frameRate&&24!==this.frameRate&&25!==this.frameRate&&29.97!==this.frameRate&&30!==this.frameRate&&50!==this.frameRate&&59.94!==this.frameRate&&60!==this.frameRate)throw new Error("Unsupported framerate");if(this.dropFrame="boolean"==typeof r?r:29.97===this.frameRate||59.94===this.frameRate,"number"==typeof e)this.frameCount=Math.round(e),this._frameCountToTimeCode();else if("string"==typeof e){var o=e.match("^([012]\\d):(\\d\\d):(\\d\\d)(:|;|\\.)(\\d\\d)$");if(!o)throw new Error("Timecode string expected as HH:MM:SS:FF or HH:MM:SS;FF");this.hours=parseInt(o[1]),this.minutes=parseInt(o[2]),this.seconds=parseInt(o[3]),"boolean"!=typeof r&&(this.dropFrame=":"!==o[4]),this.frames=parseInt(o[5]),this._timeCodeToFrameCount()}else if("object"==typeof e&&e instanceof Date){var i=new Date(e.getFullYear(),e.getMonth(),e.getDate(),0,0,0),a=60*i.getTimezoneOffset()*1e3,n=60*e.getTimezoneOffset()*1e3;this.frameCount=Math.round((e-i+(a-n))*this.frameRate/1e3),this._frameCountToTimeCode()}else if("object"==typeof e&&e.hours>=0)this.hours=e.hours,this.minutes=e.minutes,this.seconds=e.seconds,this.frames=e.frames,this._timeCodeToFrameCount();else{if(void 0!==e)throw new Error("Timecode() constructor expects a number, timecode string, or Date()");this.frameCount=0}return this._validate(e),this}).prototype._validate=function(e){if(this.dropFrame&&29.97!==this.frameRate&&59.94!==this.frameRate)throw new Error("Drop frame is only supported for 29.97 and 59.94 fps");if(this.hours>23||this.minutes>59||this.seconds>59||this.frames>=this.frameRate||this.dropFrame&&0===this.seconds&&this.minutes%10&&this.frames<this.frameRate/29.97*2)throw new Error("Invalid timecode"+JSON.stringify(e))},s.prototype._frameCountToTimeCode=function(){var e=this.frameCount;if(this.dropFrame){var t=29.97===this.frameRate?2:4,r=Math.floor(this.frameCount/(17982*t/2)),o=this.frameCount%(17982*t/2);o<t&&(o+=t),e+=9*t*r+t*Math.floor((o-t)/(1798*t/2))}var s=Math.round(this.frameRate);this.frames=e%s,this.seconds=Math.floor(e/s)%60,this.minutes=Math.floor(e/(60*s))%60,this.hours=Math.floor(e/(3600*s))%24},s.prototype._timeCodeToFrameCount=function(){if(this.frameCount=(3600*this.hours+60*this.minutes+this.seconds)*Math.round(this.frameRate)+this.frames,this.dropFrame){var e=60*this.hours+this.minutes,t=29.97===this.frameRate?2:4;this.frameCount-=t*(e-Math.floor(e/10))}},s.prototype.toString=function(e){var t=this.frames,r="";if("string"==typeof e){if("field"!==e)throw new Error("Unsupported string format");this.frameRate<=30?r=".0":(t=Math.floor(t/2),r=".".concat((this.frameCount%2).toString()))}return"".concat(this.hours<10?"0":"",this.hours.toString(),":",this.minutes<10?"0":"",this.minutes.toString(),":",this.seconds<10?"0":"",this.seconds.toString(),this.dropFrame?";":":",t<10?"0":"",t.toString(),r)},s.prototype.valueOf=function(){return this.frameCount},s.prototype.add=function(e,t,r){if("number"!=typeof e)return e instanceof s||(e=new s(e,this.frameRate,this.dropFrame)),this.add(e.frameCount,t,r);var o=this.frameCount+Math.round(e)*(t?-1:1);if(o<0&&r>0&&(o=Math.round(86400*this.frameRate)+o)/this.frameRate/3600>r)throw new Error("Rollover arithmetic exceeds max permitted");if(o<0)throw new Error("Negative timecodes not supported");return this.frameCount=o,this.frameCount=this.frameCount%Math.round(86400*this.frameRate),this._frameCountToTimeCode(),this},s.prototype.subtract=function(e,t){return this.add(e,!0,t)},s.prototype.toDate=function(){var e=this.frameCount/this.frameRate*1e3,t=new Date;t.setHours(0),t.setMinutes(0),t.setSeconds(0),t.setMilliseconds(0);var r=new Date(t.valueOf()+e),o=60*t.getTimezoneOffset()*1e3,s=60*r.getTimezoneOffset()*1e3;return new Date(t.valueOf()+e+(s-o))},"string"!=typeof r.nodeName?t.exports=s:o&&(o.Timecode=s)}));function r(e,r,o){o=o||0;const s=new Date;s.setHours(0),s.setMinutes(0),s.setSeconds(0),e=Math.max(parseFloat(e.toFixed(3))+.001+1*o/r,0),s.setMilliseconds(1e3*e);return new t(s,r).toString()}const o=30,s=0;class i{constructor(e,t){this.player=t,this.frame_rate=o,this.frame_offset=s}init(e,t,r){0!=r.reaper&&(r.on("loadstart",(function(){r.hls&&r.setOpts({fas:{frame_offset:-1}})})),r.on("config",e=>{var t,r,o,s;this.frame_rate=(null===(r=null===(t=e.data)||void 0===t?void 0:t.fas)||void 0===r?void 0:r.frame_rate)||this.frame_rate,this.frame_offset=(null===(s=null===(o=e.data)||void 0===o?void 0:o.fas)||void 0===s?void 0:s.frame_offset)||this.frame_offset}))}current_frame(){return e=r(this.player.currentTime,this.frame_rate,this.frame_offset),o=this.frame_rate,new t(e,o).frameCount;var e,o}seek_to(e){this.player.currentTime=function(e,r,o){o=o||0;const s=1*(new t(e,r).frameCount+o)/r;return Number((s+.001).toFixed(5))}(e,this.frame_rate,-this.frame_offset)}current_timecode(){return r(this.player.currentTime,this.frame_rate,this.frame_offset)}jump(e){this.seek_to(this.current_frame()+e)}}return function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const r=e.flowplayer;"function"==typeof r?r(t):(Array.isArray(r.extensions)||(r.extensions=[]),~r.extensions.indexOf(t)||r.extensions.push(t))}(window,i),i}));
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.fas=t())}(this,(function(){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var t=function(e){var t={exports:{}};return e(t,t.exports),t.exports}((function(t,r){var o,s;o=e,(s=function(e,t,r){if(!(this instanceof s))return new s(e,t,r);if(void 0===t)this.frameRate=29.97;else{if(!("number"==typeof t&&t>0))throw new Error("Number expected as framerate");this.frameRate=t}if(23.976!==this.frameRate&&24!==this.frameRate&&25!==this.frameRate&&29.97!==this.frameRate&&30!==this.frameRate&&50!==this.frameRate&&59.94!==this.frameRate&&60!==this.frameRate)throw new Error("Unsupported framerate");if(this.dropFrame="boolean"==typeof r?r:29.97===this.frameRate||59.94===this.frameRate,"number"==typeof e)this.frameCount=Math.round(e),this._frameCountToTimeCode();else if("string"==typeof e){var o=e.match("^([012]\\d):(\\d\\d):(\\d\\d)(:|;|\\.)(\\d\\d)$");if(!o)throw new Error("Timecode string expected as HH:MM:SS:FF or HH:MM:SS;FF");this.hours=parseInt(o[1]),this.minutes=parseInt(o[2]),this.seconds=parseInt(o[3]),"boolean"!=typeof r&&(this.dropFrame=":"!==o[4]),this.frames=parseInt(o[5]),this._timeCodeToFrameCount()}else if("object"==typeof e&&e instanceof Date){var i=new Date(e.getFullYear(),e.getMonth(),e.getDate(),0,0,0),a=60*i.getTimezoneOffset()*1e3,n=60*e.getTimezoneOffset()*1e3;this.frameCount=Math.round((e-i+(a-n))*this.frameRate/1e3),this._frameCountToTimeCode()}else if("object"==typeof e&&e.hours>=0)this.hours=e.hours,this.minutes=e.minutes,this.seconds=e.seconds,this.frames=e.frames,this._timeCodeToFrameCount();else{if(void 0!==e)throw new Error("Timecode() constructor expects a number, timecode string, or Date()");this.frameCount=0}return this._validate(e),this}).prototype._validate=function(e){if(this.dropFrame&&29.97!==this.frameRate&&59.94!==this.frameRate)throw new Error("Drop frame is only supported for 29.97 and 59.94 fps");if(this.hours>23||this.minutes>59||this.seconds>59||this.frames>=this.frameRate||this.dropFrame&&0===this.seconds&&this.minutes%10&&this.frames<this.frameRate/29.97*2)throw new Error("Invalid timecode"+JSON.stringify(e))},s.prototype._frameCountToTimeCode=function(){var e=this.frameCount;if(this.dropFrame){var t=29.97===this.frameRate?2:4,r=Math.floor(this.frameCount/(17982*t/2)),o=this.frameCount%(17982*t/2);o<t&&(o+=t),e+=9*t*r+t*Math.floor((o-t)/(1798*t/2))}var s=Math.round(this.frameRate);this.frames=e%s,this.seconds=Math.floor(e/s)%60,this.minutes=Math.floor(e/(60*s))%60,this.hours=Math.floor(e/(3600*s))%24},s.prototype._timeCodeToFrameCount=function(){if(this.frameCount=(3600*this.hours+60*this.minutes+this.seconds)*Math.round(this.frameRate)+this.frames,this.dropFrame){var e=60*this.hours+this.minutes,t=29.97===this.frameRate?2:4;this.frameCount-=t*(e-Math.floor(e/10))}},s.prototype.toString=function(e){var t=this.frames,r="";if("string"==typeof e){if("field"!==e)throw new Error("Unsupported string format");this.frameRate<=30?r=".0":(t=Math.floor(t/2),r=".".concat((this.frameCount%2).toString()))}return"".concat(this.hours<10?"0":"",this.hours.toString(),":",this.minutes<10?"0":"",this.minutes.toString(),":",this.seconds<10?"0":"",this.seconds.toString(),this.dropFrame?";":":",t<10?"0":"",t.toString(),r)},s.prototype.valueOf=function(){return this.frameCount},s.prototype.add=function(e,t,r){if("number"!=typeof e)return e instanceof s||(e=new s(e,this.frameRate,this.dropFrame)),this.add(e.frameCount,t,r);var o=this.frameCount+Math.round(e)*(t?-1:1);if(o<0&&r>0&&(o=Math.round(86400*this.frameRate)+o)/this.frameRate/3600>r)throw new Error("Rollover arithmetic exceeds max permitted");if(o<0)throw new Error("Negative timecodes not supported");return this.frameCount=o,this.frameCount=this.frameCount%Math.round(86400*this.frameRate),this._frameCountToTimeCode(),this},s.prototype.subtract=function(e,t){return this.add(e,!0,t)},s.prototype.toDate=function(){var e=this.frameCount/this.frameRate*1e3,t=new Date;t.setHours(0),t.setMinutes(0),t.setSeconds(0),t.setMilliseconds(0);var r=new Date(t.valueOf()+e),o=60*t.getTimezoneOffset()*1e3,s=60*r.getTimezoneOffset()*1e3;return new Date(t.valueOf()+e+(s-o))},"string"!=typeof r.nodeName?t.exports=s:o&&(o.Timecode=s)}));function r(e,r,o){o=o||0;const s=new Date;s.setHours(0),s.setMinutes(0),s.setSeconds(0),e=Math.max(parseFloat(e.toFixed(3))+.001+1*o/r,0),s.setMilliseconds(1e3*e);return new t(s,r).toString()}const o=30,s=0;class FAS{constructor(e,t){this.player=t,this.frame_rate=o,this.frame_offset=s}init(e,t,r){0!=r.reaper&&(r.on("loadstart",(function(){r.hls&&r.setOpts({fas:{frame_offset:-1}})})),r.on("config",e=>{var t,r,o,s;this.frame_rate=(null===(r=null===(t=e.data)||void 0===t?void 0:t.fas)||void 0===r?void 0:r.frame_rate)||this.frame_rate,this.frame_offset=(null===(s=null===(o=e.data)||void 0===o?void 0:o.fas)||void 0===s?void 0:s.frame_offset)||this.frame_offset}))}current_frame(){return e=r(this.player.currentTime,this.frame_rate,this.frame_offset),o=this.frame_rate,new t(e,o).frameCount;var e,o}seek_to(e){this.player.currentTime=function(e,r,o){o=o||0;const s=1*(new t(e,r).frameCount+o)/r;return Number((s+.001).toFixed(5))}(e,this.frame_rate,-this.frame_offset)}current_timecode(){return r(this.player.currentTime,this.frame_rate,this.frame_offset)}jump(e){this.seek_to(this.current_frame()+e)}}return function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const r=e.flowplayer;"function"==typeof r?r(t):(Array.isArray(r.extensions)||(r.extensions=[]),~r.extensions.indexOf(t)||r.extensions.push(t))}(window,FAS),FAS}));
@@ -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.float_on_scroll=t())}(this,(function(){"use strict";function e(e,t,n){const o=function(e){return Array.isArray(e)?e.slice(0):e.split(".")}(t);for(;o.length;){if(null==e)return n;const t=o.shift();if("string"!=typeof t)return n;e=e[t]}return null==e?n:e}const t="float:pop:in",n="float:pop:out";var o=Object.freeze({__proto__:null,POP_IN:t,POP_OUT:n});var i=Object.freeze({__proto__:null,NO_STANDARD_CONTROLS:1<<20});const r={translation_key:"core.mute",name:"fp-mute"},a={translation_key:"core.mute",name:"fp-unmute"},l={translation_key:"core.close",name:"fp-close"};function s(e){const t=document.createElement("div");return t.setAttribute("class",e.name),e.title&&t.setAttribute("title",e.title),e.title&&t.setAttribute("aria-label",e.title),t.setAttribute("tabindex","0"),t.setAttribute("focusable","true"),t}const c={},u="flowplayer-floating-container",d="flowplayer-floating-placeholder",p="fp-on",f="no-standard-controls";function _(e,t){return function(e){const t=e.getBoundingClientRect(),n=window.innerHeight,o=t.y;return o>n||o+t.height<0?0:t.y<0?(t.height+o)/t.height:n-t.y>t.height?1:Math.abs((n-t.y)/t.height)}(t.is_wrapped?e:g())>.8}function m(){return c.FLOATING_CONTAINER=c.FLOATING_CONTAINER||Object.assign(document.createElement("div"),{id:u})}function g(){return c.PLACEHOLDER=c.PLACEHOLDER||Object.assign(document.createElement("div"),{id:d})}function w(e,t){const n=t.parentNode;n&&n.replaceChild(e,t)}function y(t,o,i){var r;if(0==i.reaper||i.floating)return;if(t.is_wrapped)return v(i,o,n);const a=m(),l=g(),s=document.createElement("p");s.textContent=i.i18n("float_on_scroll.popped_out","video playing in floating mode"),l.innerHTML="",l.append(s);const c=null===(r=o.querySelector(".fp-ratio"))||void 0===r?void 0:r.cloneNode(!1);null==c||c.cloneNode(!1),c&&l.append(c),w(l,o),a.append(o),a.classList.add(p),a.classList.toggle(f,0!=function(t){return 1<<20&e(t,"opts.ui",0)}(i)),t.pop_out_container.appendChild(a),i.emit("resize"),i.emit(n)}function h(e,n,o){var i;if(0==o.reaper||!o.floating)return;if(e.is_wrapped)return void v(o,n,t);const r=m();w(n,g()),r.classList.remove(p),null===(i=r.parentElement)||void 0===i||i.removeChild(r),o.emit("resize"),o.emit(t)}function v(e,n,o){const i=n.clientWidth,r=n.clientHeight;o&&e.emit(o),setTimeout((function(){const a=n.querySelector(".fp-float-wrapper");if(!a)return;const l=getComputedStyle(a),s=o===t?"auto":(a.clientWidth-parseFloat(l.paddingLeft)-parseFloat(l.paddingRight))/i*r+"px";a.style.setProperty("height",s),e.emit("resize")}))}class b{constructor(e){this.flowplayer=e}init(e,o,i){var c,u;if(e.multiplay||0==e.float_on_scroll)return;if(function(){try{return window.self!==window.top}catch(e){return!0}}())return console.warn("iframe detected - floating player not supported in iframe");const d=(null===(c=e.float_on_scroll)||void 0===c?void 0:c.wrap_inside)||!1,p={pop_out_container:(null===(u=e.float_on_scroll)||void 0===u?void 0:u.container)||(d?function(e){const t=document.createElement("div");return t.classList.add("fp-float-wrapper"),e.appendChild(t),Array.from(e.childNodes).forEach((function(e){e instanceof Element&&(e===t||e.classList.contains("fp-ratio"))||t.appendChild(e)})),t}(o):document.body),was_user_toggled:!1,is_wrapped:d};p.is_wrapped&&i.on("renderplugin",(function(e){e.preventDefault(),e.data&&p.pop_out_container.append(e.data)}));const f=o.querySelector(".fp-header");f&&function(e,t,n,o){const i=document.createElement("div");i.classList.add("fp-exit-float"),i.append(Object.assign(s(l),{role:"button"})),i.addEventListener("click",(function(){t.was_user_toggled=!0,o.togglePlay(!1),h(t,n,o)})),e.append(i);const c=document.createElement("div");c.classList.add("fp-mute-float"),c.append(...Object.assign([s(r),s(a)],{role:"button"})),c.addEventListener("click",(function(){o.toggleMute()})),e.append(c)}(f,p,o,i);const m=function(e,t){const n=e||60,o=Math.ceil(1e3/n);let i=Date.now(),r=-1;return function(...e){return r>-1||Date.now()<i||(r=requestAnimationFrame((function(){r=-1,t(),i=Date.now()+o}))),r}}(0,(function(){_(o,p)&&h(p,o,i)})),g=function(){v(i,o)};i.on("viewleave",()=>{(function(e){return!e.paused||!(!e.ads||!e.ads.adPlaying)})(i)&&!p.was_user_toggled&&y(p,o,i)}),i.on("viewenter",(function(){p.was_user_toggled=!1})),i.on(n,(function(){window.addEventListener("scroll",m),i.floating=!0,i.setState("is-popped-out",!0),p.is_wrapped&&window.addEventListener("resize",g)})),i.on(t,(function(){window.removeEventListener("scroll",m),i.floating=!1,i.setState("is-popped-out",!1),p.is_wrapped&&window.removeEventListener("resize",g)}))}}return b.events=o,b.flags=i,function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)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,b)}));
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.float_on_scroll=t())}(this,(function(){"use strict";const e="float:pop:in";var t=Object.freeze({__proto__:null,POP_IN:e,POP_OUT:"float:pop:out"});const n=(e,t)=>new(((e,t)=>{const n=e.get(t);if(!n)throw new Error(`no flowplayer component with the name ${t} exists`);const o=window.customElements.get(t);if(!o)throw new Error(`no default flowplayer component with the name ${t} exists`);const l=window.customElements.get(n);return"function"!=typeof l?o:l})(e._customElements,t))(e),o=(e,t,n)=>{window.customElements.get(t)||window.customElements.define(t,n),e.customElements.get(t)||e.customElements.set(t,t)};function l(e){return function(e){const t=e.getBoundingClientRect(),n=window.innerHeight,o=t.y;return o>n||o+t.height<0?0:t.y<0?(t.height+o)/t.height:n-t.y>t.height?1:Math.abs((n-t.y)/t.height)}(e)>.8}function r(t,n,o){0!=o.reaper&&o.floating&&i(o,n,e)}function i(t,n,o){const l=n.clientWidth,r=n.clientHeight;o&&t.emit(o),setTimeout((function(){const i=n.querySelector(".fp-float-wrapper");if(!i)return;const s=getComputedStyle(i),a=o===e?"auto":(i.clientWidth-parseFloat(s.paddingLeft)-parseFloat(s.paddingRight))/l*r+"px";i.style.setProperty("height",a),t.emit("resize")}))}class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}class FlowplayerIcon extends FlowplayerComponent{constructor(e,t){super(e),this.classList.add("fp-icon",t.name),t.title&&this.setAttribute("title",t.title),t.title&&this.setAttribute("aria-label",t.title),this.setAttribute("tabindex","0"),this.setAttribute("focusable","true")}}const s={translation_key:"core.mute",name:"fp-mute"},a={translation_key:"core.mute",name:"fp-unmute"},c={translation_key:"core.close",name:"fp-close"};class FloatOnScroll{constructor(e){this.flowplayer=e,o(this.flowplayer,"flowplayer-mute-icon",class extends FlowplayerIcon{constructor(e){super(e,s)}}),o(this.flowplayer,"flowplayer-unmute-icon",class extends FlowplayerIcon{constructor(e){super(e,a)}}),o(this.flowplayer,"flowplayer-close-icon",class extends FlowplayerIcon{constructor(e){super(e,c)}})}init(t,o,s){var a;if(t.multiplay||!1===t.float_on_scroll)return;if(function(){try{return window.self!==window.top}catch(e){return!0}}())return console.warn("iframe detected - floating player not supported in iframe");t.float_on_scroll="object"!=typeof t.float_on_scroll?{}:t.float_on_scroll;const c={pop_out_container:(null===(a=t.float_on_scroll)||void 0===a?void 0:a.container)||function(e,t){const n=document.createElement("div");return n.classList.add("fp-float-wrapper"),e.appendChild(n),Array.from(e.childNodes).forEach((function(e){e instanceof Element&&(e===n||e.classList.contains("fp-ratio"))||n.appendChild(e)})),t.getFullsceenTarget=()=>n,n}(o,s),was_user_toggled:!1};s.on("renderplugin",(function(e){e.preventDefault(),e.detail&&c.pop_out_container.append(e.detail)}));const u=function(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}(s,"flowplayer-header");u&&function(e,t,o,l){const i=document.createElement("div");i.classList.add("fp-exit-float"),i.append(Object.assign(n(l,"flowplayer-close-icon"),{role:"button"}));const s=()=>{t.was_user_toggled=!0,l.togglePlay(!1),r(0,o,l)};i.addEventListener("click",s),e.append(i),setTimeout(()=>{const e=o.querySelector(".fp-ad-controls");if(!e)return;const t=i.cloneNode(!0);e.append(t),t.addEventListener("click",s)},0);const a=document.createElement("div");a.classList.add("fp-mute-float"),a.append(...Object.assign([n(l,"flowplayer-mute-icon"),n(l,"flowplayer-unmute-icon")],{role:"button"})),a.addEventListener("click",(function(){l.toggleMute()})),e.append(a)}(u,c,o,s);const f=function(e,t){const n=e||60,o=Math.ceil(1e3/n);let l=Date.now(),r=-1;return function(...e){return r>-1||Date.now()<l||(r=requestAnimationFrame((function(){r=-1,t(),l=Date.now()+o}))),r}}(0,(function(){if(l(o)){if(s.hasState("is-fullscreen"))return;r(0,o,s)}})),p=function(){i(s,o)};s.on("viewleave",()=>{(function(e){return!e.paused||!(!e.ads||!e.ads.adPlaying)})(s)&&!c.was_user_toggled&&function(e,t,n){0==n.reaper||n.floating||i(n,t,"float:pop:out")}(0,o,s)}),s.on("viewenter",(function(){c.was_user_toggled=!1})),s.on("float:pop:out",(function(){window.addEventListener("scroll",f),s.floating=!0,s.setState("is-popped-out",!0),window.addEventListener("resize",p)})),s.on(e,(function(){window.removeEventListener("scroll",f),s.floating=!1,s.setState("is-popped-out",!1),window.removeEventListener("resize",p)}))}}return FloatOnScroll.events=t,function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)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,FloatOnScroll)}));
package/plugins/gemius.js CHANGED
@@ -1 +1 @@
1
- !function(i,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((i="undefined"!=typeof globalThis?globalThis:i||self).flowplayer=i.flowplayer||{},i.flowplayer.gemius=e())}(this,(function(){"use strict";function i(i,e,t){const r=function(i){return Array.isArray(i)?i.slice(0):i.split(".")}(e);for(;r.length;){if(null==i)return t;const e=r.shift();if("string"!=typeof e)return t;i=i[e]}return null==i?t:i}const e=["playerID","gemiusID"],t=["programID","additionalParameters.programName","additionalParameters.programType","additionalParameters.programDuration"],r=["adName","adDuration","adType","campaignClassification","quality","resolution","volume"];function s(e,t){const r=[];return t.forEach((function(t){void 0===i(e,t)&&r.push(t)})),r.length&&console.warn("Missing Gemius configuration: ",r.join(", ")),0===r.length}function a(i){return i<.5||isNaN(i)?0:Math.round(i)}function n(i,e){return-1===i||e?-1:Math.max(0,Math.min(100,Math.round(100*i)))}return function(i,e){if("object"==typeof exports&&"undefined"!=typeof module)return e;"flowplayer"in i||(i.flowplayer={extensions:[]});const t=i.flowplayer;return"function"==typeof t?(t(e),e):(Array.isArray(t.extensions)||(t.extensions=[]),~t.extensions.indexOf(e)||t.extensions.push(e),e)}(window,class{constructor(i){this.started=!1,this.starting=!1,this.paused=!1,this.seeking=!1,this.buffering=!1,this.currentTime=0,this.flowplayer=i}init(i,e,t){if("function"!=typeof GemiusPlayer)return console.warn("Gemius SDK needs to be loaded prior loading gemius plugin");if(!i.gemius)return console.warn("Gemius plugin loaded but not configured");if(this.gemius=i.gemius,t.on("reap",()=>{this.gemiusPlayer&&this.gemius&&this.gemius.programID&&this.gemiusPlayer.programEvent(this.gemius.programID,a(t.currentTime),"stop"),this.gemiusPlayer=void 0,this.resetParams(),window.removeEventListener("beforeunload",this.handle_window_unload.bind(this,t))}),window.addEventListener("beforeunload",this.handle_window_unload.bind(this,t)),t.on(["config","loadedmetadata","src","loadstart"],e=>{var r,s;(null===(r=e.data)||void 0===r?void 0:r.gemius)&&(this.gemius=Object.assign(Object.assign({},this.gemius),null===(s=e.data)||void 0===s?void 0:s.gemius)),e.type===this.getInitEventType(i)&&this.initGemius(i,t)}),t.on("volumechange",()=>{var i;this.gemiusPlayer&&(null===(i=this.gemius)||void 0===i?void 0:i.programID)&&this.gemiusPlayer.programEvent(this.gemius.programID,a(t.currentTime),"chngVol",{volume:n(t.volume,t.muted)})}),t.on("resize",()=>{var i;this.gemiusPlayer&&(null===(i=this.gemius)||void 0===i?void 0:i.programID)&&(this.sendPlayWithRequiremets(t),this.gemiusPlayer.programEvent(this.gemius.programID,a(t.currentTime),"chngRes",{resolution:t.clientWidth+"x"+t.clientHeight}))}),t.on("play",()=>{this.buffering=!1,this.starting=!0,this.started?this.sendPlay(t):this.sendPlayWithRequiremets(t),this.paused=!1}),t.on("ended",()=>{var i;this.started&&(this.resetParams(),this.gemiusPlayer&&(null===(i=this.gemius)||void 0===i?void 0:i.programID)&&this.gemiusPlayer.programEvent(this.gemius.programID,a(t.currentTime),"complete"))}),t.on("seeking",()=>{var i;this.started&&!this.seeking&&(this.seeking=!0,this.gemiusPlayer&&(null===(i=this.gemius)||void 0===i?void 0:i.programID)&&this.gemiusPlayer.programEvent(this.gemius.programID,this.currentTime,"seek"))}),t.on("seeked",()=>{var i;this.started&&!this.paused&&(this.seeking=!1,this.gemiusPlayer&&(null===(i=this.gemius)||void 0===i?void 0:i.programID)&&this.gemiusPlayer.programEvent(this.gemius.programID,a(t.currentTime),"play",{autoPlay:this.gemius.additionalParameters.autoPlay,volume:n(this.gemius.additionalParameters.volume||0)||0}))}),t.on("pause",()=>{var e;this.started&&t.currentTime>.25&&(i.live||i.duration&&i.duration-t.currentTime>.25)&&(this.paused=!0,this.gemiusPlayer&&(null===(e=this.gemius)||void 0===e?void 0:e.programID)&&this.gemiusPlayer.programEvent(this.gemius.programID,a(t.currentTime),"pause"))}),t.on("waiting",()=>{var i;!this.buffering&&t.currentTime>.5&&(this.buffering=!0,this.gemiusPlayer&&(null===(i=this.gemius)||void 0===i?void 0:i.programID)&&this.gemiusPlayer.programEvent(this.gemius.programID,a(t.currentTime),"buffer"))}),t.on("timeupdate",()=>{this.currentTime=Math.round(t.currentTime)}),t.ads){const i=this.flowplayer.AdEvents;t.ads.on(i.AD_STARTED,i=>{var e,t,s;(this.paused=!1,this.currentAd={id:i.vast_ad_id||"unknown id",duration:(null===(e=i.ad)||void 0===e?void 0:e.duration)||-1,currentTime:0},this.gemiusPlayer&&(null===(t=this.gemius)||void 0===t?void 0:t.programID))&&(this.gemiusPlayer.newAd(i.vast_ad_id,(s=Object.assign({},this.gemius.additionalParameters,function(i){var e,t,r;return{adDuration:null===(e=i.ad)||void 0===e?void 0:e.duration,adType:i.ad_type,resolution:(null===(t=i.ad)||void 0===t?void 0:t.width)+"x"+(null===(r=i.ad)||void 0===r?void 0:r.height),volume:n(i.volume)}}(i)),r.reduce((function(i,e){return s&&s.hasOwnProperty(e)&&(i[e]=s[e]),i}),{}))),this.gemiusPlayer.adEvent(this.gemius.programID,this.currentAd.id,0,"play",{autoPlay:this.gemius.additionalParameters.autoPlay,volume:n(i.volume)}))}),t.ads.on(i.AD_PAUSED,()=>{var i;this.paused=!0,this.currentAd&&this.gemiusPlayer&&(null===(i=this.gemius)||void 0===i?void 0:i.programID)&&this.gemiusPlayer.adEvent(this.gemius.programID,this.currentAd.id,this.currentAd.currentTime,"pause")}),t.ads.on(i.AD_RESUMED,i=>{var e;if(this.currentAd&&this.paused){if(this.paused=!1,!this.gemiusPlayer||!(null===(e=this.gemius)||void 0===e?void 0:e.programID))return;this.gemiusPlayer.adEvent(this.gemius.programID,this.currentAd.id,this.currentAd.currentTime,"play",{autoPlay:this.gemius.additionalParameters.autoPlay,volume:n(i.volume)})}}),t.ads.on(i.AD_COMPLETED,()=>{var i;if(this.currentAd){if(!this.gemiusPlayer||!(null===(i=this.gemius)||void 0===i?void 0:i.programID))return;this.gemiusPlayer.adEvent(this.gemius.programID,this.currentAd.id,this.currentAd.duration,"complete"),this.currentAd=void 0}}),t.ads.on(i.AD_PROGRESS,i=>{this.currentAd&&(this.currentAd.currentTime=Math.round(i.duration-i.remaining)||0)}),t.ads.on(i.AD_VOLUME_CHANGED,i=>{var e;if(this.currentAd){const t=i||-1;if(!this.gemiusPlayer||!(null===(e=this.gemius)||void 0===e?void 0:e.programID))return;this.gemiusPlayer.adEvent(this.gemius.programID,this.currentAd.id,this.currentAd.duration,"chngVol",{volume:n(t)})}})}}resetParams(){this.seeking=!1,this.starting=!1,this.started=!1,this.paused=!1,this.buffering=!1,this.currentAd=void 0,this.currentTime=0}sendPlay(i){var e;this.gemiusPlayer&&(null===(e=this.gemius)||void 0===e?void 0:e.programID)&&(this.started=!0,this.gemiusPlayer.programEvent(this.gemius.programID,a(i.currentTime),"play",{autoPlay:this.gemius.additionalParameters.autoPlay,volume:n(this.gemius.additionalParameters.volume||0)}))}sendPlayWithRequiremets(i){this.starting&&!this.started&&i.videoWidth>0&&this.sendPlay(i)}getInitEventType(i){return!i.ima&&i.autoplay?"src":"loadstart"}initGemius(r,a){if(!s(i(r,"gemius",{}),e))return;if(!this.gemius)return;const u={currentDomain:this.gemius.additionalParameters.currentDomain,volume:n(this.gemius.additionalParameters.volume||0)};if(this.gemiusPlayer&&(this.gemiusPlayer=void 0),this.gemiusPlayer=new GemiusPlayer(this.gemius.playerID,this.gemius.gemiusID,u),this.gemiusPlayer.setVideoObject(a),!s(this.gemius,t))return;const o={programName:this.gemius.additionalParameters.programName,programDuration:this.gemius.additionalParameters.programDuration,programType:this.gemius.additionalParameters.programType,volume:n(this.gemius.additionalParameters.volume||0)};this.gemiusPlayer.newProgram(this.gemius.programID,o),this.sendPlayWithRequiremets(a)}handle_window_unload(i){var e;this.gemiusPlayer&&(null===(e=this.gemius)||void 0===e?void 0:e.programID)&&this.gemiusPlayer.programEvent(this.gemius.programID,a(i.currentTime),"close"),this.resetParams()}})}));
1
+ !function(i,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((i="undefined"!=typeof globalThis?globalThis:i||self).flowplayer=i.flowplayer||{},i.flowplayer.gemius=e())}(this,(function(){"use strict";function i(i,e,t){const r=function(i){return Array.isArray(i)?i.slice(0):i.split(".")}(e);for(;r.length;){if(null==i)return t;const e=r.shift();if("string"!=typeof e)return t;i=i[e]}return null==i?t:i}const e=["playerID","gemiusID"],t=["programID","additionalParameters.programName","additionalParameters.programType","additionalParameters.programDuration"],r=["adName","adDuration","adType","campaignClassification","quality","resolution","volume"];function s(e,t){const r=[];return t.forEach((function(t){void 0===i(e,t)&&r.push(t)})),r.length&&console.warn("Missing Gemius configuration: ",r.join(", ")),0===r.length}function a(i){return i<.5||isNaN(i)?0:Math.round(i)}function n(i,e){return-1===i||e?-1:Math.max(0,Math.min(100,Math.round(100*i)))}return function(i,e){if("object"==typeof exports&&"undefined"!=typeof module)return e;"flowplayer"in i||(i.flowplayer={extensions:[]});const t=i.flowplayer;return"function"==typeof t?(t(e),e):(Array.isArray(t.extensions)||(t.extensions=[]),~t.extensions.indexOf(e)||t.extensions.push(e),e)}(window,class GemiusPlugin{constructor(i){this.started=!1,this.starting=!1,this.paused=!1,this.seeking=!1,this.buffering=!1,this.currentTime=0,this.flowplayer=i}init(i,e,t){if("function"!=typeof GemiusPlayer)return console.warn("Gemius SDK needs to be loaded prior loading gemius plugin");if(!i.gemius)return console.warn("Gemius plugin loaded but not configured");if(this.gemius=i.gemius,t.on("reap",()=>{this.gemiusPlayer&&this.gemius&&this.gemius.programID&&this.gemiusPlayer.programEvent(this.gemius.programID,a(t.currentTime),"stop"),this.gemiusPlayer=void 0,this.resetParams(),window.removeEventListener("beforeunload",this.handle_window_unload.bind(this,t))}),window.addEventListener("beforeunload",this.handle_window_unload.bind(this,t)),t.on(["config","loadedmetadata","src","loadstart"],e=>{var r,s;(null===(r=e.data)||void 0===r?void 0:r.gemius)&&(this.gemius=Object.assign(Object.assign({},this.gemius),null===(s=e.data)||void 0===s?void 0:s.gemius)),e.type===this.getInitEventType(i)&&this.initGemius(i,t)}),t.on("volumechange",()=>{var i;this.gemiusPlayer&&(null===(i=this.gemius)||void 0===i?void 0:i.programID)&&this.gemiusPlayer.programEvent(this.gemius.programID,a(t.currentTime),"chngVol",{volume:n(t.volume,t.muted)})}),t.on("resize",()=>{var i;this.gemiusPlayer&&(null===(i=this.gemius)||void 0===i?void 0:i.programID)&&(this.sendPlayWithRequiremets(t),this.gemiusPlayer.programEvent(this.gemius.programID,a(t.currentTime),"chngRes",{resolution:t.clientWidth+"x"+t.clientHeight}))}),t.on("play",()=>{this.buffering=!1,this.starting=!0,this.started?this.sendPlay(t):this.sendPlayWithRequiremets(t),this.paused=!1}),t.on("ended",()=>{var i;this.started&&(this.resetParams(),this.gemiusPlayer&&(null===(i=this.gemius)||void 0===i?void 0:i.programID)&&this.gemiusPlayer.programEvent(this.gemius.programID,a(t.currentTime),"complete"))}),t.on("seeking",()=>{var i;this.started&&!this.seeking&&(this.seeking=!0,this.gemiusPlayer&&(null===(i=this.gemius)||void 0===i?void 0:i.programID)&&this.gemiusPlayer.programEvent(this.gemius.programID,this.currentTime,"seek"))}),t.on("seeked",()=>{var i;this.started&&!this.paused&&(this.seeking=!1,this.gemiusPlayer&&(null===(i=this.gemius)||void 0===i?void 0:i.programID)&&this.gemiusPlayer.programEvent(this.gemius.programID,a(t.currentTime),"play",{autoPlay:this.gemius.additionalParameters.autoPlay,volume:n(this.gemius.additionalParameters.volume||0)||0}))}),t.on("pause",()=>{var e;this.started&&t.currentTime>.25&&(i.live||i.duration&&i.duration-t.currentTime>.25)&&(this.paused=!0,this.gemiusPlayer&&(null===(e=this.gemius)||void 0===e?void 0:e.programID)&&this.gemiusPlayer.programEvent(this.gemius.programID,a(t.currentTime),"pause"))}),t.on("waiting",()=>{var i;!this.buffering&&t.currentTime>.5&&(this.buffering=!0,this.gemiusPlayer&&(null===(i=this.gemius)||void 0===i?void 0:i.programID)&&this.gemiusPlayer.programEvent(this.gemius.programID,a(t.currentTime),"buffer"))}),t.on("timeupdate",()=>{this.currentTime=Math.round(t.currentTime)}),t.ads){const i=this.flowplayer.AdEvents;t.ads.on(i.AD_STARTED,i=>{var e,t,s;(this.paused=!1,this.currentAd={id:i.vast_ad_id||"unknown id",duration:(null===(e=i.ad)||void 0===e?void 0:e.duration)||-1,currentTime:0},this.gemiusPlayer&&(null===(t=this.gemius)||void 0===t?void 0:t.programID))&&(this.gemiusPlayer.newAd(i.vast_ad_id,(s=Object.assign({},this.gemius.additionalParameters,function(i){var e,t,r;return{adDuration:null===(e=i.ad)||void 0===e?void 0:e.duration,adType:i.ad_type,resolution:(null===(t=i.ad)||void 0===t?void 0:t.width)+"x"+(null===(r=i.ad)||void 0===r?void 0:r.height),volume:n(i.volume)}}(i)),r.reduce((function(i,e){return s&&s.hasOwnProperty(e)&&(i[e]=s[e]),i}),{}))),this.gemiusPlayer.adEvent(this.gemius.programID,this.currentAd.id,0,"play",{autoPlay:this.gemius.additionalParameters.autoPlay,volume:n(i.volume)}))}),t.ads.on(i.AD_PAUSED,()=>{var i;this.paused=!0,this.currentAd&&this.gemiusPlayer&&(null===(i=this.gemius)||void 0===i?void 0:i.programID)&&this.gemiusPlayer.adEvent(this.gemius.programID,this.currentAd.id,this.currentAd.currentTime,"pause")}),t.ads.on(i.AD_RESUMED,i=>{var e;if(this.currentAd&&this.paused){if(this.paused=!1,!this.gemiusPlayer||!(null===(e=this.gemius)||void 0===e?void 0:e.programID))return;this.gemiusPlayer.adEvent(this.gemius.programID,this.currentAd.id,this.currentAd.currentTime,"play",{autoPlay:this.gemius.additionalParameters.autoPlay,volume:n(i.volume)})}}),t.ads.on(i.AD_COMPLETED,()=>{var i;if(this.currentAd){if(!this.gemiusPlayer||!(null===(i=this.gemius)||void 0===i?void 0:i.programID))return;this.gemiusPlayer.adEvent(this.gemius.programID,this.currentAd.id,this.currentAd.duration,"complete"),this.currentAd=void 0}}),t.ads.on(i.AD_PROGRESS,i=>{this.currentAd&&(this.currentAd.currentTime=Math.round(i.duration-i.remaining)||0)}),t.ads.on(i.AD_VOLUME_CHANGED,i=>{var e;if(this.currentAd){const t=i||-1;if(!this.gemiusPlayer||!(null===(e=this.gemius)||void 0===e?void 0:e.programID))return;this.gemiusPlayer.adEvent(this.gemius.programID,this.currentAd.id,this.currentAd.duration,"chngVol",{volume:n(t)})}})}}resetParams(){this.seeking=!1,this.starting=!1,this.started=!1,this.paused=!1,this.buffering=!1,this.currentAd=void 0,this.currentTime=0}sendPlay(i){var e;this.gemiusPlayer&&(null===(e=this.gemius)||void 0===e?void 0:e.programID)&&(this.started=!0,this.gemiusPlayer.programEvent(this.gemius.programID,a(i.currentTime),"play",{autoPlay:this.gemius.additionalParameters.autoPlay,volume:n(this.gemius.additionalParameters.volume||0)}))}sendPlayWithRequiremets(i){this.starting&&!this.started&&i.videoWidth>0&&this.sendPlay(i)}getInitEventType(i){return!i.ima&&i.autoplay?"src":"loadstart"}initGemius(r,a){if(!s(i(r,"gemius",{}),e))return;if(!this.gemius)return;const u={currentDomain:this.gemius.additionalParameters.currentDomain,volume:n(this.gemius.additionalParameters.volume||0)};if(this.gemiusPlayer&&(this.gemiusPlayer=void 0),this.gemiusPlayer=new GemiusPlayer(this.gemius.playerID,this.gemius.gemiusID,u),this.gemiusPlayer.setVideoObject(a),!s(this.gemius,t))return;const o={programName:this.gemius.additionalParameters.programName,programDuration:this.gemius.additionalParameters.programDuration,programType:this.gemius.additionalParameters.programType,volume:n(this.gemius.additionalParameters.volume||0)};this.gemiusPlayer.newProgram(this.gemius.programID,o),this.sendPlayWithRequiremets(a)}handle_window_unload(i){var e;this.gemiusPlayer&&(null===(e=this.gemius)||void 0===e?void 0:e.programID)&&this.gemiusPlayer.programEvent(this.gemius.programID,a(i.currentTime),"close"),this.resetParams()}})}));
@@ -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.google_analytics=t())}(this,(function(){"use strict";return function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const i=e.flowplayer;return"function"==typeof i?(i(t),t):(Array.isArray(i.extensions)||(i.extensions=[]),~i.extensions.indexOf(t)||i.extensions.push(t),t)}(window,class{constructor(e){this.started=!1,this.paused=!1,this.muted=!1,this.once=!0,this.liveflag=!1,this.ga_instances=[],this.ga_extensions=[],this.quartiles=[0,0,0],this.ad_type="preroll",this.preroll_counter=0,this.midroll_counter=0,this.postroll_counter=0,this.event_categories={live:"Live",videos:"Videos"},this.event_actions={fullscreen_enter:"fullscreen_enter",fullscreen_exit:"fullscreen_exit",video_player_load:"video_player_load",video_start:"video_start",video_click_play:"video_click_play",video_pause:"video_pause",video_resume:"video_resume",video_mute:"video_mute",video_unmute:"video_unmute",video_25_percent:"video_25_percent",video_50_percent:"video_50_percent",video_75_percent:"video_75_percent",video_complete:"video_complete",live_start:"live_start",live_click_play:"live_click_play",live_pause:"live_pause",live_resume:"live_resume",live_mute:"live_mute",live_unmute:"live_unmute",live_complete:"live_complete",ad_start_preroll:"ad_start_preroll",ad_start_midroll:"ad_start_midroll",ad_start_postroll:"ad_start_postroll",ad_completed_preroll:"ad_completed_preroll",ad_completed_midroll:"ad_completed_midroll",ad_completed_postroll:"ad_completed_postroll",ad_skipped_preroll:"ad_skipped_preroll",ad_skipped_midroll:"ad_skipped_midroll",ad_skipped_postroll:"ad_skipped_postroll",ad_break_completed:"ad_break_completed"},this.flowplayer=e}init(e,t,i){if(this.config=e,this.video=i,"object"!=typeof e.ga)return;const s=this.flowplayer.AdEvents||{AD_STARTED:"ad-started",AD_COMPLETED:"ad-completed",AD_SKIPPED:"ad-skipped",AD_BREAK_COMPLETED:"ad-break-completed"};this.muted=i.muted||!1,this.media_title=e.ga.media_title||"unknown video title",this.ga_instances=e.ga.ga_instances,e.ga.event_actions&&(this.event_actions=e.ga.event_actions),e.ga.event_categories&&(this.event_categories=e.ga.event_categories),i.on(["mount","timeupdate","loadstart","ended","seeked","seeking","pause","playing","volumechange",s.AD_STARTED,s.AD_COMPLETED,s.AD_SKIPPED,s.AD_BREAK_COMPLETED,"config","click","touchend","fullscreenenter","fullscreenexit"],e=>{switch(e.type){case"playing":this.playing(e.type);break;case"pause":this.pause();break;case"mount":this.loaded();break;case"timeupdate":this.progress();break;case"ended":this.ended();break;case"volumechange":this.volumechange();break;case"ad-started":this.adstarted(e);break;case"ad-completed":this.adcompleted(e);break;case"ad-break-completed":this.adbreakcompleted(e.type);break;case"config":this.configured(e);break;case"click":this.click();break;case"fullscreenenter":this.fullscreenenter();break;case"fullscreenexit":this.fullscreenexit();break;case"ad-skipped":this.adskipped()}})}setup_ga(){window.ga&&0===this.ga_extensions.length&&this.ga_instances.forEach((e,t)=>{var i;window.ga("create",e,"auto","ext"+(t+1)),(null===(i=this.config)||void 0===i?void 0:i.ga.custom_data)&&window.ga("ext"+(t+1)+".set",this.config.ga.custom_data),this.ga_extensions.push("ext"+(t+1))})}set_started(e){var t;(null===(t=this.config)||void 0===t?void 0:t.ga.start_on)===e&&(this.liveflag?this.track(this.event_actions.live_start):this.track(this.event_actions.video_start),this.started=!0)}click(){!this.paused&&this.started||(this.liveflag?this.track(this.event_actions.live_click_play):this.track(this.event_actions.video_click_play))}playing(e){this.started?this.paused&&(this.paused=!1,this.liveflag?this.track(this.event_actions.live_resume):this.track(this.event_actions.video_resume)):this.set_started(e)}pause(){this.video&&(Math.abs(this.video.duration-this.video.currentTime)<1||!this.started||(this.paused=!0,this.liveflag?this.track(this.event_actions.live_pause):this.track(this.event_actions.video_pause)))}loaded(){}progress(){!this.liveflag&&this.video&&(this.video.currentTime/this.video.duration>.25&&0===this.quartiles[0]?(this.quartiles[0]=1,this.track(this.event_actions.video_25_percent)):this.video.currentTime/this.video.duration>.5&&0===this.quartiles[1]?(this.quartiles[1]=1,this.track(this.event_actions.video_50_percent)):this.video.currentTime/this.video.duration>.75&&0===this.quartiles[2]&&(this.quartiles[2]=1,this.track(this.event_actions.video_75_percent)))}volumechange(){this.video&&(this.video.muted&&!this.muted?(this.muted=!0,this.liveflag?this.track(this.event_actions.live_mute):this.track(this.event_actions.video_mute)):!this.video.muted&&this.muted&&(this.muted=!1,this.liveflag?this.track(this.event_actions.live_unmute):this.track(this.event_actions.video_unmute)))}ended(){this.started&&(this.liveflag?this.track(this.event_actions.live_complete):this.track(this.event_actions.video_complete)),this.reset()}reset(){this.started=!1,this.quartiles=[0,0,0],this.once=!0,this.config&&(this.config.ga.start_on="playing"),this.preroll_counter=0,this.midroll_counter=0,this.postroll_counter=0}configured(e){this.config&&this.video&&(e.data&&(e.data.live&&(this.liveflag=!0),e.data.title?this.media_title=e.data.title:e.data.metadata&&e.data.metadata.title&&(this.media_title=e.data.metadata.title)),this.config.ga.start_on||(this.config.ga.start_on="playing"),this.video.ads||(this.config.ga.start_on="playing"),this.once&&(this.once=!1,this.track(this.event_actions.video_player_load)))}fullscreenenter(){this.track(this.event_actions.fullscreen_enter)}fullscreenexit(){this.track(this.event_actions.fullscreen_exit)}checkForAdCounter(e,t){return e.replace("[x]",t+"")}adstarted(e){var t;switch((null===(t=e.data)||void 0===t?void 0:t.ad_type)||"preroll"){case"midroll":this.ad_type="midroll",this.midroll_counter++,this.track(this.checkForAdCounter(this.event_actions.ad_start_midroll,this.midroll_counter));break;case"postroll":this.ad_type="postroll",this.postroll_counter++,this.track(this.checkForAdCounter(this.event_actions.ad_start_postroll,this.postroll_counter));break;default:this.ad_type="preroll",this.preroll_counter++,this.track(this.checkForAdCounter(this.event_actions.ad_start_preroll,this.preroll_counter))}}adcompleted(e){var t;switch((null===(t=e.data)||void 0===t?void 0:t.ad_type)||"preroll"){case"midroll":this.track(this.event_actions.ad_completed_midroll);break;case"postroll":this.track(this.event_actions.ad_completed_postroll);break;default:this.track(this.event_actions.ad_completed_preroll)}}adskipped(){if(this.ad_type)switch(this.ad_type){case"midroll":this.track(this.event_actions.ad_skipped_midroll);break;case"postroll":this.track(this.event_actions.ad_skipped_postroll);break;default:this.track(this.event_actions.ad_skipped_preroll)}else this.track(this.event_actions.ad_skipped_preroll)}adbreakcompleted(e){this.set_started(e),this.track(this.event_actions.ad_break_completed)}track(e){let t=this.event_categories.videos;this.liveflag&&(t=this.event_categories.live),e&&t&&(this.setup_ga(),this.ga_extensions.length&&void 0!==window.ga&&null!==window.ga?this.ga_instances.forEach(i=>{window.ga(i+".send","event",t,e,this.media_title)}):console.debug("ga console.send","event",t,e,this.media_title))}})}));
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.google_analytics=t())}(this,(function(){"use strict";return function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const i=e.flowplayer;return"function"==typeof i?(i(t),t):(Array.isArray(i.extensions)||(i.extensions=[]),~i.extensions.indexOf(t)||i.extensions.push(t),t)}(window,class GoogleAnalyticsPlugin{constructor(e){this.started=!1,this.paused=!1,this.muted=!1,this.once=!0,this.liveflag=!1,this.ga_instances=[],this.ga_extensions=[],this.quartiles=[0,0,0],this.ad_type="preroll",this.preroll_counter=0,this.midroll_counter=0,this.postroll_counter=0,this.event_categories={live:"Live",videos:"Videos"},this.event_actions={fullscreen_enter:"fullscreen_enter",fullscreen_exit:"fullscreen_exit",video_player_load:"video_player_load",video_start:"video_start",video_click_play:"video_click_play",video_pause:"video_pause",video_resume:"video_resume",video_mute:"video_mute",video_unmute:"video_unmute",video_25_percent:"video_25_percent",video_50_percent:"video_50_percent",video_75_percent:"video_75_percent",video_complete:"video_complete",live_start:"live_start",live_click_play:"live_click_play",live_pause:"live_pause",live_resume:"live_resume",live_mute:"live_mute",live_unmute:"live_unmute",live_complete:"live_complete",ad_start_preroll:"ad_start_preroll",ad_start_midroll:"ad_start_midroll",ad_start_postroll:"ad_start_postroll",ad_completed_preroll:"ad_completed_preroll",ad_completed_midroll:"ad_completed_midroll",ad_completed_postroll:"ad_completed_postroll",ad_skipped_preroll:"ad_skipped_preroll",ad_skipped_midroll:"ad_skipped_midroll",ad_skipped_postroll:"ad_skipped_postroll",ad_break_completed:"ad_break_completed"},this.flowplayer=e}init(e,t,i){if(this.config=e,this.video=i,"object"!=typeof e.ga)return;const s=this.flowplayer.AdEvents||{AD_STARTED:"ad-started",AD_COMPLETED:"ad-completed",AD_SKIPPED:"ad-skipped",AD_BREAK_COMPLETED:"ad-break-completed"};this.muted=i.muted||!1,this.media_title=e.ga.media_title||"unknown video title",this.ga_instances=e.ga.ga_instances,e.ga.event_actions&&(this.event_actions=e.ga.event_actions),e.ga.event_categories&&(this.event_categories=e.ga.event_categories),i.on(["mount","timeupdate","loadstart","ended","seeked","seeking","pause","playing","volumechange",s.AD_STARTED,s.AD_COMPLETED,s.AD_SKIPPED,s.AD_BREAK_COMPLETED,"config","click","touchend","fullscreenenter","fullscreenexit"],e=>{switch(e.type){case"playing":this.playing(e.type);break;case"pause":this.pause();break;case"mount":this.loaded();break;case"timeupdate":this.progress();break;case"ended":this.ended();break;case"volumechange":this.volumechange();break;case"ad-started":this.adstarted(e);break;case"ad-completed":this.adcompleted(e);break;case"ad-break-completed":this.adbreakcompleted(e.type);break;case"config":this.configured(e);break;case"click":this.click();break;case"fullscreenenter":this.fullscreenenter();break;case"fullscreenexit":this.fullscreenexit();break;case"ad-skipped":this.adskipped()}})}setup_ga(){window.ga&&0===this.ga_extensions.length&&this.ga_instances.forEach((e,t)=>{var i;window.ga("create",e,"auto","ext"+(t+1)),(null===(i=this.config)||void 0===i?void 0:i.ga.custom_data)&&window.ga("ext"+(t+1)+".set",this.config.ga.custom_data),this.ga_extensions.push("ext"+(t+1))})}set_started(e){var t;(null===(t=this.config)||void 0===t?void 0:t.ga.start_on)===e&&(this.liveflag?this.track(this.event_actions.live_start):this.track(this.event_actions.video_start),this.started=!0)}click(){!this.paused&&this.started||(this.liveflag?this.track(this.event_actions.live_click_play):this.track(this.event_actions.video_click_play))}playing(e){this.started?this.paused&&(this.paused=!1,this.liveflag?this.track(this.event_actions.live_resume):this.track(this.event_actions.video_resume)):this.set_started(e)}pause(){this.video&&(Math.abs(this.video.duration-this.video.currentTime)<1||!this.started||(this.paused=!0,this.liveflag?this.track(this.event_actions.live_pause):this.track(this.event_actions.video_pause)))}loaded(){}progress(){!this.liveflag&&this.video&&(this.video.currentTime/this.video.duration>.25&&0===this.quartiles[0]?(this.quartiles[0]=1,this.track(this.event_actions.video_25_percent)):this.video.currentTime/this.video.duration>.5&&0===this.quartiles[1]?(this.quartiles[1]=1,this.track(this.event_actions.video_50_percent)):this.video.currentTime/this.video.duration>.75&&0===this.quartiles[2]&&(this.quartiles[2]=1,this.track(this.event_actions.video_75_percent)))}volumechange(){this.video&&(this.video.muted&&!this.muted?(this.muted=!0,this.liveflag?this.track(this.event_actions.live_mute):this.track(this.event_actions.video_mute)):!this.video.muted&&this.muted&&(this.muted=!1,this.liveflag?this.track(this.event_actions.live_unmute):this.track(this.event_actions.video_unmute)))}ended(){this.started&&(this.liveflag?this.track(this.event_actions.live_complete):this.track(this.event_actions.video_complete)),this.reset()}reset(){this.started=!1,this.quartiles=[0,0,0],this.once=!0,this.config&&(this.config.ga.start_on="playing"),this.preroll_counter=0,this.midroll_counter=0,this.postroll_counter=0}configured(e){this.config&&this.video&&(e.data&&(e.data.live&&(this.liveflag=!0),e.data.title?this.media_title=e.data.title:e.data.metadata&&e.data.metadata.title&&(this.media_title=e.data.metadata.title)),this.config.ga.start_on||(this.config.ga.start_on="playing"),this.video.ads||(this.config.ga.start_on="playing"),this.once&&(this.once=!1,this.track(this.event_actions.video_player_load)))}fullscreenenter(){this.track(this.event_actions.fullscreen_enter)}fullscreenexit(){this.track(this.event_actions.fullscreen_exit)}checkForAdCounter(e,t){return e.replace("[x]",t+"")}adstarted(e){var t;switch((null===(t=e.data)||void 0===t?void 0:t.ad_type)||"preroll"){case"midroll":this.ad_type="midroll",this.midroll_counter++,this.track(this.checkForAdCounter(this.event_actions.ad_start_midroll,this.midroll_counter));break;case"postroll":this.ad_type="postroll",this.postroll_counter++,this.track(this.checkForAdCounter(this.event_actions.ad_start_postroll,this.postroll_counter));break;default:this.ad_type="preroll",this.preroll_counter++,this.track(this.checkForAdCounter(this.event_actions.ad_start_preroll,this.preroll_counter))}}adcompleted(e){var t;switch((null===(t=e.data)||void 0===t?void 0:t.ad_type)||"preroll"){case"midroll":this.track(this.event_actions.ad_completed_midroll);break;case"postroll":this.track(this.event_actions.ad_completed_postroll);break;default:this.track(this.event_actions.ad_completed_preroll)}}adskipped(){if(this.ad_type)switch(this.ad_type){case"midroll":this.track(this.event_actions.ad_skipped_midroll);break;case"postroll":this.track(this.event_actions.ad_skipped_postroll);break;default:this.track(this.event_actions.ad_skipped_preroll)}else this.track(this.event_actions.ad_skipped_preroll)}adbreakcompleted(e){this.set_started(e),this.track(this.event_actions.ad_break_completed)}track(e){let t=this.event_categories.videos;this.liveflag&&(t=this.event_categories.live),e&&t&&(this.setup_ga(),this.ga_extensions.length&&void 0!==window.ga&&null!==window.ga?this.ga_instances.forEach(i=>{window.ga(i+".send","event",t,e,this.media_title)}):console.debug("ga console.send","event",t,e,this.media_title))}})}));
package/plugins/health.js CHANGED
@@ -1 +1 @@
1
- !function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):((t="undefined"!=typeof globalThis?globalThis:t||self).flowplayer=t.flowplayer||{},t.flowplayer.health=n())}(this,(function(){"use strict";const t=Date.now(),n={session_id:Math.random().toString(36).substring(2)+performance.now().toString(36)};class e{constructor(){this._summary={},this._session_id=n,this.start_time=t}increment(t,n){if("string"!=typeof t||"number"!=typeof n)return;const e=this._summary[t]||0;this._summary[t]=e+n}set(t,n){"string"==typeof t&&(this._summary[t]=n)}duration(){return Date.now()-this.start_time}summary(t){return Object.assign("object"==typeof t?t:{},{event:"health_summary"},this._summary,this._session_id,{duration:this.duration()})}sessionize(t){return Object.assign(t,this._session_id)}}function i(t,n){return function(t,n){return"function"==typeof navigator.sendBeacon&&navigator.sendBeacon(t,n)}(t,JSON.stringify({events:n}))}class o{constructor(t){this.middleware=t,this._pending=[]}pending(){return this._pending}_run_middleware(t,n){return t=Object.assign({},t),this.middleware.forEach((function(e){const i=e(n);if("object"==typeof i)return Object.assign(t,i);console.warn("KPI::middleware did not return an Object\nreturn: %o\n\nfn: %s",i,e)})),t}push(t,n){t=this._run_middleware(t,n),this.push_finalized(t)}push_finalized(t){this._pending.push(t),this.send()}send(t){if(this._pending.length<20&&!t)return;const n=this._pending.slice(0);this._pending.length=0,i("https://health.flowplayer.com/v1/health/events",n)}}function r(t,n,e){const i=function(t){return Array.isArray(t)?t.slice(0):t.split(".")}(n);for(;i.length;){if(null==t)return e;const n=i.shift();if("string"!=typeof n)return e;t=t[n]}return null==t?e:t}function a(){return r(window,"navigator.connection.downlink")}function s(t){const n=t.hls;if(!n)return;const e=n.abrController._bwEstimator;return e?.001*e.getEstimate():void 0}function u(t){const n=[s,a];for(;n.length;){const e=n.shift(),i="function"==typeof e&&e(t);if("number"==typeof i)return{downlink_mbs:Number(i.toFixed(2))}}return{}}const c=document.createElement("a");function d(t){const n=t.original_src;return"string"!=typeof n?{}:(c.href=n,"string"==typeof c.pathname?{media_type:c.pathname.split(".").pop()}:{})}function f(t){return{preload:t.opt("preload"),autoplay:t.opt("autoplay",t.autoplay)}}function l(t){return{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}}function p(){return{timestamp:Date.now()}}function h(){return{ua:navigator.userAgent,version:"3.0.0-beta",commit:"494a2e0586e1a0959f8c5a3399c5464b990bc858"}}!function(){let t=!1;try{const n=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("testPassive",null,n),window.removeEventListener("testPassive",null,n)}catch(t){}}();const m=["touchstart","touchmove"];function y(t,n,e,i){if(o=n,!~m.indexOf(o))return t.addEventListener(n,e,i),t;var o;const r=Object.assign(i||{},{passive:!0});return t.addEventListener(n,e,r),t}const _=["error","rebuffer"],g=_.concat(["load","loadstart","loadedmetadata","loadeddata","error:fatal","playing","seeked","quality:set","pause","ended","seeking"]);function w(t,n,e){t.push_finalized(Object.assign(n.summary({}),f(e),l(e),p(),h())),t.send(!0)}function b(t){try{return!!new URL(t)}catch(t){return!1}}var v;(function(t,n,e,i){Array.isArray(n)?n.forEach(n=>y(t,n,e,i)):y(t,n,e,i)})(window,"flowplayer:umd",(function(t){const n=t.data;n&&window.addEventListener("unload",(function(){n.instances.forEach(t=>t.emit("unload"))}))}),Object.assign(v||{},{once:!0}));class O{init(t,n,i){if(i._health)return;const r=i._health=new e,a=i._kpis=new o([d,f,l,u,p,h]);_.forEach(t=>{r.set(t,0)}),function(t){t.on("waiting",(function(n){t.seeking||t.networkState===t.NETWORK_LOADING&&t.readyState!==t.HAVE_NOTHING&&t.emit("rebuffer")}))}(i),i.on("reap",(function(){a.send(),i._kpis=i._health=void 0})),i.on("health:summary:increment",(function(t){t.data&&Object.keys(t.data).forEach((function(n){t.data&&r.increment(n,t.data[n])}))})),i.on("health:summary:set",(function(t){t.data&&Object.keys(t.data).forEach((function(n){t.data&&r.set(n,t.data[n])}))})),i.on(_,(function(t){setTimeout(()=>{t.defaultPrevented||i.emit("health:summary:increment",{[t.type]:1})})})),i.on(g,(function(t){setTimeout(()=>{t.defaultPrevented||i.emit("health:kpi:track",{event:t.type})},0)})),i.on("health:kpi:track",(function(t){if(!t.data)return;const n=r.sessionize(t.data);a.push(n,i)})),i.on("src",(function(t){const n=t.data&&t.data.src;"string"==typeof n&&b(i.original_src)&&b(n)&&n!=i.original_src&&w(a,r,i)})),i.on("unload",(function(){w(a,r,i)}))}}return function(t,n){if("object"==typeof exports&&"undefined"!=typeof module)return n;"flowplayer"in t||(t.flowplayer={extensions:[]});const e=t.flowplayer;"function"==typeof e?e(n):(Array.isArray(e.extensions)||(e.extensions=[]),~e.extensions.indexOf(n)||e.extensions.push(n))}(window,O),O}));
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.health=t())}(this,(function(){"use strict";const e="rebuffer";var t=Object.freeze({__proto__:null,RECORD:"health:record",REBUFFER:e});const n="load",i="fullscreenenter",o="fullscreenexit",s="loadedmetadata",a="loadeddata",r="progress",d="loadstart",c="pause",l="playing",_="waiting",u="canplay",h="ended",p="seeked",f="seeking";function m(e){try{return!!new URL(e)}catch(e){return!1}}const E=navigator;function v(e){var t,n;const i=null===(t=e.hls)||void 0===t?void 0:t.bandwidthEstimate;return i?1e-6*i:(null===(n=E.connection)||void 0===n?void 0:n.downlink)||-1}function g(e,t){return function(e,t){return"function"==typeof navigator.sendBeacon&&navigator.sendBeacon(e,t)}(e,JSON.stringify({events:t}))}const y=[1e7]+""+-1e3+-4e3+-8e3+-1e11,R=()=>"undefined"==typeof crypto?"":y.replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16)),O=R(),N=[];function D(e){const t=N.slice(0);N.length=0,e.logger.log(`:dispatch events={${t.length}}`),g("https://health.flowplayer.com/v1/health/events",t)}function T(e,t,n){N.push(t),e.logger.log(":enqueue",t.event,t),N.length<10&&!n||D(e)}const A=()=>{var e,t;try{const n=window;return null===(t=null===(e=null==n?void 0:n.google)||void 0===e?void 0:e.ima)||void 0===t?void 0:t.VERSION}catch(e){return}},w=(e,t)=>Object.assign(e,{detail:t}),I=(e,{event:t,media_session_id:n})=>({event:t,media_session_id:n,device_id:e.deviceId(),session_id:O,timestamp:Date.now(),version:"3.0.2",commit:"8cb54448b417ccbf511048e11696c74848197191",ima_sdk_version:A(),preload:e.opt("preload"),autoplay:e.opt("autoplay",e.autoplay),source:e.original_src,downlink_mbs:v(e),player_id:e.opt("metadata.player_id"),media_id:e.opt("metadata.media_id"),site_id:e.opt("metadata.site_id"),category_id:e.opt("metadata.category_id"),sitegroup_id:e.opt("metadata.sitegroup_id"),token:e.token,plugins:e.plugins.map(e=>e.constructor.name).sort((e,t)=>e.localeCompare(t)),current_time:e.currentTime}),b=e=>({bitrate:null==e?void 0:e.bitrate,resolution:null==e?void 0:e.attrs.RESOLUTION,frame_rate:null==e?void 0:e.attrs["FRAME-RATE"]});function S(e,t,n,i){const o=I(t,{event:n,media_session_id:e.media_session_id}),{before:s,after:a}=i;T(e,((e,t,n)=>Object.assign(e,{state:{before:t,after:n}}))(o,b(s),b(a)))}var C;function M(e){switch(e){case C.MEDIA_PLAYBACK_ABORTED:return"media playback was aborted";case C.MEDIA_ERR_NETWORK:return"a network error occurred";case C.MEDIA_ERR_DECODE:return"unable to decode media content";case C.MEDIA_ERR_SRC_NOT_SUPPORTED:return"unsupported media type";case C.NO_INTERNET:return"no internet connection detected";case C.MIXED_CONTENT:return"cannot load insecure content in a secure context";default:return"an unknown error occurred"}}!function(e){e[e.UNKNOWN=-1]="UNKNOWN",e[e.MEDIA_PLAYBACK_ABORTED=1]="MEDIA_PLAYBACK_ABORTED",e[e.MEDIA_ERR_NETWORK=2]="MEDIA_ERR_NETWORK",e[e.MEDIA_ERR_DECODE=3]="MEDIA_ERR_DECODE",e[e.MEDIA_ERR_SRC_NOT_SUPPORTED=4]="MEDIA_ERR_SRC_NOT_SUPPORTED",e[e.MIXED_CONTENT=1001]="MIXED_CONTENT",e[e.NO_INTERNET=1002]="NO_INTERNET"}(C||(C={}));const k=(e,t)=>{let n=null;return(...i)=>{null!==n&&(clearTimeout(n),n=null),n=setTimeout(()=>t(...i),e)}};class Health{constructor(e,t){if(this.logger=function(e,t){return{log:(...n)=>{const i=e.opt("debug");i&&t.match(i)&&console.log(t,...n)}}}(t,"health"),this.media_session_id=R(),!Health._UNLOAD_SUBSCRIBED){Health._UNLOAD_SUBSCRIBED=!0;const t=()=>e.instances.forEach(e=>e.emit("unload"));document.addEventListener("visibilitychange",()=>{"hidden"==document.visibilityState&&t()}),window.addEventListener("pagehide",t)}}init(t,E,v){!function(t){t.on(_,(function(n){t.seeking||t.networkState===t.NETWORK_LOADING&&t.readyState!==t.HAVE_NOTHING&&t.emit(e)}))}(v),v.on("health:record",({detail:e})=>{const t=I(v,{event:e.event,media_session_id:this.media_session_id});Object.assign(t,e.detail||{}),T(this,t)}),[u,d,n,s,a,r,_,e].forEach(e=>{v.on(e,e=>{T(this,I(v,{event:e.type,media_session_id:this.media_session_id}))})}),[l,c,f,p,h,i,o].forEach(e=>{v.on(e,e=>{T(this,I(v,{event:e.type,media_session_id:this.media_session_id}))})}),v.on("volumechange",k(800,e=>{const t=I(v,{event:e.type,media_session_id:this.media_session_id});T(this,w(t,{volume:parseFloat(v.volume.toFixed(2)),muted:v.muted}))})),v.on("resize",k(800,e=>{const t=I(v,{event:e.type,media_session_id:this.media_session_id});T(this,w(t,{height:E.clientHeight,width:E.clientWidth}))})),v.on("qualitychange",({type:e,detail:t})=>{switch(t.kind){case"hls":return S(this,v,e,t)}}),v.addEventListener("error",e=>{const t=I(v,{event:e.type,media_session_id:this.media_session_id}),n=e.error||v.error;if(!n)return T(this,t,!0);const i=n.code,o={error_message:n.message||M(i),error_code:i,error_stack:n.stack||""};return T(this,w(t,o),!0)}),v.on("src",e=>{var t;const n=null===(t=e.detail)||void 0===t?void 0:t.src;if("string"!=typeof n)return;if(!m(v.original_src))return;if(!m(n))return;if(n==v.original_src)return;this.media_session_id=R();T(this,I(v,{event:e.type,media_session_id:this.media_session_id})),D(this)}),v.on("unload",e=>{T(this,I(v,{event:e.type,media_session_id:this.media_session_id})),D(this)})}}return Health.events=t,Health._UNLOAD_SUBSCRIBED=!1,function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;"function"==typeof n?n(t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t))}(window,Health),Health}));
package/plugins/hls.js CHANGED
@@ -38,7 +38,7 @@
38
38
  /*!*********************************************!*\
39
39
  !*** ./src/controller/buffer-controller.ts ***!
40
40
  \*********************************************/
41
- /*! exports provided: default */function(t,e,r){r.r(e),r.d(e,"default",(function(){return f}));var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../events */"./src/events.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),a=r(/*! ../errors */"./src/errors.ts"),o=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),l=r(/*! ../utils/mediasource-helper */"./src/utils/mediasource-helper.ts"),u=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),d=r(/*! ./buffer-operation-queue */"./src/controller/buffer-operation-queue.ts"),c=Object(l.getMediaSource)(),h=/([ha]vc.)(?:\.[^.,]+)+/,f=function(){function t(t){var e=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var t=e.hls,r=e.media,i=e.mediaSource;s.logger.log("[buffer-controller]: Media source opened"),r&&(e.updateMediaElementDuration(),t.trigger(n.Events.MEDIA_ATTACHED,{media:r})),i&&i.removeEventListener("sourceopen",e._onMediaSourceOpen),e.checkPendingTracks()},this._onMediaSourceClose=function(){s.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){s.logger.log("[buffer-controller]: Media source ended")},this.hls=t,this._initSourceBuffer(),this.registerListeners()}var e=t.prototype;return e.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},e.destroy=function(){this.unregisterListeners(),this.details=null},e.registerListeners=function(){var t=this.hls;t.on(n.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(n.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(n.Events.BUFFER_RESET,this.onBufferReset,this),t.on(n.Events.BUFFER_APPENDING,this.onBufferAppending,this),t.on(n.Events.BUFFER_CODECS,this.onBufferCodecs,this),t.on(n.Events.BUFFER_EOS,this.onBufferEos,this),t.on(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(n.Events.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(n.Events.FRAG_PARSED,this.onFragParsed,this),t.on(n.Events.FRAG_CHANGED,this.onFragChanged,this)},e.unregisterListeners=function(){var t=this.hls;t.off(n.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(n.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(n.Events.BUFFER_RESET,this.onBufferReset,this),t.off(n.Events.BUFFER_APPENDING,this.onBufferAppending,this),t.off(n.Events.BUFFER_CODECS,this.onBufferCodecs,this),t.off(n.Events.BUFFER_EOS,this.onBufferEos,this),t.off(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(n.Events.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(n.Events.FRAG_PARSED,this.onFragParsed,this),t.off(n.Events.FRAG_CHANGED,this.onFragChanged,this)},e._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new d.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},e.onManifestParsed=function(t,e){var r=2;(e.audio&&!e.video||!e.altAudio)&&(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,this.details=null,s.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},e.onMediaAttaching=function(t,e){var r=this.media=e.media;if(r&&c){var i=this.mediaSource=new c;i.addEventListener("sourceopen",this._onMediaSourceOpen),i.addEventListener("sourceended",this._onMediaSourceEnded),i.addEventListener("sourceclose",this._onMediaSourceClose),r.src=self.URL.createObjectURL(i),this._objectUrl=r.src}},e.onMediaDetaching=function(){var t=this.media,e=this.mediaSource,r=this._objectUrl;if(e){if(s.logger.log("[buffer-controller]: media source detaching"),"open"===e.readyState)try{e.endOfStream()}catch(t){s.logger.warn("[buffer-controller]: onMediaDetaching: "+t.message+" while calling endOfStream")}this.onBufferReset(),e.removeEventListener("sourceopen",this._onMediaSourceOpen),e.removeEventListener("sourceended",this._onMediaSourceEnded),e.removeEventListener("sourceclose",this._onMediaSourceClose),t&&(r&&self.URL.revokeObjectURL(r),t.src===r?(t.removeAttribute("src"),t.load()):s.logger.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(n.Events.MEDIA_DETACHED,void 0)},e.onBufferReset=function(){var t=this,e=this.sourceBuffer;this.getSourceBufferTypes().forEach((function(r){var i=e[r];try{i&&(t.removeBufferListeners(r),t.mediaSource&&t.mediaSource.removeSourceBuffer(i),e[r]=void 0)}catch(t){s.logger.warn("[buffer-controller]: Failed to reset the "+r+" buffer",t)}})),this._initSourceBuffer()},e.onBufferCodecs=function(t,e){var r=this,i=Object.keys(this.sourceBuffer).length;Object.keys(e).forEach((function(t){if(i){var n=r.tracks[t];if(n&&"function"==typeof n.buffer.changeType){var s=e[t],a=s.codec,o=s.levelCodec,l=s.container;if((n.levelCodec||n.codec).replace(h,"$1")!==(o||a).replace(h,"$1")){var u=l+";codecs="+(o||a);r.appendChangeType(t,u)}}}else r.pendingTracks[t]=e[t]})),i||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks())},e.appendChangeType=function(t,e){var r=this,i=this.operationQueue,n={execute:function(){var n=r.sourceBuffer[t];n&&(s.logger.log("[buffer-controller]: changing "+t+" sourceBuffer type to "+e),n.changeType(e)),i.shiftAndExecuteNext(t)},onStart:function(){},onComplete:function(){},onError:function(e){s.logger.warn("[buffer-controller]: Failed to change "+t+" SourceBuffer type",e)}};i.append(n,t)},e.onBufferAppending=function(t,e){var r=this,i=this.hls,l=this.operationQueue,u=this.tracks,d=e.data,c=e.type,h=e.frag,f=e.part,g=e.chunkMeta,v=g.buffering[c],p=self.performance.now();v.start=p;var m=h.stats.buffering,y=f?f.stats.buffering:null;0===m.start&&(m.start=p),y&&0===y.start&&(y.start=p);var E=u.audio,T="audio"===c&&1===g.id&&"audio/mpeg"===(null==E?void 0:E.container),S={execute:function(){if(v.executeStart=self.performance.now(),T){var t=r.sourceBuffer[c];if(t){var e=h.start-t.timestampOffset;Math.abs(e)>=.1&&(s.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+h.start+" (delta: "+e+") sn: "+h.sn+")"),t.timestampOffset=h.start)}}r.appendExecutor(d,c)},onStart:function(){},onComplete:function(){var t=self.performance.now();v.executeEnd=v.end=t,0===m.first&&(m.first=t),y&&0===y.first&&(y.first=t);var e=r.sourceBuffer,i={};for(var s in e)i[s]=o.BufferHelper.getBuffered(e[s]);r.appendError=0,r.hls.trigger(n.Events.BUFFER_APPENDED,{type:c,frag:h,part:f,chunkMeta:g,parent:h.type,timeRanges:i})},onError:function(t){s.logger.error("[buffer-controller]: Error encountered while trying to append to the "+c+" SourceBuffer",t);var e={type:a.ErrorTypes.MEDIA_ERROR,parent:h.type,details:a.ErrorDetails.BUFFER_APPEND_ERROR,err:t,fatal:!1};t.code===DOMException.QUOTA_EXCEEDED_ERR?e.details=a.ErrorDetails.BUFFER_FULL_ERROR:(r.appendError++,e.details=a.ErrorDetails.BUFFER_APPEND_ERROR,r.appendError>i.config.appendErrorMaxRetry&&(s.logger.error("[buffer-controller]: Failed "+i.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),e.fatal=!0)),i.trigger(n.Events.ERROR,e)}};l.append(S,c)},e.onBufferFlushing=function(t,e){var r=this,i=this.operationQueue,a=function(t){return{execute:r.removeExecutor.bind(r,t,e.startOffset,e.endOffset),onStart:function(){},onComplete:function(){r.hls.trigger(n.Events.BUFFER_FLUSHED,{type:t})},onError:function(e){s.logger.warn("[buffer-controller]: Failed to remove from "+t+" SourceBuffer",e)}}};e.type?i.append(a(e.type),e.type):(i.append(a("audio"),"audio"),i.append(a("video"),"video"))},e.onFragParsed=function(t,e){var r=this,i=e.frag,a=e.part,o=[],l=a?a.elementaryStreams:i.elementaryStreams;l[u.ElementaryStreamTypes.AUDIOVIDEO]?o.push("audiovideo"):(l[u.ElementaryStreamTypes.AUDIO]&&o.push("audio"),l[u.ElementaryStreamTypes.VIDEO]&&o.push("video")),0===o.length&&s.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+i.type+" level: "+i.level+" sn: "+i.sn),this.blockBuffers((function(){var t=self.performance.now();i.stats.buffering.end=t,a&&(a.stats.buffering.end=t);var e=a?a.stats:i.stats;r.hls.trigger(n.Events.FRAG_BUFFERED,{frag:i,part:a,stats:e,id:i.type})}),o)},e.onFragChanged=function(t,e){this.flushBackBuffer()},e.onBufferEos=function(t,e){var r=this;this.getSourceBufferTypes().reduce((function(t,i){var n=r.sourceBuffer[i];return e.type&&e.type!==i||n&&!n.ended&&(n.ended=!0,s.logger.log("[buffer-controller]: "+i+" sourceBuffer now EOS")),t&&!(n&&!n.ended)}),!0)&&this.blockBuffers((function(){var t=r.mediaSource;t&&"open"===t.readyState&&t.endOfStream()}))},e.onLevelUpdated=function(t,e){var r=e.details;r.fragments.length&&(this.details=r,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},e.flushBackBuffer=function(){var t=this.hls,e=this.details,r=this.media,s=this.sourceBuffer;if(r&&null!==e){var a=this.getSourceBufferTypes();if(a.length){var l=e.live&&null!==t.config.liveBackBufferLength?t.config.liveBackBufferLength:t.config.backBufferLength;if(Object(i.isFiniteNumber)(l)&&!(l<0)){var u=r.currentTime,d=e.levelTargetDuration,c=Math.max(l,d),h=Math.floor(u/d)*d-c;a.forEach((function(r){var i=s[r];if(i){var a=o.BufferHelper.getBuffered(i);a.length>0&&h>a.start(0)&&(t.trigger(n.Events.BACK_BUFFER_REACHED,{bufferEnd:h}),e.live&&t.trigger(n.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:h}),t.trigger(n.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:h,type:r}))}}))}}}},e.updateMediaElementDuration=function(){if(this.details&&this.media&&this.mediaSource&&"open"===this.mediaSource.readyState){var t=this.details,e=this.hls,r=this.media,n=this.mediaSource,a=t.fragments[0].start+t.totalduration,o=r.duration,l=Object(i.isFiniteNumber)(n.duration)?n.duration:0;t.live&&e.config.liveDurationInfinity?(s.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),n.duration=1/0,this.updateSeekableRange(t)):(a>l&&a>o||!Object(i.isFiniteNumber)(o))&&(s.logger.log("[buffer-controller]: Updating Media Source duration to "+a.toFixed(3)),n.duration=a)}},e.updateSeekableRange=function(t){var e=this.mediaSource,r=t.fragments;if(r.length&&t.live&&null!=e&&e.setLiveSeekableRange){var i=Math.max(0,r[0].start),n=Math.max(i,i+t.totalduration);e.setLiveSeekableRange(i,n)}},e.checkPendingTracks=function(){var t=this.bufferCodecEventsExpected,e=this.operationQueue,r=this.pendingTracks,i=Object.keys(r).length;if(i&&!t||2===i){this.createSourceBuffers(r),this.pendingTracks={};var s=Object.keys(this.sourceBuffer);if(0===s.length)return void this.hls.trigger(n.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});s.forEach((function(t){e.executeNext(t)}))}},e.createSourceBuffers=function(t){var e=this.sourceBuffer,r=this.mediaSource;if(!r)throw Error("createSourceBuffers called when mediaSource was null");var i=0;for(var o in t)if(!e[o]){var l=t[o];if(!l)throw Error("source buffer exists for track "+o+", however track does not");var u=l.levelCodec||l.codec,d=l.container+";codecs="+u;s.logger.log("[buffer-controller]: creating sourceBuffer("+d+")");try{var c=e[o]=r.addSourceBuffer(d),h=o;this.addBufferListener(h,"updatestart",this._onSBUpdateStart),this.addBufferListener(h,"updateend",this._onSBUpdateEnd),this.addBufferListener(h,"error",this._onSBUpdateError),this.tracks[o]={buffer:c,codec:u,container:l.container,levelCodec:l.levelCodec,id:l.id},i++}catch(t){s.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+t.message),this.hls.trigger(n.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:t,mimeType:d})}}i&&this.hls.trigger(n.Events.BUFFER_CREATED,{tracks:this.tracks})},e._onSBUpdateStart=function(t){this.operationQueue.current(t).onStart()},e._onSBUpdateEnd=function(t){var e=this.operationQueue;e.current(t).onComplete(),e.shiftAndExecuteNext(t)},e._onSBUpdateError=function(t,e){s.logger.error("[buffer-controller]: "+t+" SourceBuffer error",e),this.hls.trigger(n.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var r=this.operationQueue.current(t);r&&r.onError(e)},e.removeExecutor=function(t,e,r){var n=this.media,a=this.mediaSource,o=this.operationQueue,l=this.sourceBuffer[t];if(!n||!a||!l)return s.logger.warn("[buffer-controller]: Attempting to remove from the "+t+" SourceBuffer, but it does not exist"),void o.shiftAndExecuteNext(t);var u=Object(i.isFiniteNumber)(n.duration)?n.duration:1/0,d=Object(i.isFiniteNumber)(a.duration)?a.duration:1/0,c=Math.max(0,e),h=Math.min(r,u,d);h>c?(s.logger.log("[buffer-controller]: Removing ["+c+","+h+"] from the "+t+" SourceBuffer"),console.assert(!l.updating,t+" sourceBuffer must not be updating"),l.remove(c,h)):o.shiftAndExecuteNext(t)},e.appendExecutor=function(t,e){var r=this.operationQueue,i=this.sourceBuffer[e];if(!i)return s.logger.warn("[buffer-controller]: Attempting to append to the "+e+" SourceBuffer, but it does not exist"),void r.shiftAndExecuteNext(e);i.ended=!1,console.assert(!i.updating,e+" sourceBuffer must not be updating"),i.appendBuffer(t)},e.blockBuffers=function(t,e){var r=this;if(void 0===e&&(e=this.getSourceBufferTypes()),e.length){var i=this.operationQueue,n=e.map((function(t){return i.appendBlocker(t)}));Promise.all(n).then((function(){t(),e.forEach((function(t){var e=r.sourceBuffer[t];e&&e.updating||i.shiftAndExecuteNext(t)}))}))}else s.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist")},e.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},e.addBufferListener=function(t,e,r){var i=this.sourceBuffer[t];if(i){var n=r.bind(this,t);this.listeners[t].push({event:e,listener:n}),i.addEventListener(e,n)}},e.removeBufferListeners=function(t){var e=this.sourceBuffer[t];e&&this.listeners[t].forEach((function(t){e.removeEventListener(t.event,t.listener)}))},t}()},"./src/controller/buffer-operation-queue.ts":
41
+ /*! exports provided: default */function(t,e,r){r.r(e),r.d(e,"default",(function(){return f}));var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../events */"./src/events.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),a=r(/*! ../errors */"./src/errors.ts"),o=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),l=r(/*! ../utils/mediasource-helper */"./src/utils/mediasource-helper.ts"),u=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),d=r(/*! ./buffer-operation-queue */"./src/controller/buffer-operation-queue.ts"),c=Object(l.getMediaSource)(),h=/([ha]vc.)(?:\.[^.,]+)+/,f=function(){function t(t){var e=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var t=e.hls,r=e.media,i=e.mediaSource;s.logger.log("[buffer-controller]: Media source opened"),r&&(e.updateMediaElementDuration(),t.trigger(n.Events.MEDIA_ATTACHED,{media:r})),i&&i.removeEventListener("sourceopen",e._onMediaSourceOpen),e.checkPendingTracks()},this._onMediaSourceClose=function(){s.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){s.logger.log("[buffer-controller]: Media source ended")},this.hls=t,this._initSourceBuffer(),this.registerListeners()}var e=t.prototype;return e.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},e.destroy=function(){this.unregisterListeners(),this.details=null},e.registerListeners=function(){var t=this.hls;t.on(n.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(n.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(n.Events.BUFFER_RESET,this.onBufferReset,this),t.on(n.Events.BUFFER_APPENDING,this.onBufferAppending,this),t.on(n.Events.BUFFER_CODECS,this.onBufferCodecs,this),t.on(n.Events.BUFFER_EOS,this.onBufferEos,this),t.on(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(n.Events.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(n.Events.FRAG_PARSED,this.onFragParsed,this),t.on(n.Events.FRAG_CHANGED,this.onFragChanged,this)},e.unregisterListeners=function(){var t=this.hls;t.off(n.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(n.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(n.Events.BUFFER_RESET,this.onBufferReset,this),t.off(n.Events.BUFFER_APPENDING,this.onBufferAppending,this),t.off(n.Events.BUFFER_CODECS,this.onBufferCodecs,this),t.off(n.Events.BUFFER_EOS,this.onBufferEos,this),t.off(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(n.Events.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(n.Events.FRAG_PARSED,this.onFragParsed,this),t.off(n.Events.FRAG_CHANGED,this.onFragChanged,this)},e._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new d.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},e.onManifestParsed=function(t,e){var r=2;(e.audio&&!e.video||!e.altAudio)&&(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,this.details=null,s.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},e.onMediaAttaching=function(t,e){var r=this.media=e.media;if(r&&c){var i=this.mediaSource=new c;i.addEventListener("sourceopen",this._onMediaSourceOpen),i.addEventListener("sourceended",this._onMediaSourceEnded),i.addEventListener("sourceclose",this._onMediaSourceClose),r.src=self.URL.createObjectURL(i),this._objectUrl=r.src}},e.onMediaDetaching=function(){var t=this.media,e=this.mediaSource,r=this._objectUrl;if(e){if(s.logger.log("[buffer-controller]: media source detaching"),"open"===e.readyState)try{e.endOfStream()}catch(t){s.logger.warn("[buffer-controller]: onMediaDetaching: "+t.message+" while calling endOfStream")}this.onBufferReset(),e.removeEventListener("sourceopen",this._onMediaSourceOpen),e.removeEventListener("sourceended",this._onMediaSourceEnded),e.removeEventListener("sourceclose",this._onMediaSourceClose),t&&(r&&self.URL.revokeObjectURL(r),t.src===r?(t.removeAttribute("src"),t.load()):s.logger.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(n.Events.MEDIA_DETACHED,void 0)},e.onBufferReset=function(){var t=this,e=this.sourceBuffer;this.getSourceBufferTypes().forEach((function(r){var i=e[r];try{i&&(t.removeBufferListeners(r),t.mediaSource&&t.mediaSource.removeSourceBuffer(i),e[r]=void 0)}catch(t){s.logger.warn("[buffer-controller]: Failed to reset the "+r+" buffer",t)}})),this._initSourceBuffer()},e.onBufferCodecs=function(t,e){var r=this,i=Object.keys(this.sourceBuffer).length;Object.keys(e).forEach((function(t){if(i){var n=r.tracks[t];if(n&&"function"==typeof n.buffer.changeType){var s=e[t],a=s.codec,o=s.levelCodec,l=s.container;if((n.levelCodec||n.codec).replace(h,"$1")!==(o||a).replace(h,"$1")){var u=l+";codecs="+(o||a);r.appendChangeType(t,u)}}}else r.pendingTracks[t]=e[t]})),i||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks())},e.appendChangeType=function(t,e){var r=this,i=this.operationQueue,n={execute:function(){var n=r.sourceBuffer[t];n&&(s.logger.log("[buffer-controller]: changing "+t+" sourceBuffer type to "+e),n.changeType(e)),i.shiftAndExecuteNext(t)},onStart:function(){},onComplete:function(){},onError:function(e){s.logger.warn("[buffer-controller]: Failed to change "+t+" SourceBuffer type",e)}};i.append(n,t)},e.onBufferAppending=function(t,e){var r=this,i=this.hls,l=this.operationQueue,u=this.tracks,d=e.data,c=e.type,h=e.frag,f=e.part,g=e.chunkMeta,v=g.buffering[c],p=self.performance.now();v.start=p;var m=h.stats.buffering,y=f?f.stats.buffering:null;0===m.start&&(m.start=p),y&&0===y.start&&(y.start=p);var E=u.audio,T="audio"===c&&1===g.id&&"audio/mpeg"===(null==E?void 0:E.container),S={execute:function(){if(v.executeStart=self.performance.now(),T){var t=r.sourceBuffer[c];if(t){var e=h.start-t.timestampOffset;Math.abs(e)>=.1&&(s.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+h.start+" (delta: "+e+") sn: "+h.sn+")"),t.timestampOffset=h.start)}}r.appendExecutor(d,c)},onStart:function(){},onComplete:function(){var t=self.performance.now();v.executeEnd=v.end=t,0===m.first&&(m.first=t),y&&0===y.first&&(y.first=t);var e=r.sourceBuffer,i={};for(var s in e)i[s]=o.BufferHelper.getBuffered(e[s]);r.appendError=0,r.hls.trigger(n.Events.BUFFER_APPENDED,{type:c,frag:h,part:f,chunkMeta:g,parent:h.type,timeRanges:i})},onError:function(t){s.logger.error("[buffer-controller]: Error encountered while trying to append to the "+c+" SourceBuffer",t);var e={type:a.ErrorTypes.MEDIA_ERROR,parent:h.type,details:a.ErrorDetails.BUFFER_APPEND_ERROR,err:t,fatal:!1};t.code===DOMException.QUOTA_EXCEEDED_ERR?e.details=a.ErrorDetails.BUFFER_FULL_ERROR:(r.appendError++,e.details=a.ErrorDetails.BUFFER_APPEND_ERROR,r.appendError>i.config.appendErrorMaxRetry&&(s.logger.error("[buffer-controller]: Failed "+i.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),e.fatal=!0)),i.trigger(n.Events.ERROR,e)}};l.append(S,c)},e.onBufferFlushing=function(t,e){var r=this,i=this.operationQueue,a=function(t){return{execute:r.removeExecutor.bind(r,t,e.startOffset,e.endOffset),onStart:function(){},onComplete:function(){r.hls.trigger(n.Events.BUFFER_FLUSHED,{type:t})},onError:function(e){s.logger.warn("[buffer-controller]: Failed to remove from "+t+" SourceBuffer",e)}}};e.type?i.append(a(e.type),e.type):(i.append(a("audio"),"audio"),i.append(a("video"),"video"))},e.onFragParsed=function(t,e){var r=this,i=e.frag,a=e.part,o=[],l=a?a.elementaryStreams:i.elementaryStreams;l[u.ElementaryStreamTypes.AUDIOVIDEO]?o.push("audiovideo"):(l[u.ElementaryStreamTypes.AUDIO]&&o.push("audio"),l[u.ElementaryStreamTypes.VIDEO]&&o.push("video")),0===o.length&&s.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+i.type+" level: "+i.level+" sn: "+i.sn),this.blockBuffers((function(){var t=self.performance.now();i.stats.buffering.end=t,a&&(a.stats.buffering.end=t);var e=a?a.stats:i.stats;r.hls.trigger(n.Events.FRAG_BUFFERED,{frag:i,part:a,stats:e,id:i.type})}),o)},e.onFragChanged=function(t,e){this.flushBackBuffer()},e.onBufferEos=function(t,e){var r=this;this.getSourceBufferTypes().reduce((function(t,i){var n=r.sourceBuffer[i];return e.type&&e.type!==i||n&&!n.ended&&(n.ended=!0,s.logger.log("[buffer-controller]: "+i+" sourceBuffer now EOS")),t&&!(n&&!n.ended)}),!0)&&this.blockBuffers((function(){var t=r.mediaSource;t&&"open"===t.readyState&&t.endOfStream()}))},e.onLevelUpdated=function(t,e){var r=e.details;r.fragments.length&&(this.details=r,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},e.flushBackBuffer=function(){var t=this.hls,e=this.details,r=this.media,s=this.sourceBuffer;if(r&&null!==e){var a=this.getSourceBufferTypes();if(a.length){var l=e.live&&null!==t.config.liveBackBufferLength?t.config.liveBackBufferLength:t.config.backBufferLength;if(Object(i.isFiniteNumber)(l)&&!(l<0)){var u=r.currentTime,d=e.levelTargetDuration,c=Math.max(l,d),h=Math.floor(u/d)*d-c;a.forEach((function(r){var i=s[r];if(i){var a=o.BufferHelper.getBuffered(i);a.length>0&&h>a.start(0)&&(t.trigger(n.Events.BACK_BUFFER_REACHED,{bufferEnd:h}),e.live&&t.trigger(n.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:h}),t.trigger(n.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:h,type:r}))}}))}}}},e.updateMediaElementDuration=function(){if(this.details&&this.media&&this.mediaSource&&"open"===this.mediaSource.readyState){var t=this.details,e=this.hls,r=this.media,n=this.mediaSource,a=t.fragments[0].start+t.totalduration,o=r.duration,l=Object(i.isFiniteNumber)(n.duration)?n.duration:0;t.live&&e.config.liveDurationInfinity?(s.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),n.duration=1/0,this.updateSeekableRange(t)):(a>l&&a>o||!Object(i.isFiniteNumber)(o))&&(s.logger.log("[buffer-controller]: Updating Media Source duration to "+a.toFixed(3)),n.duration=a)}},e.updateSeekableRange=function(t){var e=this.mediaSource,r=t.fragments;if(r.length&&t.live&&null!=e&&e.setLiveSeekableRange){var i=Math.max(0,r[0].start),n=Math.max(i,i+t.totalduration);e.setLiveSeekableRange(i,n)}},e.checkPendingTracks=function(){var t=this.bufferCodecEventsExpected,e=this.operationQueue,r=this.pendingTracks,i=Object.keys(r).length;if(i&&!t||2===i){this.createSourceBuffers(r),this.pendingTracks={};var s=Object.keys(this.sourceBuffer);if(0===s.length)return void this.hls.trigger(n.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});s.forEach((function(t){e.executeNext(t)}))}},e.createSourceBuffers=function(t){var e=this.sourceBuffer,r=this.mediaSource;if(!r)throw Error("createSourceBuffers called when mediaSource was null");var i=0;for(var o in t)if(!e[o]){var l=t[o];if(!l)throw Error("source buffer exists for track "+o+", however track does not");var u=l.levelCodec||l.codec,d=l.container+";codecs="+u;s.logger.log("[buffer-controller]: creating sourceBuffer("+d+")");try{var c=e[o]=r.addSourceBuffer(d),h=o;this.addBufferListener(h,"updatestart",this._onSBUpdateStart),this.addBufferListener(h,"updateend",this._onSBUpdateEnd),this.addBufferListener(h,"error",this._onSBUpdateError),this.tracks[o]={buffer:c,codec:u,container:l.container,levelCodec:l.levelCodec,id:l.id},i++}catch(t){s.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+t.message),this.hls.trigger(n.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:t,mimeType:d})}}i&&this.hls.trigger(n.Events.BUFFER_CREATED,{tracks:this.tracks})},e._onSBUpdateStart=function(t){this.operationQueue.current(t).onStart()},e._onSBUpdateEnd=function(t){var e=this.operationQueue;e.current(t).onComplete(),e.shiftAndExecuteNext(t)},e._onSBUpdateError=function(t,e){s.logger.error("[buffer-controller]: "+t+" SourceBuffer error",e),this.hls.trigger(n.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var r=this.operationQueue.current(t);r&&r.onError(e)},e.removeExecutor=function(t,e,r){var n=this.media,a=this.mediaSource,o=this.operationQueue,l=this.sourceBuffer[t];if(!n||!a||!l)return s.logger.warn("[buffer-controller]: Attempting to remove from the "+t+" SourceBuffer, but it does not exist"),void o.shiftAndExecuteNext(t);var u=Object(i.isFiniteNumber)(n.duration)?n.duration:1/0,d=Object(i.isFiniteNumber)(a.duration)?a.duration:1/0,c=Math.max(0,e),h=Math.min(r,u,d);h>c?(s.logger.log("[buffer-controller]: Removing ["+c+","+h+"] from the "+t+" SourceBuffer"),console.assert(!l.updating,t+" sourceBuffer must not be updating"),l.remove(c,h)):o.shiftAndExecuteNext(t)},e.appendExecutor=function(t,e){var r=this.operationQueue,i=this.sourceBuffer[e];if(!i)return s.logger.warn("[buffer-controller]: Attempting to append to the "+e+" SourceBuffer, but it does not exist"),void r.shiftAndExecuteNext(e);i.ended=!1,console.assert(!i.updating,e+" sourceBuffer must not be updating"),i.appendBuffer(t)},e.blockBuffers=function(t,e){var r=this;if(void 0===e&&(e=this.getSourceBufferTypes()),!e.length)return s.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve(t);var i=this.operationQueue,n=e.map((function(t){return i.appendBlocker(t)}));Promise.all(n).then((function(){t(),e.forEach((function(t){var e=r.sourceBuffer[t];e&&e.updating||i.shiftAndExecuteNext(t)}))}))},e.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},e.addBufferListener=function(t,e,r){var i=this.sourceBuffer[t];if(i){var n=r.bind(this,t);this.listeners[t].push({event:e,listener:n}),i.addEventListener(e,n)}},e.removeBufferListeners=function(t){var e=this.sourceBuffer[t];e&&this.listeners[t].forEach((function(t){e.removeEventListener(t.event,t.listener)}))},t}()},"./src/controller/buffer-operation-queue.ts":
42
42
  /*!**************************************************!*\
43
43
  !*** ./src/controller/buffer-operation-queue.ts ***!
44
44
  \**************************************************/
@@ -354,4 +354,4 @@
354
354
  /*!*********************************!*\
355
355
  !*** ./src/utils/xhr-loader.ts ***!
356
356
  \*********************************/
357
- /*! exports provided: default */function(t,e,r){r.r(e);var i=r(/*! ../utils/logger */"./src/utils/logger.ts"),n=r(/*! ../loader/load-stats */"./src/loader/load-stats.ts"),s=/^age:\s*[\d.]+\s*$/m,a=function(){function t(t){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=t?t.xhrSetup:null,this.stats=new n.LoadStats,this.retryDelay=0}var e=t.prototype;return e.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},e.abortInternal=function(){var t=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),t&&(t.onreadystatechange=null,t.onprogress=null,4!==t.readyState&&(this.stats.aborted=!0,t.abort()))},e.abort=function(){var t;this.abortInternal(),null!==(t=this.callbacks)&&void 0!==t&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},e.load=function(t,e,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=t,this.config=e,this.callbacks=r,this.retryDelay=e.retryDelay,this.loadInternal()},e.loadInternal=function(){var t=this.config,e=this.context;if(t){var r=this.loader=new self.XMLHttpRequest,i=this.stats;i.loading.first=0,i.loaded=0;var n=this.xhrSetup;try{if(n)try{n(r,e.url)}catch(t){r.open("GET",e.url,!0),n(r,e.url)}r.readyState||r.open("GET",e.url,!0)}catch(t){return void this.callbacks.onError({code:r.status,text:t.message},e,r)}e.rangeEnd&&r.setRequestHeader("Range","bytes="+e.rangeStart+"-"+(e.rangeEnd-1)),r.onreadystatechange=this.readystatechange.bind(this),r.onprogress=this.loadprogress.bind(this),r.responseType=e.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),t.timeout),r.send()}},e.readystatechange=function(){var t=this.context,e=this.loader,r=this.stats;if(t&&e){var n=e.readyState,s=this.config;if(!r.aborted&&n>=2)if(self.clearTimeout(this.requestTimeout),0===r.loading.first&&(r.loading.first=Math.max(self.performance.now(),r.loading.start)),4===n){e.onreadystatechange=null,e.onprogress=null;var a=e.status;if(a>=200&&a<300){var o,l;if(r.loading.end=Math.max(self.performance.now(),r.loading.first),l="arraybuffer"===t.responseType?(o=e.response).byteLength:(o=e.responseText).length,r.loaded=r.total=l,!this.callbacks)return;var u=this.callbacks.onProgress;if(u&&u(r,t,o,e),!this.callbacks)return;var d={url:e.responseURL,data:o};this.callbacks.onSuccess(d,r,t,e)}else r.retry>=s.maxRetry||a>=400&&a<499?(i.logger.error(a+" while loading "+t.url),this.callbacks.onError({code:a,text:e.statusText},t,e)):(i.logger.warn(a+" while loading "+t.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,s.maxRetryDelay),r.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),s.timeout)}},e.loadtimeout=function(){i.logger.warn("timeout while loading "+this.context.url);var t=this.callbacks;t&&(this.abortInternal(),t.onTimeout(this.stats,this.context,this.loader))},e.loadprogress=function(t){var e=this.stats;e.loaded=t.loaded,t.lengthComputable&&(e.total=t.total)},e.getCacheAge=function(){var t=null;if(this.loader&&s.test(this.loader.getAllResponseHeaders())){var e=this.loader.getResponseHeader("age");t=e?parseFloat(e):null}return t},t}();e.default=a}}).default},t.exports=r())})));var r=Object.freeze({__proto__:null,ATTACHED:"hls:attached"});const i="com.widevine.alpha";const n="application/vnd.apple.mpegURL",s=[n,"application/x-mpegurl"],a=document.createElement("video").canPlayType(n);function o(t){const{pathname:e}=function(t){const e=document.createElement("a");return e.href=t,e}(t);return e.endsWith(".m3u8")}function l({src:t="",type:e="",drm:r},n){const l=(null==n?void 0:n.hls)||{},u="native"in l&&l.native;return(!a||!u)&&(!(r&&!Object.keys(r).find(t=>{return e=t,[i].filter((function(t){return t===e})).length;var e}))&&(!(!e||!s.includes(e))||o(t)))}var u="audio:set",d="audio:update",c="audio:tracks";const h=[e.Events.SUBTITLE_TRACKS_UPDATED,e.Events.SUBTITLE_TRACK_SWITCH,e.Events.LEVEL_SWITCHED];function f(t,e){h.forEach((function(r){t.on(r,(function(){!function(t,e){var r;const i=t.levels[t.currentLevel];if(!i||!t.subtitleTracks.length||i.attrs.SUB)return;const n=null===(r=null==i?void 0:i.attrs)||void 0===r?void 0:r.SUBTITLES;if(!n)return e.emit("tracks:text:all",[]);const s=t.subtitleTracks.filter((function(t){return t.groupId==n})).map((function(t){return e.textTracks[t.id]}));e.emit("tracks:text:all",s)}(t,e)}))}))}var g=Object.assign(Object.assign({},{404:"the video was not found",403:"access to this video was denied",410:"the video no longer exists",0:"no internet connection detected"}),{keySystemNoKeys:"no keys",keySystemNoAccess:"no access to key system",keySystemNoSession:"no session for key system",keySystemLicenseRequestFailed:"license request failed",keyLoadError:"decrypt key load failed",keyLoadTimeOut:"decrypt key load timed outs"});function v(t,r,i){if(!t.reaper||!i.src)return;t.hls&&(t.emit("recover",{type:"hls"}),t.hls.destroy());const n="live"in r==0;if(i.drm&&"https:"!==location.protocol&&"localhost"!==location.hostname&&"127.0.0.1"!==location.hostname)return t.emit("error",{message:"Secure page required for DRM"});const s=t.hls=new e(Object.assign(Object.assign({},r.hls),{startPosition:r.start_time||-1}));s.attachMedia(t),s.loadSource(i.src),t.emit("hls:attached",{hls:s}),function(t,r){t.on(e.Events.AUDIO_TRACKS_UPDATED,(function(t,e){r.emit(c,e.audioTracks)})),t.on(e.Events.AUDIO_TRACK_SWITCHING,(function(t,e){r.emit(d,e)})),t.on(e.Events.MANIFEST_PARSED,(function(t,e){e.audioTracks&&r.emit(c,e.audioTracks)})),t.on(e.Events.LEVEL_SWITCHED,(function(e,i){const n=t.levels[i.level];n&&r.emit(c,t.audioTracks.filter((function(t){return t.groupId&&~(n.audioGroupIds||[]).indexOf(t.groupId)})))}))}(s,t),f(s,t);const a=function(t){var e;const r=null===(e=t.data)||void 0===e?void 0:e.level;"number"==typeof r&&(s.levels[r]||-1===r?s.nextLevel=r:console.error(new Error("skipping invalid quality: "+t.data)))},o=function(t){var e;const r=null===(e=t.data)||void 0===e?void 0:e.id;"number"==typeof r&&r!=s.audioTrack&&setTimeout((function(){s.audioTrack=r}),0)};t.on("quality:set",a),t.on(u,o),t.on("src",(function(){t.hls&&t.hls.destroy(),t.off("quality:set",a),t.off(u,o)})),t.on("audioonlysource",(function(){})),t.on("reap",(function(){s&&s.destroy()})),n&&s.on(e.Events.LEVEL_LOADED,(function(e,r){t.setOpts({live:r.details.live})})),s.on(e.Events.MANIFEST_PARSED,(function(e,r){const i=r.levels.slice(0).reduce((t,e,r)=>[...t,{level:r,text:e.name||e.width+"",width:e.width,height:e.height,videoCodec:e.videoCodec||""}],[{text:"AUTO",level:-1,width:0,height:0,videoCodec:""}]).sort((t,e)=>e.width-t.width);t.emit("qualities",i);const n=i.find(t=>!!t.videoCodec);n||t.emit("audioonlysource"),!t.opt("ratio")&&n&&0!=n.width&&0!=n.height&&t.setOpts({ratio:n.width+":"+n.height})})),s.on(e.Events.LEVEL_LOADED,(t,e)=>{console.log(t,e)}),s.on(e.Events.INIT_PTS_FOUND,(function(t,e){e.frag.duration})),s.on(e.Events.ERROR,(function(r,i){!function(t,r,i,n){if(0==t.reaper)return;if(0==r.fatal)return;switch(r.type){case e.ErrorTypes.MEDIA_ERROR:return function(t,e){var r;t.emit("error",{fatal:!0,message:"Unrecoverable error occurred while playing media"}),null===(r=t.hls)||void 0===r||r.destroy()}(t);case e.ErrorTypes.NETWORK_ERROR:return function(t,e){var r;const i=null===(r=e.networkDetails)||void 0===r?void 0:r.status;t.emit("error",{fatal:!0,code:"http:"+i.toString(),message:g[i]||"an error occurred while loading this video"})}(t,r);case e.ErrorTypes.KEY_SYSTEM_ERROR:(function(t,e){var r;t.emit("error",{fatal:!0,message:g[e.details]||"an error occurred while accessing this video"}),null===(r=t.hls)||void 0===r||r.destroy()})(t,r)}}(t,i,t.original_src)}));const l=t.opt("start_time");l&&t.once("loadedmetadata",(function(){t.currentTime=l})),t.on("loadstart",(function(){l&&s.startLoad(l)}))}class p{init(){}onload(t,e,r,i){v(r,t,i)}wants(t,r,i){return e.isSupported()&&l(r,i)}}return p.events=r,p.version=e.version,function(t,e){if("object"==typeof exports&&"undefined"!=typeof module)return e;"flowplayer"in t||(t.flowplayer={extensions:[]});const r=t.flowplayer;"function"==typeof r?r(e):(Array.isArray(r.extensions)||(r.extensions=[]),~r.extensions.indexOf(e)||r.extensions.push(e))}(window,p),p}));
357
+ /*! exports provided: default */function(t,e,r){r.r(e);var i=r(/*! ../utils/logger */"./src/utils/logger.ts"),n=r(/*! ../loader/load-stats */"./src/loader/load-stats.ts"),s=/^age:\s*[\d.]+\s*$/m,a=function(){function t(t){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=t?t.xhrSetup:null,this.stats=new n.LoadStats,this.retryDelay=0}var e=t.prototype;return e.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},e.abortInternal=function(){var t=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),t&&(t.onreadystatechange=null,t.onprogress=null,4!==t.readyState&&(this.stats.aborted=!0,t.abort()))},e.abort=function(){var t;this.abortInternal(),null!==(t=this.callbacks)&&void 0!==t&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},e.load=function(t,e,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=t,this.config=e,this.callbacks=r,this.retryDelay=e.retryDelay,this.loadInternal()},e.loadInternal=function(){var t=this.config,e=this.context;if(t){var r=this.loader=new self.XMLHttpRequest,i=this.stats;i.loading.first=0,i.loaded=0;var n=this.xhrSetup;try{if(n)try{n(r,e.url)}catch(t){r.open("GET",e.url,!0),n(r,e.url)}r.readyState||r.open("GET",e.url,!0)}catch(t){return void this.callbacks.onError({code:r.status,text:t.message},e,r)}e.rangeEnd&&r.setRequestHeader("Range","bytes="+e.rangeStart+"-"+(e.rangeEnd-1)),r.onreadystatechange=this.readystatechange.bind(this),r.onprogress=this.loadprogress.bind(this),r.responseType=e.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),t.timeout),r.send()}},e.readystatechange=function(){var t=this.context,e=this.loader,r=this.stats;if(t&&e){var n=e.readyState,s=this.config;if(!r.aborted&&n>=2)if(self.clearTimeout(this.requestTimeout),0===r.loading.first&&(r.loading.first=Math.max(self.performance.now(),r.loading.start)),4===n){e.onreadystatechange=null,e.onprogress=null;var a=e.status;if(a>=200&&a<300){var o,l;if(r.loading.end=Math.max(self.performance.now(),r.loading.first),l="arraybuffer"===t.responseType?(o=e.response).byteLength:(o=e.responseText).length,r.loaded=r.total=l,!this.callbacks)return;var u=this.callbacks.onProgress;if(u&&u(r,t,o,e),!this.callbacks)return;var d={url:e.responseURL,data:o};this.callbacks.onSuccess(d,r,t,e)}else r.retry>=s.maxRetry||a>=400&&a<499?(i.logger.error(a+" while loading "+t.url),this.callbacks.onError({code:a,text:e.statusText},t,e)):(i.logger.warn(a+" while loading "+t.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,s.maxRetryDelay),r.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),s.timeout)}},e.loadtimeout=function(){i.logger.warn("timeout while loading "+this.context.url);var t=this.callbacks;t&&(this.abortInternal(),t.onTimeout(this.stats,this.context,this.loader))},e.loadprogress=function(t){var e=this.stats;e.loaded=t.loaded,t.lengthComputable&&(e.total=t.total)},e.getCacheAge=function(){var t=null;if(this.loader&&s.test(this.loader.getAllResponseHeaders())){var e=this.loader.getResponseHeader("age");t=e?parseFloat(e):null}return t},t}();e.default=a}}).default},t.exports=r())})));var r=Object.freeze({__proto__:null,ATTACHED:"hls:attached"});const i="com.widevine.alpha";const n="application/vnd.apple.mpegURL",s=[n,"application/x-mpegurl"],a=document.createElement("video").canPlayType(n);function o(t){const{pathname:e}=function(t){const e=document.createElement("a");return e.href=t,e}(t);return e.endsWith(".m3u8")}function l({src:t="",type:e="",drm:r},n){const l=(null==n?void 0:n.hls)||{},u="native"in l&&l.native;return(!a||!u)&&(!(r&&!Object.keys(r).find(t=>{return e=t,[i].filter((function(t){return t===e})).length;var e}))&&(!(!e||!s.includes(e))||o(t)))}var u="audio:set",d="audio:update",c="audio:tracks";const h=[e.Events.SUBTITLE_TRACKS_UPDATED,e.Events.SUBTITLE_TRACK_SWITCH,e.Events.LEVEL_SWITCHED];function f(t,e){h.forEach((function(r){t.on(r,(function(){!function(t,e){var r;const i=t.levels[t.currentLevel];if(!i||!t.subtitleTracks.length||i.attrs.SUB)return;const n=null===(r=null==i?void 0:i.attrs)||void 0===r?void 0:r.SUBTITLES;if(!n)return e.emit("tracks:text:all",[]);const s=t.subtitleTracks.filter((function(t){return t.groupId==n})).map((function(t){return e.textTracks[t.id]}));e.emit("tracks:text:all",s)}(t,e)}))}))}var g=Object.assign(Object.assign({},{404:"the video was not found",403:"access to this video was denied",410:"the video no longer exists",0:"no internet connection detected"}),{keySystemNoKeys:"no keys",keySystemNoAccess:"no access to key system",keySystemNoSession:"no session for key system",keySystemLicenseRequestFailed:"license request failed",keyLoadError:"decrypt key load failed",keyLoadTimeOut:"decrypt key load timed outs"});var v;function p(t,r,i){if(!t.reaper||!i.src)return;t.hls&&(t.emit("recover",{type:"hls"}),t.hls.destroy());const n="live"in r==0;if(i.drm&&"https:"!==location.protocol&&"localhost"!==location.hostname&&"127.0.0.1"!==location.hostname)return t.emit("error",{message:"Secure page required for DRM"});const s=t.hls=new e(function(t){return Object.assign(Object.assign({autoStartLoad:!1},t.hls),{startPosition:t.start_time||-1})}(r));s.subtitleDisplay=!1,s.attachMedia(t),s.loadSource(i.src),t.emit("hls:attached",{hls:s}),function(t,r){t.on(e.Events.AUDIO_TRACKS_UPDATED,(function(t,e){r.emit(c,e.audioTracks)})),t.on(e.Events.AUDIO_TRACK_SWITCHING,(function(t,e){r.emit(d,e)})),t.on(e.Events.MANIFEST_PARSED,(function(t,e){e.audioTracks&&r.emit(c,e.audioTracks)})),t.on(e.Events.LEVEL_SWITCHED,(function(e,i){const n=t.levels[i.level];n&&r.emit(c,t.audioTracks.filter((function(t){return t.groupId&&~(n.audioGroupIds||[]).indexOf(t.groupId)})))}))}(s,t),f(s,t);const a=function(t){var e;const r=null===(e=t.data)||void 0===e?void 0:e.level;"number"==typeof r&&(s.levels[r]||-1===r?s.nextLevel=r:console.error(new Error("skipping invalid quality: "+t.data)))},o=function(t){var e;const r=null===(e=t.data)||void 0===e?void 0:e.id;"number"==typeof r&&r!=s.audioTrack&&setTimeout((function(){s.audioTrack=r}),0)};t.on("quality:set",a),t.on(u,o),t.on("src",(function(){t.hls&&t.hls.destroy(),t.off("quality:set",a),t.off(u,o)})),t.on("audioonlysource",(function(){})),t.on("reap",(function(){s&&s.destroy()})),t.on("remotesession:started",()=>{t.hls&&t.hls.stopLoad()}),t.on("remotesession:ended",()=>{t.hls&&t.hls.startLoad()}),n&&s.on(e.Events.LEVEL_LOADED,(function(e,r){t.setOpts({live:r.details.live})})),s.on(e.Events.MANIFEST_PARSED,(function(e,i){const n=i.levels.slice(0).reduce((t,e,r)=>[...t,{level:r,text:e.name||e.width+"",width:e.width,height:e.height,videoCodec:e.videoCodec||""}],[{text:"AUTO",level:-1,width:0,height:0,videoCodec:""}]).sort((t,e)=>e.width-t.width);t.emit("qualities",n),function(t,e,r){var i;if(!t.hls)return;void 0!==e.start_quality&&(v.HIGH&e.start_quality&&(t.hls.startLevel=r[0].level),v.LOW&e.start_quality&&(t.hls.startLevel=r[r.length-1].level),v.MEDIUM&e.start_quality&&(t.hls.startLevel=r[Math.ceil(r.length/2)-1].level));("none"!==e.preload||e.autoplay)&&(null===(i=t.hls)||void 0===i||i.startLoad(e.start_time||-1))}(t,r,n.slice(0,-1));const s=n.find(t=>!!t.videoCodec);s||t.emit("audioonlysource"),!t.opt("ratio")&&s&&0!=s.width&&0!=s.height&&t.setOpts({ratio:s.width+":"+s.height})})),s.on(e.Events.INIT_PTS_FOUND,(function(t,e){e.frag.duration})),s.on(e.Events.ERROR,(function(r,i){!function(t,r,i,n){if(0==t.reaper)return;if(0==r.fatal)return;switch(r.type){case e.ErrorTypes.MEDIA_ERROR:return function(t,e){var r;t.emit("error",{fatal:!0,message:"Unrecoverable error occurred while playing media"}),null===(r=t.hls)||void 0===r||r.destroy()}(t);case e.ErrorTypes.NETWORK_ERROR:return function(t,e){var r;const i=null===(r=e.networkDetails)||void 0===r?void 0:r.status;t.emit("error",{fatal:!0,code:"http:"+i.toString(),message:g[i]||"an error occurred while loading this video"})}(t,r);case e.ErrorTypes.KEY_SYSTEM_ERROR:(function(t,e){var r;t.emit("error",{fatal:!0,message:g[e.details]||"an error occurred while accessing this video"}),null===(r=t.hls)||void 0===r||r.destroy()})(t,r)}}(t,i,t.original_src,s.config)})),s.on(e.Events.LEVEL_SWITCHING,(e,r)=>{const i=s.levels[s.currentLevel],n=s.levels[r.level];t.emit("qualitychange",{before:i,after:n,kind:"hls"})});const l=t.opt("start_time");l&&t.once("loadedmetadata",(function(){t.currentTime=l})),"none"===r.preload&&t.once("beforeplay",()=>{s.startLoad(r.start_time||-1)})}!function(t){t[t.LOW=1]="LOW",t[t.MEDIUM=2]="MEDIUM",t[t.HIGH=4]="HIGH"}(v||(v={}));class HLS{init(){}onload(t,e,r,i){p(r,t,i)}wants(t,r,i){return e.isSupported()&&l(r,i)}}return HLS.events=r,HLS.version=e.version,function(t,e){if("object"==typeof exports&&"undefined"!=typeof module)return e;"flowplayer"in t||(t.flowplayer={extensions:[]});const r=t.flowplayer;"function"==typeof r?r(e):(Array.isArray(r.extensions)||(r.extensions=[]),~r.extensions.indexOf(e)||r.extensions.push(e))}(window,HLS),HLS}));
package/plugins/id3.js CHANGED
@@ -13,4 +13,4 @@
13
13
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
14
  PERFORMANCE OF THIS SOFTWARE.
15
15
  ***************************************************************************** */
16
- function n(e,n,t,o){return new(t||(t=Promise))((function(i,f){function r(e){try{u(o.next(e))}catch(e){f(e)}}function a(e){try{u(o.throw(e))}catch(e){f(e)}}function u(e){var n;e.done?i(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(r,a)}u((o=o.apply(e,n||[])).next())}))}class t{init(e,t,o){o.textTracks.addEventListener("addtrack",({track:e})=>{if(e&&"metadata"===e.kind)return"id3"==e.id||"id3"==e.label?function(e,t){t.addEventListener("cuechange",()=>n(this,void 0,void 0,(function*(){Array.from(t.activeCues||[]).forEach(t=>n(this,void 0,void 0,(function*(){(function(e){return"object"==typeof e.value&&"string"==typeof e.value.info&&"string"==typeof e.value.key&&"object"==typeof e.value.data})(t)&&e.emit("ID3",{cue:t})})))})))}(o,e):void 0})}}return t.events=e,function(e,n){if("object"==typeof exports&&"undefined"!=typeof module)return n;"flowplayer"in e||(e.flowplayer={extensions:[]});const t=e.flowplayer;"function"==typeof t?t(n):(Array.isArray(t.extensions)||(t.extensions=[]),~t.extensions.indexOf(n)||t.extensions.push(n))}(window,t),t}));
16
+ function n(e,n,t,o){return new(t||(t=Promise))((function(i,f){function r(e){try{u(o.next(e))}catch(e){f(e)}}function a(e){try{u(o.throw(e))}catch(e){f(e)}}function u(e){var n;e.done?i(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(r,a)}u((o=o.apply(e,n||[])).next())}))}class ID3{init(e,t,o){o.textTracks.addEventListener("addtrack",({track:e})=>{if(e&&"metadata"===e.kind)return"id3"==e.id||"id3"==e.label?function(e,t){t.addEventListener("cuechange",()=>n(this,void 0,void 0,(function*(){Array.from(t.activeCues||[]).forEach(t=>n(this,void 0,void 0,(function*(){(function(e){return"object"==typeof e.value&&"string"==typeof e.value.info&&"string"==typeof e.value.key&&"object"==typeof e.value.data})(t)&&e.emit("ID3",{cue:t})})))})))}(o,e):void 0})}}return ID3.events=e,function(e,n){if("object"==typeof exports&&"undefined"!=typeof module)return n;"flowplayer"in e||(e.flowplayer={extensions:[]});const t=e.flowplayer;"function"==typeof t?t(n):(Array.isArray(t.extensions)||(t.extensions=[]),~t.extensions.indexOf(n)||t.extensions.push(n))}(window,ID3),ID3}));
package/plugins/iframe.js CHANGED
@@ -1 +1 @@
1
- !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.iframe=n())}(this,(function(){"use strict";class e{constructor(n){e.ATTACHED||(e.ATTACHED=!0,window.addEventListener("message",(function(t){if(!e.is_flowplayer_message(t.data))return;const o=n.instances||[],s=o[0];if(!s)return;o.length>1&&console.warn("Multiple player instances in iframe. Messaging supported with first instance only.");switch(e.message_body(t.data)){case"pause":return s.togglePlay(!1);case"play":return s.togglePlay(!0)}})))}init(e,n,t){t.on("fullscreenenter",(function(){document.fullscreenEnabled||"function"==typeof t.webkitEnterFullscreen&&(t.webkitEnterFullscreen(),t.once("webkitendfullscreen",(function(){t.emit("fullscreenexit")})),t.on("ended",(function(){t.webkitExitFullscreen()})))}))}}return e.FLOWPLAYER_RPC_PROTOCOL="flowplayer://",e.ATTACHED=!1,e.is_flowplayer_message=function(n){return"string"==typeof n&&n.startsWith(e.FLOWPLAYER_RPC_PROTOCOL)},e.message_body=function(n){return n.slice(e.FLOWPLAYER_RPC_PROTOCOL.length)},function(){try{return window.self!==window.top}catch(e){return!0}}()&&function(e,n){if("object"==typeof exports&&"undefined"!=typeof module)return n;"flowplayer"in e||(e.flowplayer={extensions:[]});const t=e.flowplayer;"function"==typeof t?t(n):(Array.isArray(t.extensions)||(t.extensions=[]),~t.extensions.indexOf(n)||t.extensions.push(n))}(window,e),e}));
1
+ !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.iframe=n())}(this,(function(){"use strict";class Iframe{constructor(e){Iframe.ATTACHED||(Iframe.ATTACHED=!0,window.addEventListener("message",(function(n){if(!Iframe.is_flowplayer_message(n.data))return;const t=e.instances||[],r=t[0];if(!r)return;t.length>1&&console.warn("Multiple player instances in iframe. Messaging supported with first instance only.");switch(Iframe.message_body(n.data)){case"pause":return r.togglePlay(!1);case"play":return r.togglePlay(!0)}})))}init(e,n,t){t.on("fullscreenenter",(function(){document.fullscreenEnabled||"function"==typeof t.webkitEnterFullscreen&&(t.webkitEnterFullscreen(),t.once("webkitendfullscreen",(function(){t.emit("fullscreenexit")})),t.on("ended",(function(){t.webkitExitFullscreen()})))}))}}return Iframe.FLOWPLAYER_RPC_PROTOCOL="flowplayer://",Iframe.ATTACHED=!1,Iframe.is_flowplayer_message=function(e){return"string"==typeof e&&e.startsWith(Iframe.FLOWPLAYER_RPC_PROTOCOL)},Iframe.message_body=function(e){return e.slice(Iframe.FLOWPLAYER_RPC_PROTOCOL.length)},function(){try{return window.self!==window.top}catch(e){return!0}}()&&function(e,n){if("object"==typeof exports&&"undefined"!=typeof module)return n;"flowplayer"in e||(e.flowplayer={extensions:[]});const t=e.flowplayer;"function"==typeof t?t(n):(Array.isArray(t.extensions)||(t.extensions=[]),~t.extensions.indexOf(n)||t.extensions.push(n))}(window,Iframe),Iframe}));
@@ -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.keyboard=t())}(this,(function(){"use strict";function e(e,t,n){const i=function(e){return Array.isArray(e)?e.slice(0):e.split(".")}(t);for(;i.length;){if(null==e)return n;const t=i.shift();if("string"!=typeof t)return n;e=e[t]}return null==e?n:e}function t(e,t,n){const i=function(e,t){const n=new Event(e);return t&&Object.assign(n,{data:t}),n}(t,n);return e.dispatchEvent(i),e}!function(){let e=!1;try{const t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("testPassive",null,t),window.removeEventListener("testPassive",null,t)}catch(e){}}();var n={TAB:9,ENTER:13,ESCAPE:27,SPACE:32,ARROW_LEFT:37,ARROW_UP:38,ARROW_RIGHT:39,ARROW_DOWN:40,F:70,H:72,J:74,K:75,L:76,M:77};let i=void 0;function o(e){e.setState("is-kb-active",!0),clearTimeout(i),i=setTimeout((function(){e.setState("is-kb-active",!1)}),2500)}function r(e,t){e.enqueueSeek(t)&&o(e)}let s=void 0;const u=[n.ARROW_UP,n.ARROW_RIGHT,n.ARROW_LEFT,n.ARROW_DOWN],a=[n.SPACE,n.F,n.ESCAPE,n.M,n.ARROW_UP,n.ARROW_DOWN,n.ARROW_RIGHT,n.ARROW_LEFT,n.H,n.J,n.K,n.L];function c(e,t){e.volume=function(e,t,n=0){return Math.max(Math.min(t,e),n)}(e.volume+t,1,0),o(e)}function f(e,t){return!(t.altKey||t.shiftKey||t.metaKey||t.ctrlKey)&&(!!(e&&e.in_viewport&&e.started)&&(!!e.root&&(function(e){let t=document.activeElement;for(;t;){if(t===e)return!0;t=t.parentElement}return!1}(e.root)||document.activeElement===document.body)))}function l(e){e.preventDefault(),e.stopPropagation()}function R(e,t){return!!d(e,t)}function d(e,t){return!!e.parentElement&&(e.parentElement.matches(t)?e.parentElement:R(e.parentElement,t))}document.addEventListener("keydown",(function(i){setTimeout((function(){i.defaultPrevented||function(i){const o=i.which,p=s,A=e(p,"opts.keyboard.seek_step",5),E=document.activeElement;if(!E)return;if(!p)return;if((o===n.SPACE||o===n.ENTER)&&E.hasAttribute("tabindex")&&R(E,".flowplayer"))return E.dispatchEvent(new MouseEvent("click",{bubbles:!0})),l(i);if(~u.indexOf(o)&&E.hasAttribute("aria-valuenow")){const e=~[n.ARROW_UP,n.ARROW_RIGHT].indexOf(o);if(E.matches(".fp-volume"))return c(p,e?.15:-.15),l(i);if(E.matches(".fp-timeline"))return r(p,e?A:-1*A),l(i)}if((o===n.ARROW_DOWN||o===n.ARROW_UP||o===n.ESCAPE)&&R(E,".fp-menu"))return i.preventDefault(),o===n.ARROW_DOWN&&E.nextSibling&&E.nextSibling.focus(),o===n.ARROW_UP&&E.previousSibling&&E.nextSibling.focus(),void(o===n.ESCAPE&&t(p.root,"menu:toggle:open",{open:!1,menu:d(E,".fp-menu")}));if(o===n.TAB){const e=window.flowplayer;e&&Array.isArray(e.instances)&&e.instances.forEach((function(e){e.setState("is-hovered",!0),e.setState("is-accessibility",!0)}))}if(!f(p,i))return;const m=!p.hasState("no-timeline");switch(~a.indexOf(o)&&i.preventDefault(),o){case n.SPACE:return p.togglePlay();case n.F:return p.toggleFullScreen();case n.ESCAPE:return p.toggleFullScreen(!1);case n.M:return p.toggleMute();case n.ARROW_UP:case n.K:return c(p,.15);case n.ARROW_DOWN:case n.J:return c(p,-.15);case n.ARROW_RIGHT:case n.L:return m&&r(p,A);case n.ARROW_LEFT:case n.H:m&&r(p,-1*A)}}(i)}),0)}));class p{init(e,t,n){n.on(["loadstart","playing","fullscreenenter"],(function(){s=n}))}}return function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;"function"==typeof n?n(t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t))}(window,p),p}));
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.keyboard=t())}(this,(function(){"use strict";function e(e,t,n){const i=function(e){return Array.isArray(e)?e.slice(0):e.split(".")}(t);for(;i.length;){if(null==e)return n;const t=i.shift();if("string"!=typeof t)return n;e=e[t]}return null==e?n:e}function t(e,t,n){const i=function(e,t){const n=new CustomEvent(e,{detail:t,cancelable:!0});return t&&Object.defineProperty(n,"data",{get:()=>t}),n}(t,n);return e.dispatchEvent(i),e}!function(){let e=!1;try{const t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("testPassive",null,t),window.removeEventListener("testPassive",null,t)}catch(e){}}();var n={TAB:9,ENTER:13,ESCAPE:27,SPACE:32,ARROW_LEFT:37,ARROW_UP:38,ARROW_RIGHT:39,ARROW_DOWN:40,F:70,H:72,J:74,K:75,L:76,M:77};let i=void 0;function o(e){e.setState("is-kb-active",!0),clearTimeout(i),i=setTimeout((function(){e.setState("is-kb-active",!1)}),2500)}function r(e,t){e.enqueueSeek(t)&&o(e)}let s=void 0;const u=[n.ARROW_UP,n.ARROW_RIGHT,n.ARROW_LEFT,n.ARROW_DOWN],a=[n.SPACE,n.F,n.ESCAPE,n.M,n.ARROW_UP,n.ARROW_DOWN,n.ARROW_RIGHT,n.ARROW_LEFT,n.H,n.J,n.K,n.L];function c(e,t){e.volume=function(e,t,n=0){return Math.max(Math.min(t,e),n)}(e.volume+t,1,0),o(e)}function l(e,t){return!(t.altKey||t.shiftKey||t.metaKey||t.ctrlKey)&&(!!(e&&e.in_viewport&&e.started)&&(!!e.root&&(function(e){let t=document.activeElement;for(;t;){if(t===e)return!0;t=t.parentElement}return!1}(e.root)||document.activeElement===document.body)))}function f(e){e.preventDefault(),e.stopPropagation()}function d(e,t){return!!R(e,t)}function R(e,t){return!!e.parentElement&&(e.parentElement.matches(t)?e.parentElement:d(e.parentElement,t))}document.addEventListener("keydown",(function(i){setTimeout((function(){i.defaultPrevented||function(i){const o=i.which,p=s,A=e(p,"opts.keyboard.seek_step",5),y=document.activeElement;if(!y)return;if(!p)return;if((o===n.SPACE||o===n.ENTER)&&y.hasAttribute("tabindex")&&d(y,".flowplayer"))return y.dispatchEvent(new MouseEvent("click",{bubbles:!0})),f(i);if(~u.indexOf(o)&&y.hasAttribute("aria-valuenow")){const e=~[n.ARROW_UP,n.ARROW_RIGHT].indexOf(o);if(y.matches(".fp-volume"))return c(p,e?.15:-.15),f(i);if(y.matches(".fp-timeline"))return r(p,e?A:-1*A),f(i)}if((o===n.ARROW_DOWN||o===n.ARROW_UP||o===n.ESCAPE)&&d(y,".fp-menu"))return i.preventDefault(),o===n.ARROW_DOWN&&y.nextSibling&&y.nextSibling.focus(),o===n.ARROW_UP&&y.previousSibling&&y.nextSibling.focus(),void(o===n.ESCAPE&&t(p.root,"menu:toggle:open",{open:!1,menu:R(y,".fp-menu")}));if(o===n.TAB){const e=window.flowplayer;e&&Array.isArray(e.instances)&&e.instances.forEach((function(e){e.setState("is-hovered",!0),e.setState("is-accessibility",!0)}))}if(!l(p,i))return;const E=!p.hasState("no-timeline");switch(~a.indexOf(o)&&i.preventDefault(),o){case n.SPACE:return p.togglePlay();case n.F:return p.toggleFullScreen();case n.ESCAPE:return p.toggleFullScreen(!1);case n.M:return p.toggleMute();case n.ARROW_UP:case n.K:return c(p,.15);case n.ARROW_DOWN:case n.J:return c(p,-.15);case n.ARROW_RIGHT:case n.L:return E&&r(p,A);case n.ARROW_LEFT:case n.H:E&&r(p,-1*A)}}(i)}),0)}));class Keyboard{init(e,t,n){n.on(["loadstart","playing","fullscreenenter"],(function(){s=n}))}}return function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;"function"==typeof n?n(t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t))}(window,Keyboard),Keyboard}));
@@ -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.media_session=t())}(this,(function(){"use strict";let e=void 0;function t(t,n){t.enqueueSeek(n)&&function(t){t.setState("is-kb-active",!0),clearTimeout(e),e=setTimeout((function(){t.setState("is-kb-active",!1)}),2500)}(t)}const n="pause",i="playing",o="seeked";var a="playlist:next";let s=void 0;function l(e){e.data&&r(e.data)}function r(e){var t,n,i;const o=null!==(t=e.media_session)&&void 0!==t?t:{};if(null!==(n=o.title)&&void 0!==n||(o.title=e.title),null==o.artwork){const t=null!==(i=e.poster)&&void 0!==i?i:"";o.artwork=[{src:t,sizes:"512x512"},{src:t,sizes:"256x256"}]}navigator.mediaSession.metadata=new MediaMetadata(o)}function c(){const e=navigator.mediaSession;if(null==e.setPositionState)return;const t=s;t&&(e.setPositionState({duration:Math.round(t.duration||0),playbackRate:t.hasState("is-playing")?t.playbackRate:.001,position:Math.round(t.currentTime)}),e.playbackState=t.hasState("is-playing")?"playing":"paused")}function u(e){const n=s,i=navigator.mediaSession;if(n){if(i.setActionHandler("play",(function(){n.togglePlay()})),i.setActionHandler("pause",(function(){n.togglePlay()})),"playlist"in n){const e=n.playlist;i.setActionHandler("nexttrack",(function(){e&&e.next()})),i.setActionHandler("previoustrack",(function(){e&&e.prev()}))}!function(e,n){var i,o;if(null!==(i=n.seekable)&&void 0!==i&&!i||e.hasState("no-timeline"))return;const a=navigator.mediaSession,s=null!==(o=n.seek_step)&&void 0!==o?o:5;e.disabled||a.setActionHandler("seekforward",(function(){t(e,s)}));a.setActionHandler("seekbackward",(function(){t(e,-s)}));try{a.setActionHandler("seekto",(function(t){"number"==typeof t.seekTime&&(t.seekTime>e.currentTime&&e.disabled?c():t&&t.seekTime<e.duration&&(e.currentTime=t.seekTime))}))}catch(e){}}(n,e)}}class d{init(e,t,d){null!=navigator.mediaSession&&d.on(["loadstart",i,"fullscreenenter"],(function(){let t=s;d!==t&&(t&&(["ratechange",o,i,n].forEach(e=>{t&&t.off(e,c)}),t.off(a,l),t=void 0),s=d,r(e),u(e),c(),d.on(["ratechange",o,i,n],c),d.on(a,l))}))}}return function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;"function"==typeof n?n(t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t))}(window,d),d}));
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.media_session=t())}(this,(function(){"use strict";let e=void 0;function t(t,n){t.enqueueSeek(n)&&function(t){t.setState("is-kb-active",!0),clearTimeout(e),e=setTimeout((function(){t.setState("is-kb-active",!1)}),2500)}(t)}const n="pause",i="playing",o="seeked";var a="playlist:next";let s=void 0;function l(e){e.data&&r(e.data)}function r(e){var t,n,i;const o=null!==(t=e.media_session)&&void 0!==t?t:{};if(null!==(n=o.title)&&void 0!==n||(o.title=e.title),null==o.artwork){const t=null!==(i=e.poster)&&void 0!==i?i:"";o.artwork=[{src:t,sizes:"512x512"},{src:t,sizes:"256x256"}]}navigator.mediaSession.metadata=new MediaMetadata(o)}function c(){const e=navigator.mediaSession;if(null==e.setPositionState)return;const t=s;t&&(e.setPositionState({duration:Math.round(t.duration||0),playbackRate:t.hasState("is-playing")?t.playbackRate:.001,position:Math.round(t.currentTime)}),e.playbackState=t.hasState("is-playing")?"playing":"paused")}function d(e){const n=s,i=navigator.mediaSession;if(n){if(i.setActionHandler("play",(function(){n.togglePlay()})),i.setActionHandler("pause",(function(){n.togglePlay()})),"playlist"in n){const e=n.playlist;i.setActionHandler("nexttrack",(function(){e&&e.next()})),i.setActionHandler("previoustrack",(function(){e&&e.prev()}))}!function(e,n){var i,o;if(null!==(i=n.seekable)&&void 0!==i&&!i||e.hasState("no-timeline"))return;const a=navigator.mediaSession,s=null!==(o=n.seek_step)&&void 0!==o?o:5;e.disabled||a.setActionHandler("seekforward",(function(){t(e,s)}));a.setActionHandler("seekbackward",(function(){t(e,-s)}));try{a.setActionHandler("seekto",(function(t){"number"==typeof t.seekTime&&(t.seekTime>e.currentTime&&e.disabled?c():t&&t.seekTime<e.duration&&(e.currentTime=t.seekTime))}))}catch(e){}}(n,e)}}class MediaSession{init(e,t,u){null!=navigator.mediaSession&&u.on(["loadstart",i,"fullscreenenter"],(function(){let t=s;u!==t&&(t&&(["ratechange",o,i,n].forEach(e=>{t&&t.off(e,c)}),t.off(a,l),t=void 0),s=u,r(e),d(e),c(),u.on(["ratechange",o,i,n],c),u.on(a,l))}))}}return function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;"function"==typeof n?n(t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t))}(window,MediaSession),MediaSession}));
@@ -1 +1 @@
1
- !function(e,s){"object"==typeof exports&&"undefined"!=typeof module?module.exports=s():"function"==typeof define&&define.amd?define(s):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.message=s())}(this,(function(){"use strict";const e=/<trans(.*)trans>/;class s{init(t,n,o){let i="";o.on("message:show",(function(s){var t,a,d;const f=null===(t=s.data)||void 0===t?void 0:t.sticky,l=null===(a=s.data)||void 0===a?void 0:a.timeout;let c=(null===(d=s.data)||void 0===d?void 0:d.message)||"";if(c==i)return;if(i=c||"",e.test(c)){const s=e.exec(c)||["",""];c=o.i18n(s[1].trim())}const u=document.createElement("div");u.classList.add("fp-message");const r=document.createElement("p");r.innerText=c,u.append(r),n.append(u),setTimeout((function(){u.classList.add("fp-shown")}),100),f||setTimeout((function(){o.emit("message:dismiss",u)}),l)})),o.on("message:dismiss",(function(e){const s=e.data;s&&(s.classList.remove("fp-shown"),setTimeout((function(){s.remove()}),1e3))})),o.message={events:s.events}}}return s.events={SHOW_MESSAGE:"message:show",DISMISS_MESSAGE:"message:dismiss"},function(e,s){if("object"==typeof exports&&"undefined"!=typeof module)return s;"flowplayer"in e||(e.flowplayer={extensions:[]});const t=e.flowplayer;"function"==typeof t?t(s):(Array.isArray(t.extensions)||(t.extensions=[]),~t.extensions.indexOf(s)||t.extensions.push(s))}(window,s),s}));
1
+ !function(e,s){"object"==typeof exports&&"undefined"!=typeof module?module.exports=s():"function"==typeof define&&define.amd?define(s):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.message=s())}(this,(function(){"use strict";const e=/<trans(.*)trans>/;class Message{init(s,t,n){let o="";n.on("message:show",(function(s){var i,a,d;const f=null===(i=s.data)||void 0===i?void 0:i.sticky,l=null===(a=s.data)||void 0===a?void 0:a.timeout;let c=(null===(d=s.data)||void 0===d?void 0:d.message)||"";if(c==o)return;if(o=c||"",e.test(c)){const s=e.exec(c)||["",""];c=n.i18n(s[1].trim())}const u=document.createElement("div");u.classList.add("fp-message");const r=document.createElement("p");r.innerText=c,u.append(r),t.append(u),setTimeout((function(){u.classList.add("fp-shown")}),100),f||setTimeout((function(){n.emit("message:dismiss",u)}),l)})),n.on("message:dismiss",(function(e){o="";const s=e.data;s&&(s.classList.remove("fp-shown"),setTimeout((function(){s.remove()}),1e3))})),n.message={events:Message.events}}}return Message.events={SHOW_MESSAGE:"message:show",DISMISS_MESSAGE:"message:dismiss"},function(e,s){if("object"==typeof exports&&"undefined"!=typeof module)return s;"flowplayer"in e||(e.flowplayer={extensions:[]});const t=e.flowplayer;"function"==typeof t?t(s):(Array.isArray(t.extensions)||(t.extensions=[]),~t.extensions.indexOf(s)||t.extensions.push(s))}(window,Message),Message}));
package/plugins/ovp.js CHANGED
@@ -12,4 +12,4 @@
12
12
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13
13
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
14
  PERFORMANCE OF THIS SOFTWARE.
15
- ***************************************************************************** */const t=t=>"object"==typeof t&&null!==t&&!Array.isArray(t),e=(...n)=>n.reduce((n,o)=>t(o)?(Object.keys(o).forEach(i=>{if(t(n[i])&&t(o[i]))return n[i]=e(n[i],o[i]);n[i]=o[i]}),n):n,{});class n{constructor(t){this.data=t}static of(t){return new n(t)}static maybe(t,e,...n){return null==t?t:e.apply(t,[t,...n])}tap(t,...e){return t.apply(this,[this.data,...e]),new n(this.data)}fmap(t,...e){const o=t.apply(this,[this.data,...e]);return new n(o)}unwrap(){return this.data}}function o(t){return fetch(t).then(t=>t.json())}function i(){let t=[].join.call(arguments,"/");return"/"!==t[0]&&(t="/"+t),a()+"/web/public/native/config"+t}const a=()=>"https://ljsp.lwcdn.com";function r(t){return~t.indexOf("/")?t:"/media/"+t}var s={404:"media not found",402:"invalid subscription",400:"bad request",415:"unsupported media type"};function l(t){const e=t.ima,n=t.duration;if(!e||!n)return t;const o=null==e?void 0:e.ads;return Array.isArray(o)&&(e.ads=o.map((function(t){return"number"==typeof t.percentage&&(t.time=t.percentage*n),t}))),t}function c(t,n){var o,i;n="object"==typeof n?n:{};const a={title:null===(o=null==t?void 0:t.metadata)||void 0===o?void 0:o.title,description:null===(i=null==t?void 0:t.metadata)||void 0===i?void 0:i.description},r={ima:{parameters:function({media_id:t,duration:e,title:n,tags:o,category_name:i,ad_keywords:a}){return{ad_keywords:a||"",media_id:t||"",category:i||"",media_name:n||"",media_tags:o||"",media_duration:e||-1}}((null==t?void 0:t.metadata)||{})}},s=n.embed||{};return delete s.src,e(r,a,t,(delete(l=n).src,delete l.metadata,delete l.title,delete l.description,delete l.duration,delete l.poster,l),s);var l}const d=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/;function u(t){return"object"==typeof t&&"ovp/base64"==t.type}function p(t,e){return function(t,e){return!(~t.indexOf(".")||!d.test(t))&&(e.type="video/ovp",!0)}(t,e)||u(e)}function f(t){try{return function(t){return null===t?{}:JSON.parse(t)}(decodeURIComponent(atob(t).split("").map((function(t){return"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2)})).join("")))}catch(t){return{err:t.message}}}function m(t){const e=t.split(/[^0-9]/).map(t=>parseInt(t,10));return Date.UTC(e[0],e[1]-1,e[2],e[3],e[4],e[5])}function v(t){return t.live}var y=Object.freeze({__proto__:null,OVP_ERROR:"ovp:error",OVP_MEDIA_REQUEST_START:"ovp:request:start",OVP_MEDIA_REQUEST_COMPLETE:"ovp:request:media:complete",OVP_PLAYLIST_REQUEST_COMPLETE:"ovp:request:playlist:complete",LIVE_COUNTDOWN_TICK:"ovp:live:countdown:tick",LIVE_COUNTDOWN_START:"ovp:live:countdown:start",LIVE_COUNTDOWN_COMPLETE:"ovp:live:countdown:complete",OVP_MEDIA_CHANGED:"ovp:media:changed",OVP_REALTIME_MESSAGE:"ovp:message:realtime"});function _(t,e){const o=null==e?void 0:e.src;if(u(e))return function(t,e){const n=f(e.src||"");if(function(t){return"string"==typeof t.err}(n))return console.error(n.err);h(t,n)}(t,e);o&&n.of(o).fmap(r).fmap(i).fmap(t=>fetch(t)).fmap(e=>e.then(t=>Promise.all([t.status,t.json()])).then(([e,n])=>200==e?h(t,n):g(t,n)))}function h(t,o){return t.emit("ovp:media:changed",o),function(t){return Array.isArray(t.playlist)}(o)?function(t,n){if("function"!=typeof window.flowplayer.playlist)return console.warn("OVP responded with Playlist media but the playlist plugin does not exist"),g(t,{status:415});t.emit("ovp:request:playlist:complete",function(t,n){const o=Object.assign({},t),i=(null==t?void 0:t.playlist)||{},a=e(n,i),r=((null==a?void 0:a.playlist)||[]).map(t=>c(t,o));return Object.assign(a,{playlist:r})}(t.opts,n))}(t,o):v(o)?function(t,e){var o,i;const a=(null===(o=null==e?void 0:e.metadata)||void 0===o?void 0:o.live_start_time)||(null===(i=null==e?void 0:e.metadata)||void 0===i?void 0:i.starttime);a&&(e.live_start_time=n.of(a).fmap(m).unwrap());t.emit("ovp:live:countdown:start",n.of(e).fmap(c,t.opts).fmap(l).unwrap())}(t,o):function(t,e){t.emit("ovp:request:media:complete",n.of(e).fmap(c,t.opts).fmap(l).unwrap())}(t,o)}function g(t,e){return e.message?t.emit("ovp:error",e):e.status?t.emit("ovp:error",new Error(s[e.status])):t.emit("ovp:error",e)}const w={};function b(t,e,n){"object"!=typeof w[e]&&(w[e]=n);const o=t.opts,i=(null==o?void 0:o.metadata)||{};i.player_id=e,o.metadata=i,n.title&&delete n.title,n.description&&delete n.description;const a=Object.assign(o,n);t.setOpts(a),n.autoplay&&t.togglePlay(!0)}let O=!1;function E(t,e,a){j()||n.of("recommendation").fmap(i,e,a).fmap(o).fmap(e=>e.then(e=>function(t,e){const n=e.playlist;if(t.opts.recommendations=n,!n.length)return;t.emit("recommendationsready",{playlist:n.map((function(t){var e;return{poster:t.poster,src:t.src,title:null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.title,metadata:t.metadata||{}}}))})}(t,e)).catch(A))}function j(){return O}function A(t){O=!0,console.error("Failed to load recommendations: %j",t)}class T{constructor(t){this.manualDisconnect=!1,this.video=t,this.onClose=this.onClose.bind(this),this.onMessage=this.onMessage.bind(this)}static of(t){return new T(t)}connect(t){this.client=new WebSocket("wss://player.ws.flowplayer.com?mediaId="+t),this.current_media_id=t,this.wireup()}onClose(){this.manualDisconnect?this.manualDisconnect=!1:this.current_media_id&&this.reconnect(this.current_media_id)}onMessage(t){JSON.parse(t.data).forEach(t=>{this.video.emit("ovp:message:realtime",t)})}reconnect(t){this.cleanup(),this.connect(t)}wireup(){this.client&&(this.client.addEventListener("message",this.onMessage),this.client.addEventListener("close",this.onClose))}cleanup(){this.client&&(this.client.removeEventListener("message",this.onMessage),this.client.removeEventListener("close",this.onClose),this.client=void 0)}disconnect(){this.client&&(this.manualDisconnect=!0,this.client.close())}}class P{onload(t,e,n,o){if("string"==typeof o.src)return"string"!=typeof t.player_id||0===o.src.indexOf(t.player_id)||u(o)||(o.src=[t.player_id,o.src].join("/")),_(n,o)}wants(t,e,n){return p(t,e)}init(t,a,r){const s=new T(r);let l=Object.assign({},t);const c=function(t){if(!l)return t;delete l.src;const n=e(t,l);return l=!1,n};r.on("ovp:error",(function(t){r.emit("error",t.data)})),r.on("ovp:request:start",(function(){r.setState("is-waiting",!0),t.recommendations&&(t.recommendations=!1)})),r.on("ovp:media:changed",(function({data:t}){var e;const n=null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.media_id;(null==t?void 0:t.live)&&n&&(s.disconnect(),s.connect(n))})),r.on("ovp:message:realtime",(function({data:e}){var n;const o=null==e?void 0:e.event,i=null==e?void 0:e.value,a=r.opt("metadata",{live_start_time:""});switch(o){case"METADATA":{const e=Object.assign(a,i),o=Object.assign(t,{metadata:e});o.live&&(null===(n=null==o?void 0:o.metadata)||void 0===n?void 0:n.live_start_time)&&(o.live_start_time=m(o.metadata.live_start_time)),r.setOpts(o);break}}})),r.on("beforeplay",(function(e){const n=t;if(v(n)){if(C(n))return;e.preventDefault()}})),r.on("ovp:request:media:complete",(function(t){const e=t.data;if(!e)return;if(0==r.reaper||"object"!=typeof t.data||function(t){return t&&t.live_start_time&&t.live_start_time-Date.now()>0}(t.data))return;const n=c(e);r.setOpts(n),n.src&&r.setSrc(n.src),n.autoplay&&r.togglePlay(!0)})),r.on("config",(function({data:e}){var s;const l=null==e?void 0:e.brand_color;if(l&&function(t,e){t.style.setProperty("--fp-brand-color",e)}(a,l),!("string"==typeof t.src&&p(t.src,{})||t.src&&S(t.src)))return"string"==typeof t.player_id&&(null===(s=null==t?void 0:t.metadata)||void 0===s?void 0:s.player_id)!==t.player_id?function(t,e){if("object"==typeof w[e])return console.debug("using Cache(%s)",e),b(t,e,w[e]);n.of(e).fmap(i).fmap(o).fmap(n=>n.then(n=>b(t,e,n)).catch(console.error))}(r,t.player_id):void 0})),r.on("ovp:request:playlist:complete",(function(t){const e=t.data;if(!e||0==r.reaper)return;const{playlist:n}=e,o=function(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(t);i<o.length;i++)e.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(t,o[i])&&(n[o[i]]=t[o[i]])}return n}(e,["playlist"]),i=c({playlist:o});r.setOpts(i);const a={type:"flowplayer/playlist",items:n};r.setSrc(a)})),r.on("ovp:live:countdown:start",(function(e){const n=e.data;if(!n||0==r.reaper)return;const o=c(n);r.setOpts(o),r.render("live/countdown",[t,a,r])})),r.on("timeupdate",(function(){var e,n,o;const i=t;v(i)?C(i)||(r.togglePlay(!1),r.emit("ended")):t.recommendations&&((null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.media_id)||Array.isArray(t.recommendations)||r.currentTime/r.duration<.8||j()||(null===(n=null==t?void 0:t.metadata)||void 0===n?void 0:n.media_id)&&(null===(o=null==t?void 0:t.metadata)||void 0===o?void 0:o.player_id)&&E(r,t.metadata.media_id,t.metadata.player_id))})),r.on("reap",(function(){s.disconnect()}))}}function C(t){var e,n;const o=null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.live_stop_time;if(!o)return;return(null===(n=null==t?void 0:t.metadata)||void 0===n?void 0:n.allow_after_stop_time)?void 0:m(o)>Date.now()}P.events=y;const S=t=>{var e;if(t&&Array.isArray(t))return"object"==typeof t[0]&&"ovp/base64"===(null===(e=t[0])||void 0===e?void 0:e.type)};return function(t,e){if("object"==typeof exports&&"undefined"!=typeof module)return e;"flowplayer"in t||(t.flowplayer={extensions:[]});const n=t.flowplayer;"function"==typeof n?n(e):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(e)||n.extensions.push(e))}(window,P),P}));
15
+ ***************************************************************************** */const t=t=>"object"==typeof t&&null!==t&&!Array.isArray(t),e=(...n)=>n.reduce((n,o)=>t(o)?(Object.keys(o).forEach(i=>{if(t(n[i])&&t(o[i]))return n[i]=e(n[i],o[i]);n[i]=o[i]}),n):n,{});class Pipe{constructor(t){this.data=t}static of(t){return new Pipe(t)}static maybe(t,e,...n){return null==t?t:e.apply(t,[t,...n])}tap(t,...e){return t.apply(this,[this.data,...e]),new Pipe(this.data)}fmap(t,...e){const n=t.apply(this,[this.data,...e]);return new Pipe(n)}unwrap(){return this.data}}function n(t){return fetch(t).then(t=>t.json())}function o(){let t=[].join.call(arguments,"/");return"/"!==t[0]&&(t="/"+t),i()+"/web/public/native/config"+t}const i=()=>"https://ljsp.lwcdn.com";function r(t){return~t.indexOf("/")?t:"/media/"+t}var s={404:"media not found",402:"invalid subscription",400:"bad request",415:"unsupported media type"};function a(t){const e=t.ima,n=t.duration;if(!e||!n)return t;const o=null==e?void 0:e.ads;return Array.isArray(o)&&(e.ads=o.map((function(t){return"number"==typeof t.percentage&&(t.time=t.percentage*n),t}))),t}function l(t,n){var o,i;n="object"==typeof n?n:{};const r={title:null===(o=null==t?void 0:t.metadata)||void 0===o?void 0:o.title,description:null===(i=null==t?void 0:t.metadata)||void 0===i?void 0:i.description},s={ima:{parameters:function({media_id:t,duration:e,title:n,tags:o,category_name:i,ad_keywords:r}){return{ad_keywords:r||"",media_id:t||"",category:i||"",media_name:n||"",media_tags:o||"",media_duration:e||-1}}((null==t?void 0:t.metadata)||{})}},a=n.embed||{};return delete a.src,e(s,r,t,(delete(l=n).src,delete l.metadata,delete l.title,delete l.description,delete l.duration,delete l.poster,l),a);var l}const c=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/;function d(t){return"object"==typeof t&&"ovp/base64"==t.type}function u(t,e){return function(t,e){return!(~t.indexOf(".")||!c.test(t))&&(e.type="video/ovp",!0)}(t,e)||d(e)}function p(t){try{return function(t){return null===t?{}:JSON.parse(t)}(decodeURIComponent(atob(t).split("").map((function(t){return"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2)})).join("")))}catch(t){return{err:t.message}}}function m(t){const e=t.split(/[^0-9]/).map(t=>parseInt(t,10));return Date.UTC(e[0],e[1]-1,e[2],e[3],e[4],e[5])}function f(t){return t.live}var v=Object.freeze({__proto__:null,OVP_ERROR:"ovp:error",OVP_MEDIA_REQUEST_START:"ovp:request:start",OVP_MEDIA_REQUEST_COMPLETE:"ovp:request:media:complete",OVP_PLAYLIST_REQUEST_COMPLETE:"ovp:request:playlist:complete",LIVE_COUNTDOWN_TICK:"ovp:live:countdown:tick",LIVE_COUNTDOWN_START:"ovp:live:countdown:start",LIVE_COUNTDOWN_COMPLETE:"ovp:live:countdown:complete",OVP_MEDIA_CHANGED:"ovp:media:changed",OVP_REALTIME_MESSAGE:"ovp:message:realtime"});function y(t,e){const n=null==e?void 0:e.src;if(d(e))return function(t,e){const n=p(e.src||"");if(function(t){return"string"==typeof t.err}(n))return console.error(n.err);h(t,n)}(t,e);n&&Pipe.of(n).fmap(r).fmap(o).fmap(t=>fetch(t)).fmap(e=>e.then(t=>Promise.all([t.status,t.json()])).then(([e,n])=>200==e?h(t,n):w(t,n)))}function h(t,n){return t.emit("ovp:media:changed",n),function(t){return Array.isArray(t.playlist)}(n)?function(t,n){if("function"!=typeof window.flowplayer.playlist)return console.warn("OVP responded with Playlist media but the playlist plugin does not exist"),w(t,{status:415});t.emit("ovp:request:playlist:complete",function(t,n){const o=Object.assign({},t),i=(null==t?void 0:t.playlist)||{},r=e(n,i),s=((null==r?void 0:r.playlist)||[]).map(t=>l(t,o));return Object.assign(r,{playlist:s})}(t.opts,n))}(t,n):f(n)?function(t,e){var n,o;const i=(null===(n=null==e?void 0:e.metadata)||void 0===n?void 0:n.live_start_time)||(null===(o=null==e?void 0:e.metadata)||void 0===o?void 0:o.starttime);i&&(e.live_start_time=Pipe.of(i).fmap(m).unwrap());t.emit("ovp:live:countdown:start",Pipe.of(e).fmap(l,t.opts).fmap(a).unwrap())}(t,n):function(t,e){t.emit("ovp:request:media:complete",Pipe.of(e).fmap(l,t.opts).fmap(a).unwrap())}(t,n)}function w(t,e){return e.message?t.emit("ovp:error",e):e.status?t.emit("ovp:error",new Error(s[e.status])):t.emit("ovp:error",e)}const _={};function g(t,e,n){"object"!=typeof _[e]&&(_[e]=n);const o=t.opts,i=(null==o?void 0:o.metadata)||{};i.player_id=e,o.metadata=i,n.title&&delete n.title,n.description&&delete n.description;const r=Object.assign(o,n);t.setOpts(r),n.autoplay&&t.togglePlay(!0)}let b=!1;function O(t,e,i){E()||Pipe.of("recommendation").fmap(o,e,i).fmap(n).fmap(e=>e.then(e=>function(t,e){const n=e.playlist;if(t.opts.recommendations=n,!n.length)return;t.emit("recommendationsready",{playlist:n.map((function(t){var e;return{poster:t.poster,src:t.src,title:null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.title,metadata:t.metadata||{}}}))})}(t,e)).catch(P))}function E(){return b}function P(t){b=!0,console.error("Failed to load recommendations: %j",t)}function j(t){const e="number"==typeof t?t:parseInt(t,10);return(e>9?"":"0")+e}function A(t,e){const n=t._customElements.get(e);return n&&t.root.querySelector(n)||void 0}const T="flowplayer-live-countdown";function C(t){return t&&t.live_start_time&&t.live_start_time-Date.now()>0}function L(t,e){let o=0;function r(){return function(t,e){const n=Date.now()-e;return Math.floor((t-n)/1e3)}(e.live_start_time||0,e.server_time_offset||0)}function s(){const n=r();if(n<0||isNaN(n)||0===t.reaper)return clearInterval(o),function(t,e){t.emit("ovp:live:countdown:complete");const n=A(t,T);n&&n.remove(),t.root.classList.remove("is-livecountdown"),t.emit("ovp:request:media:complete",e)}(t,e);var i,s,a;i=t,s=t.root,a=n,s.classList.add("is-livecountdown"),i.emit("ovp:live:countdown:tick",{remaining_time:x(a+1)}),i.hasState("is-starting")||i.setState("is-starting",!0)}var a;a=e,n(i()+"/web/public/countdown/time.json").then(t=>Object.assign(a,{server_time_offset:Date.now()-t.millisUtc})),s(),o=setInterval(s,250)}function x(t){const e=function(t){"number"!=typeof t&&(t=parseInt(t,10)),t=Math.round(t);const e=Math.floor(t/86400);t-=86400*e;const n=Math.floor(t/3600);t-=3600*n;const o=Math.floor(t/60);return{days:e,hours:n,minutes:o,seconds:t-=60*o}}(t);let n="";return e.days&&(n+=e.days+":"),n+j(e.hours)+":"+j(e.minutes)+":"+j(e.seconds)}class WebsocketBridge{constructor(t){this.manualDisconnect=!1,this.video=t,this.onClose=this.onClose.bind(this),this.onMessage=this.onMessage.bind(this)}static of(t){return new WebsocketBridge(t)}connect(t){this.client=new WebSocket("wss://player.ws.flowplayer.com?mediaId="+t),this.current_media_id=t,this.wireup()}onClose(){this.manualDisconnect?this.manualDisconnect=!1:this.current_media_id&&this.reconnect(this.current_media_id)}onMessage(t){JSON.parse(t.data).forEach(t=>{this.video.emit("ovp:message:realtime",t)})}reconnect(t){this.cleanup(),this.connect(t)}wireup(){this.client&&(this.client.addEventListener("message",this.onMessage),this.client.addEventListener("close",this.onClose))}cleanup(){this.client&&(this.client.removeEventListener("message",this.onMessage),this.client.removeEventListener("close",this.onClose),this.client=void 0)}disconnect(){this.client&&(this.manualDisconnect=!0,this.client.close())}}const M=(t,e)=>new(((t,e)=>{const n=t.get(e);if(!n)throw new Error(`no flowplayer component with the name ${e} exists`);const o=window.customElements.get(e);if(!o)throw new Error(`no default flowplayer component with the name ${e} exists`);const i=window.customElements.get(n);return"function"!=typeof i?o:i})(t._customElements,e))(t);class FlowplayerComponent extends HTMLElement{constructor(t){super(),this.player=t}}class FlowplayerLiveCountdown extends FlowplayerComponent{constructor(t){super(t),this.classList.add("fp-livecountdown");const e=function(...t){const e=document.createElement("div");return 0==t.length||e.classList.add(...t),e}("fp-inner");this.append(e);const n=document.createElement("p");n.innerText=t.i18n("ovp.starting_in"),e.append(n);const o=document.createElement("p");o.classList.add("fp-countdown"),e.append(o),t.on("ovp:live:countdown:tick",e=>{const n=e.detail.remaining_time;t.root.classList.add("is-livecountdown"),o.innerText=n})}}class OVP{constructor(t){((t,e,n)=>{window.customElements.get(e)||window.customElements.define(e,n),t.customElements.get(e)||t.customElements.set(e,e)})(t,T,FlowplayerLiveCountdown)}onload(t,e,n,o){if("string"==typeof o.src)return"string"!=typeof t.player_id||0===o.src.indexOf(t.player_id)||d(o)||(o.src=[t.player_id,o.src].join("/")),y(n,o)}wants(t,e,n){return u(t,e)}init(t,i,r){const s=new WebsocketBridge(r);let a=Object.assign({},t);const l=function(t){if(!a)return t;delete a.src;const n=e(t,a);return a=!1,n};r.on("ovp:error",(function(t){r.emit("error",t.data)})),r.on("ovp:request:start",(function(){r.setState("is-waiting",!0),t.recommendations&&(t.recommendations=!1)})),r.on("ovp:media:changed",(function({data:t}){var e;const n=null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.media_id;(null==t?void 0:t.live)&&n&&(s.disconnect(),s.connect(n))})),r.on("ovp:message:realtime",(function({data:e}){var n;const o=null==e?void 0:e.event,i=null==e?void 0:e.value,s=r.opt("metadata",{live_start_time:""});switch(o){case"METADATA":{const e=Object.assign(s,i),o=Object.assign(t,{metadata:e});o.live&&(null===(n=null==o?void 0:o.metadata)||void 0===n?void 0:n.live_start_time)&&(o.live_start_time=m(o.metadata.live_start_time)),r.setOpts(o);break}}})),r.on("beforeplay",(function(e){const n=t;if(f(n)){if(S(n))return;e.preventDefault()}})),r.on("ovp:request:media:complete",(function(t){const e=t.data;if(!e)return;if(0==r.reaper||"object"!=typeof t.data||C(t.data))return;const n=l(e);r.setOpts(n),r.setAttrs(n),n.src&&r.setSrc(n.src),n.autoplay&&r.togglePlay(!0)})),r.on("config",(function({data:e}){var i;if("string"==typeof t.src&&u(t.src,{}))return;if(t.src&&D(t.src))return;const s=null==e?void 0:e.brand_color;return s&&r.root.style.setProperty("--fp-brand-color","#"==s[0]?s:"#"+s),"string"==typeof t.player_id&&(null===(i=null==t?void 0:t.metadata)||void 0===i?void 0:i.player_id)!==t.player_id?function(t,e){if("object"==typeof _[e])return console.debug("using Cache(%s)",e),g(t,e,_[e]);Pipe.of(e).fmap(o).fmap(n).fmap(n=>n.then(n=>g(t,e,n)).catch(console.error))}(r,t.player_id):void 0})),r.on("ovp:request:playlist:complete",(function(t){const e=t.data;if(!e||0==r.reaper)return;const{playlist:n}=e,o=function(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(t);i<o.length;i++)e.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(t,o[i])&&(n[o[i]]=t[o[i]])}return n}(e,["playlist"]),i=l({playlist:o});Array.isArray(i.playlist)&&(i.playlist=o),r.setOpts(i);const s={type:"flowplayer/playlist",items:n};r.setSrc(s)})),r.on("ovp:live:countdown:start",(function(e){const n=e.data;if(!n||0==r.reaper)return;const o=l(n);if(r.setOpts(o),r.setAttrs(o),!C(n))return r.emit("ovp:request:media:complete",n);A(r,T)||(i.appendChild(M(r,T)),L(r,t))})),r.on("timeupdate",(function(){var e,n,o;const i=t;f(i)?S(i)||(r.togglePlay(!1),r.emit("ended")):t.recommendations&&((null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.media_id)||Array.isArray(t.recommendations)||r.currentTime/r.duration<.8||E()||(null===(n=null==t?void 0:t.metadata)||void 0===n?void 0:n.media_id)&&(null===(o=null==t?void 0:t.metadata)||void 0===o?void 0:o.player_id)&&O(r,t.metadata.media_id,t.metadata.player_id))})),r.on("reap",(function(){s.disconnect()}))}}function S(t){var e,n;const o=null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.live_stop_time;if(!o)return!0;return!!(null===(n=null==t?void 0:t.metadata)||void 0===n?void 0:n.allow_after_stop_time)||m(o)>Date.now()}OVP.events=v;const D=t=>{var e;if(t&&Array.isArray(t))return"object"==typeof t[0]&&"ovp/base64"===(null===(e=t[0])||void 0===e?void 0:e.type)};return function(t,e){if("object"==typeof exports&&"undefined"!=typeof module)return e;"flowplayer"in t||(t.flowplayer={extensions:[]});const n=t.flowplayer;"function"==typeof n?n(e):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(e)||n.extensions.push(e))}(window,OVP),OVP}));