@flowplayer/player 3.0.2 → 3.0.3-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/events.d.ts +1 -1
- package/core/events.js +2 -2
- package/core.js +2 -2
- package/default.js +2 -2
- package/embed.js +18 -18
- package/flowplayer.css +1 -1
- package/index.d.ts +0 -1
- package/package.json +4 -1
- package/plugins/chromecast.js +1 -1
- package/plugins/cuepoints.js +1 -1
- package/plugins/dash.js +1 -1
- package/plugins/fas.js +1 -1
- package/plugins/float-on-scroll.js +1 -1
- package/plugins/health.js +16 -1
- package/plugins/hls.js +1 -1
- package/plugins/keyboard.js +1 -1
- package/plugins/ovp.js +1 -1
- package/plugins/preview.js +1 -1
- package/plugins/subtitles.js +1 -1
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 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
|
+
!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}),r.fas=this)}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";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
|
|
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 s(t,n,o){0!=o.reaper&&o.floating&&r(o,n,e)}function r(t,n,o){const l=n.clientWidth,s=n.clientHeight;o&&t.emit(o),setTimeout((function(){const r=n.querySelector(".fp-float-wrapper");if(!r)return;const i=getComputedStyle(r),a=o===e?"auto":(r.clientWidth-parseFloat(i.paddingLeft)-parseFloat(i.paddingRight))/l*s+"px";r.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 i={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,i)}}),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,i){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,t.autopause&&i.setOpts({autopause:!1});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,i),was_user_toggled:!1};i.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}(i,"flowplayer-header");u&&function(e,t,o,l){const r=document.createElement("div");r.classList.add("fp-exit-float"),r.append(Object.assign(n(l,"flowplayer-close-icon"),{role:"button"}));const i=()=>{t.was_user_toggled=!0,l.togglePlay(!1),s(0,o,l)};r.addEventListener("click",i),e.append(r),setTimeout(()=>{const e=o.querySelector(".fp-ad-controls");if(!e)return;const t=r.cloneNode(!0);e.append(t),t.addEventListener("click",i)},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,i);const p=function(e,t){const n=e||60,o=Math.ceil(1e3/n);let l=Date.now(),s=-1;return function(...e){return s>-1||Date.now()<l||(s=requestAnimationFrame((function(){s=-1,t(),l=Date.now()+o}))),s}}(0,(function(){if(l(o)){if(i.hasState("is-fullscreen"))return;s(0,o,i)}})),f=function(){r(i,o)};i.on("viewleave",()=>{(function(e){return!e.paused||!(!e.ads||!e.ads.adPlaying)})(i)&&!c.was_user_toggled&&function(e,t,n){0==n.reaper||n.floating||r(n,t,"float:pop:out")}(0,o,i)}),i.on("viewenter",(function(){c.was_user_toggled=!1})),i.on("float:pop:out",(function(){window.addEventListener("scroll",p),i.floating=!0,i.setState("is-popped-out",!0),window.addEventListener("resize",f)})),i.on(e,(function(){window.removeEventListener("scroll",p),i.floating=!1,i.setState("is-popped-out",!1),window.removeEventListener("resize",f)}))}}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/health.js
CHANGED
|
@@ -1 +1,16 @@
|
|
|
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",
|
|
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",r="loadeddata",a="progress",d="loadstart",c="pause",l="playing",u="waiting",_="canplay",f="ended",h="seeked",p="seeking";function m(e){try{return!!new URL(e)}catch(e){return!1}}
|
|
2
|
+
/*! *****************************************************************************
|
|
3
|
+
Copyright (c) Microsoft Corporation.
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted.
|
|
7
|
+
|
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
9
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
10
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
11
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
12
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
13
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
+
***************************************************************************** */
|
|
16
|
+
function v(e,t,n,i){return new(n||(n=Promise))((function(o,s){function r(e){try{d(i.next(e))}catch(e){s(e)}}function a(e){try{d(i.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,a)}d((i=i.apply(e,t||[])).next())}))}const E=navigator;function y(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 R=[1e7]+""+-1e3+-4e3+-8e3+-1e11,O=()=>"undefined"==typeof crypto?"":R.replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16)),D="https://ljsp.lwcdn.com".concat("/web/public/countdown/time.json"),w=window,N=w._flowplayerTimekeeper||(w._flowplayerTimekeeper={});var T;!function(e){e[e.OFF=0]="OFF",e[e.ON=1]="ON",e[e.AUDIO_REQUIRED=2]="AUDIO_REQUIRED"}(T||(T={}));const A=e=>{switch(e){case!0:return T.ON;case!1:return T.OFF;default:return e}},I=O(),b=[];function S(e){const t=b.slice(0);b.length=0,0!=t.length&&(e.logger.log(`:dispatch events={${t.length}}`),g("https://health.flowplayer.com/v1/health/events",t))}function U(e,t,n){return v(this,void 0,void 0,(function*(){const i=yield C();b.push(Object.assign(t,i)),e.logger.log(":enqueue",t.event,t),b.length<10&&!n||S(e)}))}const k=()=>{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}},C=()=>v(void 0,void 0,void 0,(function*(){try{const e=yield function(){return v(this,void 0,void 0,(function*(){const e=N.cachedServerOffset;if(e)return e;const t=N.pendingRequest||(N.pendingRequest=fetch(D)),n=yield t,i=parseInt(n.headers.get("age")||"0"),o=yield n.json(),s=Date.now()-o.millisUtc-1e3*i;return N.cachedServerOffset=s,N.cachedServerOffset}))}();return{timestamp:Date.now()-e,adjustedTimestamp:!0}}catch(e){return{timestamp:Date.now(),adjustedTimestamp:!1}}})),x=(e,t)=>Object.assign(e,{detail:t}),M=(e,{event:t,media_session_id:n})=>({event:t,media_session_id:n,device_id:e.deviceId(),session_id:I,version:"3.0.3-rc.2",commit:"327a8ec27fc367bf10ecde8375237c65f312d2d3",ima_sdk_version:k(),preload:e.opt("preload"),autoplay:A(e.opt("autoplay")),live:e.opt("live"),source:e.original_src,downlink_mbs:y(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,external_media_id:e.opt("external_media_id")}),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 j(e,t,n,i){const o=M(t,{event:n,media_session_id:e.media_session_id}),{before:s,after:r}=i;U(e,((e,t,n)=>Object.assign(e,{state:{before:t,after:n}}))(o,B(s),B(r)))}var F;function L(e){switch(e){case F.MEDIA_PLAYBACK_ABORTED:return"media playback was aborted";case F.MEDIA_ERR_NETWORK:return"a network error occurred";case F.MEDIA_ERR_DECODE:return"unable to decode media content";case F.MEDIA_ERR_SRC_NOT_SUPPORTED:return"unsupported media type";case F.NO_INTERNET:return"no internet connection detected";case F.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"}(F||(F={}));const H=(e,t)=>{let n=null;return(...i)=>{null!==n&&(clearTimeout(n),n=null),n=setTimeout(()=>t(...i),e)}};class Health{constructor(e,t){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=O();const n=setInterval(()=>S(this),1e3);if(t.on("reap",()=>clearInterval(n)),!Health._UNLOAD_SUBSCRIBED){Health._UNLOAD_SUBSCRIBED=!0;const t=t=>e.instances.forEach(e=>e.emit(t.type));document.addEventListener("visibilitychange",e=>{"hidden"==document.visibilityState&&t(e)}),window.addEventListener("pagehide",t)}}init(t,v,E){!function(t){t.on(u,(function(n){t.seeking||t.networkState===t.NETWORK_LOADING&&t.readyState!==t.HAVE_NOTHING&&t.emit(e)}))}(E),E.on("health:record",({detail:e})=>{const t=M(E,{event:e.event,media_session_id:this.media_session_id});Object.assign(t,e.detail||{}),U(this,t)}),[_,d,n,s,r,a,u,e].forEach(e=>{E.on(e,e=>{U(this,M(E,{event:e.type,media_session_id:this.media_session_id}))})}),[l,c,p,h,f,i,o].forEach(e=>{E.on(e,e=>{U(this,M(E,{event:e.type,media_session_id:this.media_session_id}))})}),E.on("volumechange",H(800,e=>{const t=M(E,{event:e.type,media_session_id:this.media_session_id});U(this,x(t,{volume:parseFloat(E.volume.toFixed(2)),muted:E.muted}))})),E.on("resize",H(800,e=>{const t=M(E,{event:e.type,media_session_id:this.media_session_id});U(this,x(t,{height:v.clientHeight,width:v.clientWidth}))})),E.on("qualitychange",({type:e,detail:t})=>{switch(t.kind){case"hls":return j(this,E,e,t)}});let y=Date.now()+1e3;E.on("timeupdate",e=>{if(Date.now()<y)return;y=Date.now()+1e3;const t=M(E,{event:e.type,media_session_id:this.media_session_id});var n;U(this,x(t,{duration:(n=E.duration,Number.isFinite(n)?n:n===1/0?-1:void 0)}))}),E.addEventListener("error",e=>{const t=M(E,{event:e.type,media_session_id:this.media_session_id}),n=e.error||E.error;if(!n)return U(this,t,!0);const i=n.code,o={error_message:n.message||L(i),error_code:i,error_stack:n.stack||""};return U(this,x(t,o),!0)}),E.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(E.original_src))return;if(!m(n))return;if(n==E.original_src)return;this.media_session_id=O();U(this,M(E,{event:e.type,media_session_id:this.media_session_id})),S(this)}),E.on("visibilitychange",e=>{U(this,M(E,{event:e.type,media_session_id:this.media_session_id})),S(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
|
@@ -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"});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
|
|
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,s={is_audio_only:!1,fragDuration:-1};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 a=t.hls=new e(function(t){return Object.assign(Object.assign({autoStartLoad:!1},t.hls),{startPosition:t.start_time||-1})}(r));a.subtitleDisplay=!1,a.attachMedia(t),a.loadSource(i.src),t.emit("hls:attached",{hls:a}),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)})))}))}(a,t),f(a,t);const o=function(t){var e;const r=null===(e=t.data)||void 0===e?void 0:e.level;"number"==typeof r&&(a.levels[r]||-1===r?a.nextLevel=r:console.error(new Error("skipping invalid quality: "+t.data)))},l=function(t){var e;const r=null===(e=t.data)||void 0===e?void 0:e.id;"number"==typeof r&&r!=a.audioTrack&&setTimeout((function(){a.audioTrack=r}),0)};t.on("quality:set",o),t.on(u,l),t.on("src",(function(){t.hls&&t.hls.destroy(),t.off("quality:set",o),t.off(u,l)})),t.on("audioonlysource",(function(){s.is_audio_only=!0})),t.on("reap",(function(){a&&a.destroy()})),t.on("remotesession:started",()=>{t.hls&&t.hls.stopLoad()}),t.on("remotesession:ended",()=>{t.hls&&m(t)}),n&&a.on(e.Events.LEVEL_LOADED,(function(e,r){t.setOpts({live:r.details.live})})),a.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){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));if("none"===e.preload&&!e.autoplay)return;m(t,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})})),a.on(e.Events.INIT_PTS_FOUND,(function(t,e){s.fragDuration=e.frag.duration})),a.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,a.config)})),a.on(e.Events.LEVEL_PTS_UPDATED,(function(e,r){var i;if("video"!==r.type&&(!s.is_audio_only||"audio"!==r.type))return;const n=null===(i=null==r?void 0:r.details)||void 0===i?void 0:i.fragments;if(!n)return;const a=n[0].start||0,o=n[n.length-1].start+n[n.length-1].duration;t.emit("dvr/window",o-a)})),a.on(e.Events.LEVEL_SWITCHING,(e,r)=>{const i=a.levels[a.currentLevel],n=a.levels[r.level];t.emit("qualitychange",{before:i,after:n,kind:"hls"})});const h=t.opt("start_time");h&&t.once("loadedmetadata",(function(){t.currentTime=h})),"none"===r.preload&&t.once("beforeplay",()=>{m(t,r.start_time||-1)})}function m(t,e){var r;t.setState("is-loading",!0),null===(r=t.hls)||void 0===r||r.startLoad(e)}!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/keyboard.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.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.
|
|
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.hasState("is-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}));
|
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 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}));
|
|
15
|
+
***************************************************************************** */function t(t,e,n,o){return new(n||(n=Promise))((function(i,r){function s(t){try{l(o.next(t))}catch(t){r(t)}}function a(t){try{l(o.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((o=o.apply(t,e||[])).next())}))}const e=t=>"object"==typeof t&&null!==t&&!Array.isArray(t),n=(...t)=>t.reduce((t,o)=>e(o)?(Object.keys(o).forEach(i=>{if(e(t[i])&&e(o[i]))return t[i]=n(t[i],o[i]);t[i]=o[i]}),t):t,{});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}}const o="https://ljsp.lwcdn.com".concat("/web/public/countdown/time.json"),i=window,r=i._flowplayerTimekeeper||(i._flowplayerTimekeeper={});function s(t){return fetch(t).then(t=>t.json())}function a(){let t=[].join.call(arguments,"/");return"/"!==t[0]&&(t="/"+t),l()+"/web/public/native/config"+t}const l=()=>"https://ljsp.lwcdn.com";function c(e){(function(){return t(this,void 0,void 0,(function*(){const t=r.cachedServerOffset;if(t)return t;const e=r.pendingRequest||(r.pendingRequest=fetch(o)),n=yield e,i=parseInt(n.headers.get("age")||"0"),s=yield n.json(),a=Date.now()-s.millisUtc-1e3*i;return r.cachedServerOffset=a,r.cachedServerOffset}))})().then(t=>Object.assign(e,{server_time_offset:t}))}function d(t){return~t.indexOf("/")?t:"/media/"+t}var u={404:"media not found",402:"invalid subscription",400:"bad request",415:"unsupported media type"};function p(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 f(t,e){var o,i;e="object"==typeof e?e:{};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=e.embed||{};return delete a.src,n(s,r,t,(delete(l=e).src,delete l.metadata,delete l.title,delete l.description,delete l.duration,delete l.poster,l),a);var l}const m=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/;function v(t){return"object"==typeof t&&"ovp/base64"==t.type}function y(t,e){return function(t,e){return!(~t.indexOf(".")||!m.test(t))&&(e.type="video/ovp",!0)}(t,e)||v(e)}function h(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 w(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 _(t){return t.live}var g=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 b(t,e){const n=null==e?void 0:e.src;if(v(e))return function(t,e){const n=h(e.src||"");if(function(t){return"string"==typeof t.err}(n))return console.error(n.err);O(t,n)}(t,e);n&&Pipe.of(n).fmap(d).fmap(a).fmap(t=>fetch(t)).fmap(e=>e.then(t=>Promise.all([t.status,t.json()])).then(([e,n])=>200==e?O(t,n):E(t,n)))}function O(t,e){return t.emit("ovp:media:changed",e),function(t){return Array.isArray(t.playlist)}(e)?function(t,e){if("function"!=typeof window.flowplayer.playlist)return console.warn("OVP responded with Playlist media but the playlist plugin does not exist"),E(t,{status:415});t.emit("ovp:request:playlist:complete",function(t,e){const o=Object.assign({},t),i=(null==t?void 0:t.playlist)||{},r=n(e,i),s=((null==r?void 0:r.playlist)||[]).map(t=>f(t,o));return Object.assign(r,{playlist:s})}(t.opts,e))}(t,e):_(e)?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(w).unwrap());t.emit("ovp:live:countdown:start",Pipe.of(e).fmap(f,t.opts).fmap(p).unwrap())}(t,e):function(t,e){t.emit("ovp:request:media:complete",Pipe.of(e).fmap(f,t.opts).fmap(p).unwrap())}(t,e)}function E(t,e){return e.message?t.emit("ovp:error",e):e.status?t.emit("ovp:error",new Error(u[e.status])):t.emit("ovp:error",e)}const P={};function j(t,e,n){"object"!=typeof P[e]&&(P[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 A=!1;function T(t,e,n){L()||Pipe.of("recommendation").fmap(a,e,n).fmap(s).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(x))}function L(){return A}function x(t){A=!0,console.error("Failed to load recommendations: %j",t)}function S(t){const e="number"==typeof t?t:parseInt(t,10);return(e>9?"":"0")+e}function C(t,e){const n=t._customElements.get(e);return n&&t.root.querySelector(n)||void 0}const M="flowplayer-live-countdown";function D(t){return t&&t.live_start_time&&t.live_start_time-Date.now()>0}function I(t,e){let n=0;function o(){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 i(){const i=o();if(i<0||isNaN(i)||0===t.reaper)return clearInterval(n),function(t,e){t.emit("ovp:live:countdown:complete");const n=C(t,M);n&&n.remove(),t.root.classList.remove("is-livecountdown"),t.emit("ovp:request:media:complete",e)}(t,e);var r,s,a;r=t,s=t.root,a=i,s.classList.add("is-livecountdown"),r.emit("ovp:live:countdown:tick",{remaining_time:k(a+1)}),r.hasState("is-starting")||r.setState("is-starting",!0)}c(e),i(),n=setInterval(i,250)}function k(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+S(e.hours)+":"+S(e.minutes)+":"+S(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 q=(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,M,FlowplayerLiveCountdown)}onload(t,e,n,o){if("string"==typeof o.src)return"string"!=typeof t.player_id||0===o.src.indexOf(t.player_id)||v(o)||(o.src=[t.player_id,o.src].join("/")),b(n,o)}wants(t,e,n){return y(t,e)}init(t,e,o){const i=new WebsocketBridge(o);let r=Object.assign({},t);const l=function(t){if(!r)return t;delete r.src;const e=n(t,r);return r=!1,e};o.on("ovp:error",(function(t){o.emit("error",t.data)})),o.on("ovp:request:start",(function(){o.setState("is-waiting",!0),t.recommendations&&(t.recommendations=!1)})),o.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&&(i.disconnect(),i.connect(n))})),o.on("ovp:message:realtime",(function({data:e}){var n;const i=null==e?void 0:e.event,r=null==e?void 0:e.value,s=o.opt("metadata",{live_start_time:""});switch(i){case"METADATA":{const e=Object.assign(s,r),i=Object.assign(t,{metadata:e});i.live&&(null===(n=null==i?void 0:i.metadata)||void 0===n?void 0:n.live_start_time)&&(i.live_start_time=w(i.metadata.live_start_time)),o.setOpts(i);break}}})),o.on("beforeplay",(function(e){const n=t;if(_(n)){if(V(n))return;e.preventDefault()}})),o.on("ovp:request:media:complete",(function(t){const e=t.data;if(!e)return;if(0==o.reaper||"object"!=typeof t.data||D(t.data))return;const n=l(e);o.setOpts(n),o.setAttrs(n),n.src&&o.setSrc(n.src),n.autoplay&&o.togglePlay(!0)})),o.on("config",(function({data:n}){var i,r;if("string"==typeof t.src&&y(t.src,{}))return;if(t.src&&R(t.src))return;if((null==n?void 0:n.domains)&&(null==n?void 0:n.domains.length)&&!((t,e)=>{const n=t.split(".").reverse();return e.some(t=>{const e=t.split(".").reverse(),o="*"===e[e.length-1];return o&&e.pop(),(o||e.length===n.length)&&e.every((t,e)=>n[e]===t)})})(window.location.hostname,n.domains))return function({root:t,video:e,data:n}){e&&e.destroy(),console.error(new Error(n.details||n.reason)),t.innerHTML="",t.classList.remove("flowplayer"),t.classList.add("flowplayer-fatal"),t.innerHTML=`\n <h2>Playback Error</h2>\n <p>Are you the site owner?</p>\n <a class="troubleshoot" target="_blank" href="https://flowplayer.com/help/developers/troubleshooting#${n.reason}">Troubleshoot?</a>\n <img src=""https://flowplayer.com/user/pages/images/logo-white.png""/>\n `}({root:e,video:o,data:{details:`Hostname ${window.location.hostname} is not allowed to load player ${null===(i=n.metadata)||void 0===i?void 0:i.player_id}.`,reason:"domain"}});const l=null==n?void 0:n.brand_color;return l&&o.root.style.setProperty("--fp-brand-color","#"==l[0]?l:"#"+l),"string"==typeof t.player_id&&(null===(r=null==t?void 0:t.metadata)||void 0===r?void 0:r.player_id)!==t.player_id?function(t,e){if("object"==typeof P[e])return console.debug("using Cache(%s)",e),j(t,e,P[e]);Pipe.of(e).fmap(a).fmap(s).fmap(n=>n.then(n=>j(t,e,n)).catch(console.error))}(o,t.player_id):void 0})),o.on("ovp:request:playlist:complete",(function(t){const e=t.data;if(!e||0==o.reaper)return;const{playlist:n}=e,i=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"]),r=l({playlist:i});Array.isArray(r.playlist)&&(r.playlist=i),o.setOpts(r);const s={type:"flowplayer/playlist",items:n};o.setSrc(s)})),o.on("ovp:live:countdown:start",(function(n){const i=n.data;if(!i||0==o.reaper)return;const r=l(i);if(o.setOpts(r),o.setAttrs(r),!D(i))return o.emit("ovp:request:media:complete",i);C(o,M)||(e.appendChild(q(o,M)),I(o,t))})),o.on("timeupdate",(function(){var e,n,i;const r=t;_(r)?V(r)||(o.togglePlay(!1),o.emit("ended")):t.recommendations&&((null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.media_id)||Array.isArray(t.recommendations)||o.currentTime/o.duration<.8||L()||(null===(n=null==t?void 0:t.metadata)||void 0===n?void 0:n.media_id)&&(null===(i=null==t?void 0:t.metadata)||void 0===i?void 0:i.player_id)&&T(o,t.metadata.media_id,t.metadata.player_id))})),o.on("reap",(function(){i.disconnect()}))}}function V(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)||w(o)>Date.now()}OVP.events=g;const R=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}));
|
package/plugins/preview.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,
|
|
1
|
+
!function(e,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.preview=i())}(this,(function(){"use strict";var e=Object.freeze({__proto__:null,MOUSEOVER:1,MOBILE_VIEWPORT_VISIBLE:2,VIEWPORT_VISIBLE:4});class PreviewPlugin{init(e,i,t){t.on("config",({data:e})=>{e&&JSON.stringify(this.preview_config)!==JSON.stringify(e.preview)&&this.configure(e)}),this.root=i,this.player=t,this.configure(e)}configure(e){var i,t;if(null===(i=this.preview)||void 0===i||i.remove(),!e.preview||!e.poster)return;this.preview_config=Object.assign({},e.preview),this.createPreview(e.preview.src);const n=e.preview.trigger||3;(4&n||function(){const e="undefined"!=typeof document&&"undefined"!=typeof window,i=e?navigator.userAgent:"",t=/iP(hone|od)/i.test(i)&&!/iPad/.test(i)&&!/IEMobile/i.test(i),n=/Android/.test(i)&&!/Firefox/.test(i),r=/^((?!chrome|android).)*safari/i.test(i),o=/SamsungBrowser/.test(i),s=o&&/SMART-TV/.test(i);return{controls:!t,video:function(i){return e&&document.createElement("video").canPlayType(i)},lang:e&&window.navigator.language,android:n,iphone:t,safari:r,ios:e&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,samsung:o,samsung_tv:o&&s,touch:!!("ontouchstart"in window)}}().touch&&2&n)&&(null===(t=this.preview)||void 0===t||t.classList.add("in-viewport"))}createPreview(e){var i;if(!this.root||0===(null==e?void 0:e.length))return;if(this.preview=document.createElement("img"),this.preview.classList.add("fp-preview"),this.player&&(null===(i=function(e,i){const t=e._customElements.get(i);return t&&e.root.querySelector(t)||void 0}(this.player,"flowplayer-ui"))||void 0===i||i.prepend(this.preview)),!Array.isArray(e))return this.preview.setAttribute("src",e);const t=this.root.clientWidth;this.preview.src=e.reduce((e,i)=>Math.abs(i.dimensions.width-t)<Math.abs(e.dimensions.width-t)?i:e).src}}return PreviewPlugin.trigger=e,function(e,i){if("object"==typeof exports&&"undefined"!=typeof module)return i;"flowplayer"in e||(e.flowplayer={extensions:[]});const t=e.flowplayer;return"function"==typeof t?(t(i),i):(Array.isArray(t.extensions)||(t.extensions=[]),~t.extensions.indexOf(i)||t.extensions.push(i),i)}(window,PreviewPlugin)}));
|
package/plugins/subtitles.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.subtitles=t())}(this,(function(){"use strict";function e(e,t,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 t(e,t){e.innerHTML="",t.forEach((function(t){const n=document.createElement("pre");n.classList.add("fp-cue"),function(e,t){const n=e.style,o=t.size;n.setProperty("--caption-size",o.toString());const i=t.position;i&&"auto"!==i&&t?n.setProperty("--caption-position",i.toString()):n.removeProperty("--caption-position");const s="captions-align-"+t.align;Array.from(e.classList).forEach((function(n){n!=s&&("captions-vertical"==n&&t.vertical||n.startsWith("captions")&&e.classList.remove(n))})),e.classList.add(s),e.classList.toggle("captions-vertical",!!t.vertical)}(e,t),n.appendChild(t.getCueAsHTML()),e.appendChild(n)}))}var n;function o(e,t){if(function(e){return Object.values(n).includes(e)}(t=t||n.Anonymous))return"crossOrigin"in e?e.crossOrigin=t:e.setAttribute("crossorigin",t),e}function i(e){const t=document.createElement("a");return t.href=e,t.origin}function s(e,t){const n=document.createElement("track");n.className="fp-track renderable",n.kind=t.kind||"captions",n.id=["fp",t.lang].join("-");const s=n.track;return"string"!=typeof t.crossorigin&&function(e,t){try{return e.src.startsWith("blob:"),i(e.src)!==i(t)}catch(e){return console.error(e),!0}}(e,t.src)&&(o(e),t.crossorigin=e.getAttribute("crossorigin")),"crossorigin"in t&&o(e,t.crossorigin),Object.keys(t).forEach(e=>{n[e]=t[e]}),s.mode=t.default?"showing":t.mode||"disabled",n.onload=function(){},s.oncuechange=function(t){e.emit(t.type,{track:t.target})},e.appendChild(n),n}!function(e){e.Anonymous="anonymous",e.UseCredentials="use-credentials",e.Empty=""}(n||(n={}));function r(e){(function(){const e="undefined"!=typeof document&&"undefined"!=typeof window,t=e?navigator.userAgent:"",n=/iP(hone|od)/i.test(t)&&!/iPad/.test(t)&&!/IEMobile/i.test(t),o=/Android/.test(t)&&!/Firefox/.test(t),i=/^((?!chrome|android).)*safari/i.test(t),s=/SamsungBrowser/.test(t),r=s&&/SMART-TV/.test(t);return{controls:!n,video:function(t){return e&&document.createElement("video").canPlayType(t)},lang:e&&window.navigator.language,android:o,iphone:n,safari:i,ios:e&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,samsung:s,samsung_tv:s&&r,touch:!!("ontouchstart"in window)}})().ios&&(e.on("fullscreenenter",(function(){Array.from(e.textTracks).forEach((function(e){e.mode="hidden"===e.mode?"showing":"disabled"}))})),e.on("fullscreenexit",(function(){Array.from(e.textTracks).forEach((function(e){e.mode="showing"===e.mode?"hidden":"disabled"}))})))}const c=(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);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}const l="flowplayer-subtitles-menu",a="fp-on",u="fp-invis";class FlowplayerMenu extends FlowplayerComponent{constructor(e){super(e),this.player=e,this.menuContainer=document.createElement("details"),this.summaryEle=document.createElement("summary"),this.olEle=document.createElement("ol"),this.menu=document.createElement("div"),this.closeEle=document.createElement("span"),this.menu.classList.add("fp-menu"),this.menu.append(this.closeEle,this.olEle),this.closeEle.classList.add("fp-close"),this.closeEle.innerHTML="×",this.menuContainer.append(this.summaryEle,this.menu),this.menuContainer.addEventListener("click",(function(t){t.preventDefault();const n=this.open;n||(d(),document.active_menu=this),this.open=!n,e.root.classList.toggle("has-menu-opened",!n)})),this.append(this.menuContainer)}get options(){return this.olEle.querySelectorAll("li")}setMenuAttrs(e){if(this.className=`${e.class} ${u}`,this.menuContainer.classList.add("fp-menu-container"),this.menuContainer.setAttribute("aria-controls",e.id||Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)),this.menuContainer.setAttribute("aria-label",e.menuTitle||""),e.summaryTitle&&(this.summaryEle.textContent=e.summaryTitle),e.summaryIcon){const t=c(this.player,e.summaryIcon);t.setAttribute("tabindex",""),this.summaryEle.append(t)}if(e.menuTitle){const t=document.createElement("h3");t.textContent=e.menuTitle,this.menu.prepend(t)}this.menu.classList.toggle("fp-icons",!!e.icons),this.addEventListener(e.options_event,e=>{this.render(e.data)}),e.item_selected_event&&this.addEventListener(e.item_selected_event,e=>{void 0!==e.data&&this.select_item(e.data.selected_index)})}render(e){this.olEle&&(this.olEle.innerHTML="",e&&e.forEach(this.menuOption,this),this.classList.toggle(u,!(null==e?void 0:e.length)))}menuOption(e,t){const n=document.createElement("li");n.setAttribute("tabindex","0"),n.setAttribute("role","menuitem"),e.icon&&n.append(e.icon);const o=document.createElement("span");o.textContent=e.text,n.append(o),n.addEventListener("click",()=>{this.select_item(t),"function"==typeof e.onclick&&e.onclick()}),this.olEle.appendChild(n)}select_item(e){this.options.forEach((t,n)=>{t.classList.toggle(a,n===e&&(this.localName!==l||!t.classList.contains(a)))})}unselect_item(){this.options.forEach(e=>{e.classList.remove(a)})}}function d(){Array.from(document.querySelectorAll(".fp-engine")).forEach(e=>{const t=e.root.querySelector("details[open].fp-menu-container");t&&(t.open=!1,e.root.classList.toggle("has-menu-opened",!1))})}function m(e,t,n){const o=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(o),e}function f(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}document.addEventListener("click",(function(e){this.active_menu&&!e.composedPath().includes(this.active_menu)&&(d(),this.active_menu=void 0)})),function(){let e=!1;try{const t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("testPassive",null,t),window.removeEventListener("testPassive",null,t)}catch(e){}}();class Subtitles{constructor(e){((e,t,n)=>{window.customElements.get(t)||window.customElements.define(t,n),e.customElements.get(t)||e.customElements.set(t,t)})(e,l,FlowplayerMenu)}init(n,o,i){const a=c(i,l);a instanceof FlowplayerMenu&&a.setMenuAttrs({class:"fp-cc",summaryTitle:i.i18n("cc.button","CC"),menuTitle:i.i18n("cc.menu_title","Subtitles"),options_event:Subtitles.events.TRACKS,item_selected_event:Subtitles.events.SWITCH});const u=function(e){const t=document.createElement("div");return t.classList.add("fp-captions"),t.ontouchend=t=>e.emit(t.type),t.onclick=t=>e.emit(t.type),t}(i);let d,p=[],h=[];function y(e){var t;if(e==d)return v();v(),null===(t=i.root.querySelector(l))||void 0===t||t.summaryEle.classList.add("fp-color-text"),e.mode="hidden",d=e,i.emit("cuechange",{track:e})}function v(){var e;d&&(null===(e=i.root.querySelector(l))||void 0===e||e.summaryEle.classList.remove("fp-color-text"),d.mode="disabled",d=void 0,t(u,[]))}i.on("mount",(function(){var e;const t=f(i,"flowplayer-control");if(!t)return null===(e=f(i,"flowplayer-ui"))||void 0===e?void 0:e.appendChild(u);t.insertAdjacentElement("beforebegin",u),t.append(a),a instanceof FlowplayerMenu&&a.menuContainer.addEventListener("click",()=>{var e;1===h.length&&(null===(e=a.querySelector("li"))||void 0===e||e.click())})})),i.on("config",(function(e){var t,n;const o=null===(n=null===(t=e.data)||void 0===t?void 0:t.subtitles)||void 0===n?void 0:n.tracks;o&&p!==o&&(p=o,0===p.length&&(m(a,Subtitles.events.TRACKS,[]),v(),h=[]),Array.from(i.querySelectorAll(".fp-track")).forEach(e=>{i.removeChild(e)}),p.forEach(e=>s(i,e)))})),i.textTracks.addEventListener("addtrack",()=>{const t=Array.from(i.textTracks);if(h.length===t.length&&h.every((e,n)=>e===t[n]))return;let o;const s=t.filter((function(e){return~["captions","subtitles","descriptions"].indexOf(e.kind)})).map((function(e){return~["showing","hidden"].indexOf(e.mode)&&(o=e,e.mode="disabled"),e.oncuechange=e.oncuechange||function(e){i.emit(e.type,{track:e.target})},e}));m(a,Subtitles.events.TRACKS,s.map((function(e){return{text:e.label,onclick:y.bind(0,e)}}))),h=s;const r=e(n,"subtitles.show");if(o=(!1!==r?o:void 0)||h.find(e=>e.label===(null==d?void 0:d.label)),!o)return v();y(o),m(a,Subtitles.events.SWITCH,{selected_index:h.indexOf(o)})}),i.on("cuechange",(function(n){var o;const i=null===(o=n.data)||void 0===o?void 0:o.track,s=Array.from(e(i,"activeCues",[])).filter((e,t,n)=>t===n.findIndex(t=>e.id===t.id)).sort((e,t)=>"number"!=typeof e.line||"number"!=typeof t.line?0:e.line-t.line);t(u,s)})),r(i)}}return Subtitles.events={TRACKS:"subs:tracks",SWITCH:"subs:change"},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,Subtitles),Subtitles}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.subtitles=t())}(this,(function(){"use strict";function e(e,t,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 t(e,t){e.innerHTML="",t.forEach((function(t){const n=document.createElement("pre");n.classList.add("fp-cue"),function(e,t){const n=e.style,o=t.size;n.setProperty("--caption-size",o.toString());const i=t.position;i&&"auto"!==i&&t?n.setProperty("--caption-position",i.toString()):n.removeProperty("--caption-position");const s="captions-align-"+t.align;Array.from(e.classList).forEach((function(n){n!=s&&("captions-vertical"==n&&t.vertical||n.startsWith("captions")&&e.classList.remove(n))})),e.classList.add(s),e.classList.toggle("captions-vertical",!!t.vertical)}(e,t),n.appendChild(t.getCueAsHTML()),e.appendChild(n)}))}var n;function o(e,t){if(function(e){return Object.values(n).includes(e)}(t=t||n.Anonymous))return"crossOrigin"in e?e.crossOrigin=t:e.setAttribute("crossorigin",t),e}function i(e){const t=document.createElement("a");return t.href=e,t.origin}function s(e,t){const n=document.createElement("track");n.className="fp-track renderable",n.kind=t.kind||"captions",n.id=["fp",t.lang].join("-");const s=n.track;return"string"!=typeof t.crossorigin&&function(e,t){try{return e.src.startsWith("blob:"),i(e.src)!==i(t)}catch(e){return console.error(e),!0}}(e,t.src)&&(o(e),t.crossorigin=e.getAttribute("crossorigin")),"crossorigin"in t&&o(e,t.crossorigin),Object.keys(t).forEach(e=>{n[e]=t[e]}),s.mode=t.default?"showing":t.mode||"disabled",n.onload=function(){},s.oncuechange=function(t){e.emit(t.type,{track:t.target})},e.appendChild(n),n}!function(e){e.Anonymous="anonymous",e.UseCredentials="use-credentials",e.Empty=""}(n||(n={}));function r(e){(function(){const e="undefined"!=typeof document&&"undefined"!=typeof window,t=e?navigator.userAgent:"",n=/iP(hone|od)/i.test(t)&&!/iPad/.test(t)&&!/IEMobile/i.test(t),o=/Android/.test(t)&&!/Firefox/.test(t),i=/^((?!chrome|android).)*safari/i.test(t),s=/SamsungBrowser/.test(t),r=s&&/SMART-TV/.test(t);return{controls:!n,video:function(t){return e&&document.createElement("video").canPlayType(t)},lang:e&&window.navigator.language,android:o,iphone:n,safari:i,ios:e&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,samsung:s,samsung_tv:s&&r,touch:!!("ontouchstart"in window)}})().ios&&(e.on("fullscreenenter",(function(){Array.from(e.textTracks).forEach((function(e){e.mode="hidden"===e.mode?"showing":"disabled"}))})),e.on("fullscreenexit",(function(){Array.from(e.textTracks).forEach((function(e){e.mode="showing"===e.mode?"hidden":"disabled"}))})))}const c=(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);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}const l="flowplayer-subtitles-menu",a="fp-on",u="fp-invis";class FlowplayerMenu extends FlowplayerComponent{constructor(e){super(e),this.player=e,this.menuContainer=document.createElement("details"),this.summaryEle=document.createElement("summary"),this.olEle=document.createElement("ol"),this.menu=document.createElement("div"),this.closeEle=document.createElement("span"),this.menu.classList.add("fp-menu"),this.menu.append(this.closeEle,this.olEle),this.closeEle.classList.add("fp-close"),this.closeEle.innerHTML="×",this.menuContainer.append(this.summaryEle,this.menu),this.menuContainer.addEventListener("click",(function(t){t.preventDefault();const n=this.open;n||(d(),document.active_menu=this),this.open=!n,e.root.classList.toggle("has-menu-opened",!n)})),this.append(this.menuContainer)}get options(){return this.olEle.querySelectorAll("li")}setMenuAttrs(e){if(this.className=`${e.class} ${u}`,this.menuContainer.classList.add("fp-menu-container"),this.menuContainer.setAttribute("aria-controls",e.id||Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)),this.menuContainer.setAttribute("aria-label",e.menuTitle||""),e.summaryTitle&&(this.summaryEle.textContent=e.summaryTitle),e.summaryIcon){const t=c(this.player,e.summaryIcon);t.setAttribute("tabindex",""),this.summaryEle.append(t)}if(e.menuTitle){const t=document.createElement("h3");t.textContent=e.menuTitle,this.menu.prepend(t)}this.menu.classList.toggle("fp-icons",!!e.icons),this.addEventListener(e.options_event,e=>{this.render(e.data)}),e.item_selected_event&&this.addEventListener(e.item_selected_event,e=>{void 0!==e.data&&this.select_item(e.data.selected_index)})}render(e){this.olEle&&(this.olEle.innerHTML="",e&&e.forEach(this.menuOption,this),this.classList.toggle(u,!(null==e?void 0:e.length)))}menuOption(e,t){const n=document.createElement("li");n.setAttribute("tabindex","0"),n.setAttribute("role","menuitem"),e.icon&&n.append(e.icon);const o=document.createElement("span");o.textContent=e.text,n.append(o),n.addEventListener("click",()=>{this.select_item(t),"function"==typeof e.onclick&&e.onclick()}),this.olEle.appendChild(n)}select_item(e){this.options.forEach((t,n)=>{t.classList.toggle(a,n===e&&(this.localName!==l||!t.classList.contains(a)))})}unselect_item(){this.options.forEach(e=>{e.classList.remove(a)})}}function d(){Array.from(document.querySelectorAll(".fp-engine")).forEach(e=>{const t=e.root.querySelector("details[open].fp-menu-container");t&&(t.open=!1,e.root.classList.toggle("has-menu-opened",!1))})}function m(e,t,n){const o=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(o),e}function f(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}document.addEventListener("click",(function(e){this.active_menu&&!e.composedPath().includes(this.active_menu)&&(d(),this.active_menu=void 0)})),function(){let e=!1;try{const t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("testPassive",null,t),window.removeEventListener("testPassive",null,t)}catch(e){}}();class Subtitles{constructor(e){((e,t,n)=>{window.customElements.get(t)||window.customElements.define(t,n),e.customElements.get(t)||e.customElements.set(t,t)})(e,l,FlowplayerMenu)}init(n,o,i){const a=c(i,l);a instanceof FlowplayerMenu&&a.setMenuAttrs({class:"fp-cc",summaryTitle:i.i18n("cc.button","CC"),menuTitle:i.i18n("cc.menu_title","Subtitles"),options_event:Subtitles.events.TRACKS,item_selected_event:Subtitles.events.SWITCH});const u=function(e){const t=document.createElement("div");return t.classList.add("fp-captions"),t.ontouchend=t=>e.emit(t.type),t.onclick=t=>e.emit(t.type),t}(i);let d,p=[],h=[];function y(e){var t;if(e==d)return v();v(),null===(t=i.root.querySelector(l))||void 0===t||t.summaryEle.classList.add("fp-color-text"),e.mode="hidden",d=e,i.emit("cuechange",{track:e}),i.emit("tracks:text:updated",d)}function v(){var e;d&&(i.emit("tracks:text:updated"),null===(e=i.root.querySelector(l))||void 0===e||e.summaryEle.classList.remove("fp-color-text"),d.mode="disabled",d=void 0,t(u,[]))}i.on("mount",(function(){var e;const t=f(i,"flowplayer-control");if(!t)return null===(e=f(i,"flowplayer-ui"))||void 0===e?void 0:e.appendChild(u);t.insertAdjacentElement("beforebegin",u),t.append(a),a instanceof FlowplayerMenu&&a.menuContainer.addEventListener("click",()=>{var e;1===h.length&&(null===(e=a.querySelector("li"))||void 0===e||e.click())})})),i.on("config",(function(e){var t,n;const o=null===(n=null===(t=e.data)||void 0===t?void 0:t.subtitles)||void 0===n?void 0:n.tracks;o&&p!==o&&(p=o,0===p.length&&(m(a,Subtitles.events.TRACKS,[]),v(),h=[]),Array.from(i.querySelectorAll(".fp-track")).forEach(e=>{i.removeChild(e)}),p.forEach(e=>s(i,e)))})),i.textTracks.addEventListener("addtrack",()=>{const t=Array.from(i.textTracks);if(h.length===t.length&&h.every((e,n)=>e===t[n]))return;let o;const s=t.filter((function(e){return~["captions","subtitles","descriptions"].indexOf(e.kind)})).map((function(e){return~["showing","hidden"].indexOf(e.mode)&&(o=e,e.mode="disabled"),e.oncuechange=e.oncuechange||function(e){i.emit(e.type,{track:e.target})},e}));m(a,Subtitles.events.TRACKS,s.map((function(e){return{text:e.label,onclick:y.bind(0,e)}}))),h=s;const r=e(n,"subtitles.show");if(o=(!1!==r?o:void 0)||h.find(e=>e.label===(null==d?void 0:d.label)),!o)return v();y(o),m(a,Subtitles.events.SWITCH,{selected_index:h.indexOf(o)})}),i.on("cuechange",(function(n){var o;const i=null===(o=n.data)||void 0===o?void 0:o.track,s=Array.from(e(i,"activeCues",[])).filter((e,t,n)=>t===n.findIndex(t=>e.id===t.id)).sort((e,t)=>"number"!=typeof e.line||"number"!=typeof t.line?0:e.line-t.line);t(u,s)})),r(i)}}return Subtitles.events={TRACKS:"subs:tracks",SWITCH:"subs:change"},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,Subtitles),Subtitles}));
|