@flowplayer/player 3.2.2 → 3.2.4
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.js +1 -15
- package/default.js +1 -15
- package/embed.js +3 -17
- package/index.d.ts +3 -4
- package/package.json +2 -1
- package/plugin.d.ts +31 -0
- package/plugins/ads.js +2 -17
- package/plugins/analytics.js +1 -1
- package/plugins/chromecast.js +1 -16
- package/plugins/dash.js +1 -1
- package/plugins/health.js +1 -1
- package/plugins/ovp.js +1 -15
- package/plugins/preview.js +1 -1
- package/util/loader.d.ts +1 -1
package/plugins/health.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.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",h="ended",p="seeked",f="seeking";function m(e){try{return!!new URL(e)}catch(e){return!1}}function v(e,t){const n=function(){try{return localStorage.getItem("flowplayer/debug")}catch(e){return""}}(),i=(i,...o)=>{const s=(null==t?void 0:t.debug)||n;s&&e.match(s)&&console.log(`${e} -- ${i}`,...o)};return i.log=i,i}const E=navigator;function g(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 y(e,t){return function(e,t){return"function"==typeof navigator.sendBeacon&&navigator.sendBeacon(e,t)}(e,JSON.stringify({events:t}))}const R="https://ljsp.lwcdn.com".concat("/web/public/countdown/time.json"),O=window,I=O._flowplayerTimekeeper||(O._flowplayerTimekeeper={});var w;!function(e){e[e.OFF=0]="OFF",e[e.ON=1]="ON",e[e.AUDIO_REQUIRED=2]="AUDIO_REQUIRED"}(w||(w={}));const D=e=>{switch(e){case!0:return w.ON;case!1:return w.OFF;default:return e}},N=[];function T(e){if(e.suspended)return;const t=N.slice(0);N.length=0,0!=t.length&&(e.logger.log(`:dispatch events={${t.length}}`),y("https://ihi.flowplayer.com/v1/health/events",t))}async function A(e,t,n){const i=await S();N.push(Object.assign(t,i)),e.logger.log(":enqueue",t.event,t),N.length<10&&!n||T(e)}const b=()=>{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}},S=async()=>{try{const e=await async function(){const e=I.cachedServerOffset;if(e)return e;const t=I.pendingRequest||(I.pendingRequest=fetch(R)),n=await t,i=parseInt(n.headers.get("age")||"0"),o=await n.json(),s=Date.now()-o.millisUtc-1e3*i;return I.cachedServerOffset=s,I.cachedServerOffset}();return{timestamp:Date.now()-e,adjustedTimestamp:!0}}catch(e){return{timestamp:Date.now(),adjustedTimestamp:!1}}},U=(e,t)=>Object.assign(e,{detail:t}),k=(e,{event:t,media_session_id:n,session_id:i})=>({event:t,media_session_id:n,session_id:i,device_id:e.deviceId(),version:"3.2.
|
|
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",h="ended",p="seeked",f="seeking";function m(e){try{return!!new URL(e)}catch(e){return!1}}function v(e,t){const n=function(){try{return localStorage.getItem("flowplayer/debug")}catch(e){return""}}(),i=(i,...o)=>{const s=(null==t?void 0:t.debug)||n;s&&e.match(s)&&console.log(`${e} -- ${i}`,...o)};return i.log=i,i}const E=navigator;function g(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 y(e,t){return function(e,t){return"function"==typeof navigator.sendBeacon&&navigator.sendBeacon(e,t)}(e,JSON.stringify({events:t}))}const R="https://ljsp.lwcdn.com".concat("/web/public/countdown/time.json"),O=window,I=O._flowplayerTimekeeper||(O._flowplayerTimekeeper={});var w;!function(e){e[e.OFF=0]="OFF",e[e.ON=1]="ON",e[e.AUDIO_REQUIRED=2]="AUDIO_REQUIRED"}(w||(w={}));const D=e=>{switch(e){case!0:return w.ON;case!1:return w.OFF;default:return e}},N=[];function T(e){if(e.suspended)return;const t=N.slice(0);N.length=0,0!=t.length&&(e.logger.log(`:dispatch events={${t.length}}`),y("https://ihi.flowplayer.com/v1/health/events",t))}async function A(e,t,n){const i=await S();N.push(Object.assign(t,i)),e.logger.log(":enqueue",t.event,t),N.length<10&&!n||T(e)}const b=()=>{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}},S=async()=>{try{const e=await async function(){const e=I.cachedServerOffset;if(e)return e;const t=I.pendingRequest||(I.pendingRequest=fetch(R)),n=await t,i=parseInt(n.headers.get("age")||"0"),o=await n.json(),s=Date.now()-o.millisUtc-1e3*i;return I.cachedServerOffset=s,I.cachedServerOffset}();return{timestamp:Date.now()-e,adjustedTimestamp:!0}}catch(e){return{timestamp:Date.now(),adjustedTimestamp:!1}}},U=(e,t)=>Object.assign(e,{detail:t}),k=(e,{event:t,media_session_id:n,session_id:i})=>({event:t,media_session_id:n,session_id:i,device_id:e.deviceId(),version:"3.2.4",commit:"09aaca5c8c467df201b16246641f0c6087f7c75b",ima_sdk_version:b(),preload:e.opt("preload"),autoplay:D(e.opt("autoplay")),live:e.opt("live"),dvr:e.opt("dvr"),source:e.original_src,downlink_mbs:g(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")}),C=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 L(e,t,n,i){const o=k(t,e.eventInfo(n)),{before:s,after:r}=i;A(e,((e,t,n)=>Object.assign(e,{state:{before:t,after:n}}))(o,C(s),C(r)))}const M=[1e7]+""+-1e3+-4e3+-8e3+-1e11,B=()=>"undefined"==typeof crypto?"":M.replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16));var x;function j(e){switch(e){case x.MEDIA_PLAYBACK_ABORTED:return"media playback was aborted";case x.MEDIA_ERR_NETWORK:return"a network error occurred";case x.MEDIA_ERR_DECODE:return"unable to decode media content";case x.MEDIA_ERR_SRC_NOT_SUPPORTED:return"unsupported media type";case x.NO_INTERNET:return"no internet connection detected";case x.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"}(x||(x={}));const F=(e,t)=>{let n=null;return(...i)=>{null!==n&&(clearTimeout(n),n=null),n=setTimeout(()=>t(...i),e)}},H=B();class Health{constructor(e,t){this.session_id=H,this.suspended=!1,this.logger=v("health",t.opts),this.media_session_id=B(),this.analyticsLoop=setInterval(()=>T(this),2e3),t.on("reap",()=>clearInterval(this.analyticsLoop));const n=this;if(t.health={get media_session_id(){return n.media_session_id},set media_session_id(e){n.media_session_id=e},get session_id(){return n.session_id},set session_id(e){n.session_id=e},toggle(e){e?n.resume():n.suspend()}},!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)}}eventInfo(e){return{event:e,media_session_id:this.media_session_id,session_id:this.session_id}}suspend(){this.suspended=!0,clearInterval(this.analyticsLoop)}resume(){this.suspended=!1,this.analyticsLoop=setInterval(()=>T(this),2e3)}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=k(E,this.eventInfo(e.event));Object.assign(t,e.detail||{}),A(this,t)}),[_,d,n,s,r,a,u,e].forEach(e=>{E.on(e,e=>{A(this,k(E,this.eventInfo(e.type)))})}),[l,c,f,p,h,i,o].forEach(e=>{E.on(e,e=>{A(this,k(E,this.eventInfo(e.type)))})}),E.on("volumechange",F(800,e=>{const t=k(E,this.eventInfo(e.type));A(this,U(t,{volume:parseFloat(E.volume.toFixed(2)),muted:E.muted}))})),E.on("resize",F(800,e=>{const t=k(E,this.eventInfo(e.type));A(this,U(t,{height:v.clientHeight,width:v.clientWidth}))})),E.on("qualitychange",({type:e,detail:t})=>{switch(t.kind){case"hls":return L(this,E,e,t)}});let g=Date.now()+5e3;E.on("timeupdate",e=>{if(Date.now()<g)return;g=Date.now()+5e3;const t=k(E,this.eventInfo(e.type));var n;A(this,U(t,{duration:(n=E.duration,Number.isFinite(n)?n:n===1/0?-1:void 0)}))}),E.addEventListener("error",e=>{const t=k(E,this.eventInfo(e.type)),n=e.error||E.error;if(!n)return A(this,t,!0);const i=n.code,o={error_message:n.message||j(i),error_code:i,error_stack:n.stack||""};return A(this,U(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=B();A(this,k(E,this.eventInfo(e.type))),T(this)}),E.on("visibilitychange",e=>{A(this,k(E,this.eventInfo(e.type))),T(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/ovp.js
CHANGED
|
@@ -1,15 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((t="undefined"!=typeof globalThis?globalThis:t||self).flowplayer=t.flowplayer||{},t.flowplayer.ovp=e())}(this,(function(){"use strict";
|
|
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
|
-
***************************************************************************** */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}}const n="https://ljsp.lwcdn.com".concat("/web/public/countdown/time.json"),o=window,i=o._flowplayerTimekeeper||(o._flowplayerTimekeeper={});function r(t){return fetch(t).then(t=>t.json())}function a(){let t=[].join.call(arguments,"/");return"/"!==t[0]&&(t="/"+t),s()+"/web/public/native/config"+t}const s=()=>"https://ljsp.lwcdn.com";function l(t){(async function(){const t=i.cachedServerOffset;if(t)return t;const e=i.pendingRequest||(i.pendingRequest=fetch(n)),o=await e,r=parseInt(o.headers.get("age")||"0"),a=await o.json(),s=Date.now()-a.millisUtc-1e3*r;return i.cachedServerOffset=s,i.cachedServerOffset})().then(e=>Object.assign(t,{server_time_offset:e}))}function c(t){return~t.indexOf("/")?t:"/media/"+t}var d={404:"media not found",402:"invalid subscription",400:"bad request",415:"unsupported media type"};function u(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 p(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},a={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)||{})}},s=n.embed||{};return delete s.src,e(a,r,t,(delete(l=n).src,delete l.metadata,delete l.title,delete l.description,delete l.duration,delete l.poster,l),s);var l}const m=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/;function f(t){return"object"==typeof t&&"ovp/base64"==t.type}function v(t,e){return function(t,e){return!t.startsWith("blob:")&&(!(~t.indexOf(".")||!m.test(t))&&(e.type="video/ovp",!0))}(t,e)||f(e)}function y(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 h(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 w(t){return t.live}var _=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 g(t,e){const n=null==e?void 0:e.src;if(f(e))return function(t,e){const n=y(e.src||"");if(function(t){return"string"==typeof t.err}(n))return console.error(n.err);b(t,n)}(t,e);n&&Pipe.of(n).fmap(c).fmap(a).fmap(t=>fetch(t)).fmap(e=>e.then(t=>Promise.all([t.status,t.json()])).then(([e,n])=>200==e?b(t,n):E(t,n)))}function b(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"),E(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),a=((null==r?void 0:r.playlist)||[]).map(t=>p(t,o));return Object.assign(r,{playlist:a})}(t.opts,n))}(t,n):w(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(h).unwrap());t.emit("ovp:live:countdown:start",Pipe.of(e).fmap(p,t.opts).fmap(u).unwrap())}(t,n):function(t,e){t.emit("ovp:request:media:complete",Pipe.of(e).fmap(p,t.opts).fmap(u).unwrap())}(t,n)}function E(t,e){return e.message?t.emit("ovp:error",e):e.status?t.emit("ovp:error",new Error(d[e.status])):t.emit("ovp:error",e)}const O={};function P(t,e,n){"object"!=typeof O[e]&&(O[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 j=!1;function A(t,e,n){T()||Pipe.of("recommendation").fmap(a,e,n).fmap(r).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(L))}function T(){return j}function L(t){j=!0,console.error("Failed to load recommendations: %j",t)}function C(t){const e="number"==typeof t?t:parseInt(t,10);return(e>9?"":"0")+e}function x(t,e){const n=t._customElements.get(e);return n&&t.root.querySelector(n)||void 0}const S="flowplayer-live-countdown";function M(t){return t&&t.live_start_time&&t.live_start_time-Date.now()>0}function D(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=x(t,S);n&&n.remove(),t.root.classList.remove("is-livecountdown"),t.emit("ovp:request:media:complete",e)}(t,e);var r,a,s;r=t,a=t.root,s=i,a.classList.add("is-livecountdown"),r.emit("ovp:live:countdown:tick",{remaining_time:I(s+1)}),r.hasState("is-starting")||r.setState("is-starting",!0)}l(e),i(),n=setInterval(i,250)}function I(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+C(e.hours)+":"+C(e.minutes)+":"+C(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 k=(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})}}const q=["*.lwcdn.com","*.flowplayer.com"];function V(){try{return window.location.hostname!==window.parent.location.hostname?function(t){const e=document.createElement("a");return e.href=t,e}(document.referrer).hostname:document.location.hostname}catch(t){return window.location.hostname}}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,S,FlowplayerLiveCountdown)}onload(t,e,n,o){if("string"==typeof o.src)return"string"!=typeof t.player_id||0===o.src.indexOf(t.player_id)||f(o)||(o.src=[t.player_id,o.src].join("/")),g(n,o)}wants(t,e,n){return v(t,e)}init(t,n,o){const i=new WebsocketBridge(o);let s=Object.assign({},t);const l=function(t){if(!s)return t;delete s.src;const n=e(t,s);return s=!1,n};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,a=o.opt("metadata",{live_start_time:""});switch(i){case"METADATA":{const e=Object.assign(a,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=h(i.metadata.live_start_time)),o.setOpts(i);break}}})),o.on("beforeplay",(function(e){const n=t;if(w(n)){if(R(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||M(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:e}){var i,s;if("string"==typeof t.src&&v(t.src,{}))return;if(t.src&&N(t.src))return;if((null==e?void 0:e.domains)&&(null==e?void 0:e.domains.length)&&!((t,e)=>{const n=t.split(".").reverse();return e.concat(q).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)})})(V(),e.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.style.removeProperty("background-image");const o=document.createElement("h2");o.textContent="Playback Error";const i=document.createElement("p");i.textContent="Are you the site owner?";const r=document.createElement("a");r.classList.add("troubleshoot"),r.target="_blank",r.href="https://docs.flowplayer.com/troubleshooting/player#"+n.reason,r.textContent="Troubleshoot?";const a=document.createElement("img");a.src="https://flowplayer.com/user/pages/images/logo-white.png",t.append(o,i,r,a)}({root:n,video:o,data:{details:`Hostname ${window.location.hostname} is not allowed to load player ${null===(i=e.metadata)||void 0===i?void 0:i.player_id}.`,reason:"domain"}});const l=null==e?void 0:e.brand_color;return l&&o.root.style.setProperty("--fp-brand-color","#"==l[0]?l:"#"+l),"string"==typeof t.player_id&&(null===(s=null==t?void 0:t.metadata)||void 0===s?void 0:s.player_id)!==t.player_id?function(t,e){if("object"==typeof O[e])return console.debug("using Cache(%s)",e),P(t,e,O[e]);Pipe.of(e).fmap(a).fmap(r).fmap(n=>n.then(n=>P(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 a={type:"flowplayer/playlist",items:n};o.setSrc(a)})),o.on("ovp:live:countdown:start",(function(e){const i=e.data;if(!i||0==o.reaper)return;const r=l(i);if(o.setOpts(r),o.setAttrs(r),!M(i))return o.emit("ovp:request:media:complete",i);x(o,S)||(n.appendChild(k(o,S)),D(o,t))})),o.on("timeupdate",(function(){var e,n,i;const r=t;w(r)?R(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||T()||(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)&&A(o,t.metadata.media_id,t.metadata.player_id))})),o.on("reap",(function(){i.disconnect()}))}}function R(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)||h(o)>Date.now()}OVP.events=_;const N=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}));
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((t="undefined"!=typeof globalThis?globalThis:t||self).flowplayer=t.flowplayer||{},t.flowplayer.ovp=e())}(this,(function(){"use strict";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}}const n="https://ljsp.lwcdn.com".concat("/web/public/countdown/time.json"),o=window,i=o._flowplayerTimekeeper||(o._flowplayerTimekeeper={});function r(t){return fetch(t).then(t=>t.json())}function a(){let t=[].join.call(arguments,"/");return"/"!==t[0]&&(t="/"+t),s()+"/web/public/native/config"+t}const s=()=>"https://ljsp.lwcdn.com";function l(t){(async function(){const t=i.cachedServerOffset;if(t)return t;const e=i.pendingRequest||(i.pendingRequest=fetch(n)),o=await e,r=parseInt(o.headers.get("age")||"0"),a=await o.json(),s=Date.now()-a.millisUtc-1e3*r;return i.cachedServerOffset=s,i.cachedServerOffset})().then(e=>Object.assign(t,{server_time_offset:e}))}function c(t){return~t.indexOf("/")?t:"/media/"+t}var d={404:"media not found",402:"invalid subscription",400:"bad request",415:"unsupported media type"};function u(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 p(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},a={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)||{})}},s=n.embed||{};return delete s.src,e(a,r,t,(delete(l=n).src,delete l.metadata,delete l.title,delete l.description,delete l.duration,delete l.poster,l),s);var l}const m=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/;function f(t){return"object"==typeof t&&"ovp/base64"==t.type}function v(t,e){return function(t,e){return!t.startsWith("blob:")&&(!(~t.indexOf(".")||!m.test(t))&&(e.type="video/ovp",!0))}(t,e)||f(e)}function y(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 h(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 w(t){return t.live}var _=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 g(t,e){const n=null==e?void 0:e.src;if(f(e))return function(t,e){const n=y(e.src||"");if(function(t){return"string"==typeof t.err}(n))return console.error(n.err);b(t,n)}(t,e);n&&Pipe.of(n).fmap(c).fmap(a).fmap(t=>fetch(t)).fmap(e=>e.then(t=>Promise.all([t.status,t.json()])).then(([e,n])=>200==e?b(t,n):E(t,n)))}function b(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"),E(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),a=((null==r?void 0:r.playlist)||[]).map(t=>p(t,o));return Object.assign(r,{playlist:a})}(t.opts,n))}(t,n):w(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(h).unwrap());t.emit("ovp:live:countdown:start",Pipe.of(e).fmap(p,t.opts).fmap(u).unwrap())}(t,n):function(t,e){t.emit("ovp:request:media:complete",Pipe.of(e).fmap(p,t.opts).fmap(u).unwrap())}(t,n)}function E(t,e){return e.message?t.emit("ovp:error",e):e.status?t.emit("ovp:error",new Error(d[e.status])):t.emit("ovp:error",e)}const O={};function P(t,e,n){"object"!=typeof O[e]&&(O[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 j=!1;function A(t,e,n){T()||Pipe.of("recommendation").fmap(a,e,n).fmap(r).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(L))}function T(){return j}function L(t){j=!0,console.error("Failed to load recommendations: %j",t)}function C(t){const e="number"==typeof t?t:parseInt(t,10);return(e>9?"":"0")+e}function x(t,e){const n=t._customElements.get(e);return n&&t.root.querySelector(n)||void 0}const S="flowplayer-live-countdown";function M(t){return t&&t.live_start_time&&t.live_start_time-Date.now()>0}function D(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=x(t,S);n&&n.remove(),t.root.classList.remove("is-livecountdown"),t.emit("ovp:request:media:complete",e)}(t,e);var r,a,s;r=t,a=t.root,s=i,a.classList.add("is-livecountdown"),r.emit("ovp:live:countdown:tick",{remaining_time:I(s+1)}),r.hasState("is-starting")||r.setState("is-starting",!0)}l(e),i(),n=setInterval(i,250)}function I(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+C(e.hours)+":"+C(e.minutes)+":"+C(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 k=(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})}}const q=["*.lwcdn.com","*.flowplayer.com"];function V(){try{return window.location.hostname!==window.parent.location.hostname?function(t){const e=document.createElement("a");return e.href=t,e}(document.referrer).hostname:document.location.hostname}catch(t){return window.location.hostname}}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,S,FlowplayerLiveCountdown)}onload(t,e,n,o){if("string"==typeof o.src)return"string"!=typeof t.player_id||0===o.src.indexOf(t.player_id)||f(o)||(o.src=[t.player_id,o.src].join("/")),g(n,o)}wants(t,e,n){return v(t,e)}init(t,n,o){const i=new WebsocketBridge(o);let s=Object.assign({},t);const l=function(t){if(!s)return t;delete s.src;const n=e(t,s);return s=!1,n};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,a=o.opt("metadata",{live_start_time:""});switch(i){case"METADATA":{const e=Object.assign(a,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=h(i.metadata.live_start_time)),o.setOpts(i);break}}})),o.on("beforeplay",(function(e){const n=t;if(w(n)){if(R(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||M(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:e}){var i,s;if("string"==typeof t.src&&v(t.src,{}))return;if(t.src&&N(t.src))return;if((null==e?void 0:e.domains)&&(null==e?void 0:e.domains.length)&&!((t,e)=>{const n=t.split(".").reverse();return e.concat(q).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)})})(V(),e.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.style.removeProperty("background-image");const o=document.createElement("h2");o.textContent="Playback Error";const i=document.createElement("p");i.textContent="Are you the site owner?";const r=document.createElement("a");r.classList.add("troubleshoot"),r.target="_blank",r.href="https://docs.flowplayer.com/troubleshooting/player#"+n.reason,r.textContent="Troubleshoot?";const a=document.createElement("img");a.src="https://flowplayer.com/user/pages/images/logo-white.png",t.append(o,i,r,a)}({root:n,video:o,data:{details:`Hostname ${window.location.hostname} is not allowed to load player ${null===(i=e.metadata)||void 0===i?void 0:i.player_id}.`,reason:"domain"}});const l=null==e?void 0:e.brand_color;return l&&o.root.style.setProperty("--fp-brand-color","#"==l[0]?l:"#"+l),"string"==typeof t.player_id&&(null===(s=null==t?void 0:t.metadata)||void 0===s?void 0:s.player_id)!==t.player_id?function(t,e){if("object"==typeof O[e])return console.debug("using Cache(%s)",e),P(t,e,O[e]);Pipe.of(e).fmap(a).fmap(r).fmap(n=>n.then(n=>P(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 a={type:"flowplayer/playlist",items:n};o.setSrc(a)})),o.on("ovp:live:countdown:start",(function(e){const i=e.data;if(!i||0==o.reaper)return;const r=l(i);if(o.setOpts(r),o.setAttrs(r),!M(i))return o.emit("ovp:request:media:complete",i);x(o,S)||(n.appendChild(k(o,S)),D(o,t))})),o.on("timeupdate",(function(){var e,n,i;const r=t;w(r)?R(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||T()||(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)&&A(o,t.metadata.media_id,t.metadata.player_id))})),o.on("reap",(function(){i.disconnect()}))}}function R(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)||h(o)>Date.now()}OVP.events=_;const N=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,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",({
|
|
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",({detail: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)=>i.dimensions&&e.dimensions&&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/util/loader.d.ts
CHANGED
|
@@ -3,6 +3,6 @@ import { PluginCtor } from "../types/plugin";
|
|
|
3
3
|
* adds support for asynchronous plugin loading`
|
|
4
4
|
* issue/127
|
|
5
5
|
*/
|
|
6
|
-
export declare function define(root: any, plugin: PluginCtor):
|
|
6
|
+
export declare function define(root: any, plugin: PluginCtor): PluginCtor;
|
|
7
7
|
export declare function root(): {};
|
|
8
8
|
export declare function modules(): any;
|