@flowplayer/player 3.8.1 → 3.9.0
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 -1
- package/default.js +1 -1
- package/embed.js +2 -2
- package/flowplayer.css +1 -1
- package/package.json +1 -1
- package/plugins/ads.js +2 -2
- package/plugins/analytics.js +1 -1
- package/plugins/dash.js +4 -4
- package/plugins/drm.js +1 -1
- package/plugins/health.js +1 -1
- package/plugins/hls.js +1 -1
- package/plugins/ovp.js +1 -1
- package/plugins/preview.js +1 -1
- package/plugins/qul.js +1 -1
- package/plugins/subtitles.js +1 -1
- package/plugins/tizen.js +1 -1
- package/plugins/webos.js +1 -1
package/plugins/ovp.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((t="undefined"!=typeof globalThis?globalThis:t||self).flowplayer=t.flowplayer||{},t.flowplayer.ovp=e())}(this,(function(){"use strict";function t(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 r=0;for(o=Object.getOwnPropertySymbols(t);r<o.length;r++)e.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(n[o[r]]=t[o[r]])}return n}const e=t=>"object"==typeof t&&null!==t&&!Array.isArray(t),n=(...t)=>t.reduce((t,o)=>e(o)?(Object.keys(o).forEach(r=>{if(e(t[r])&&e(o[r]))return t[r]=n(t[r],o[r]);t[r]=o[r]}),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"),r=window,i=r._flowplayerTimekeeper||(r._flowplayerTimekeeper={});function s(t){return fetch(t).then(t=>t.json())}function a(){let t=[].join.call(arguments,"/");return"/"!==t[0]&&(t="/"+t),c()+"/web/public/native/config"+t}const c=()=>"https://ljsp.lwcdn.com";function l(t){(async function(){const t=i.cachedServerOffset;if(t)return t;const e=i.pendingRequest||(i.pendingRequest=fetch(o)),n=await e,r=parseInt(n.headers.get("age")||"0"),s=await n.json(),a=Date.now()-s.millisUtc-1e3*r;return i.cachedServerOffset=a,i.cachedServerOffset})().then(e=>Object.assign(t,{server_time_offset:e}))}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,e){var o,r;e="object"==typeof e?e:{};const i={title:null===(o=null==t?void 0:t.metadata)||void 0===o?void 0:o.title,description:null===(r=null==t?void 0:t.metadata)||void 0===r?void 0:r.description},s={ima:{parameters:function({media_id:t,duration:e,title:n,tags:o,category_name:r,ad_keywords:i}){return{ad_keywords:i||"",media_id:t||"",category:r||"",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,i,t,(delete(c=e).src,delete c.metadata,delete c.title,delete c.description,delete c.duration,delete c.poster,c),a);var c}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 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 _(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&&(t.setState("is-source-processing",!0),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])=>{return 200==e?b(t,n):(r=n,(o=t).setState("is-source-processing",!1),r.message?o.emit("ovp:error",r):r.status?o.emit("ovp:error",new Error(u[r.status])):o.emit("ovp:error",r));var o,r})))}function b(t,e){return t.emit("ovp:media:changed",e),function(t){return Array.isArray(t.playlist)}(e)?function(t,e){t.emit("ovp:request:playlist:complete",function(t,e){const o=Object.assign({},t),r=(null==t?void 0:t.playlist)||{},i=n(e,r),s=((null==i?void 0:i.playlist)||[]).map(t=>{e.ima&&Object.assign(t,{ima:e.ima});const n=p(t,o);return delete n.playlist,n});return delete i.ima,Object.assign(i,{playlist:s})}(t.opts,e))}(t,e):w(e)?function(t,e){var n,o;const r=(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);r&&(e.live_start_time=Pipe.of(r).fmap(h).unwrap());t.emit("ovp:live:countdown:start",Pipe.of(e).fmap(p,t.opts).unwrap())}(t,e):function(t,e){t.emit("ovp:request:media:complete",Pipe.of(e).fmap(p,t.opts).unwrap())}(t,e)}const O={};function E(t,e,n){"object"!=typeof O[e]&&(O[e]=n);const o=t.opts,r=(null==o?void 0:o.metadata)||{};r.player_id=e,o.metadata=r,n.title&&delete n.title,n.description&&delete n.description;const i=Object.assign(o,n);t.setOpts(i),n.autoplay&&t.togglePlay(!0)}let j=!1;function A(t,e,n){P()||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,n;return{poster:t.poster,src:t.src,title:null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.title,description:null===(n=null==t?void 0:t.metadata)||void 0===n?void 0:n.description,metadata:t.metadata||{},chapters:t.chapters,thumbnails:t.thumbnails,subtitles:t.subtitles}}))})}(t,e)).catch(S))}function P(){return j}function S(t){j=!0,console.error("Failed to load recommendations: %j",t)}function T(t){const e="number"==typeof t?t:parseInt(t,10);return(e>9?"":"0")+e}function L(t,e){const n=t._customElements.get(e);return n&&t.root.querySelector(n)||void 0}const x="flowplayer-live-countdown";function C(t){const e=Date.now()-(t.server_time_offset||0);return Math.floor(((t.live_start_time||0)-e)/1e3)}function M(t,e){let n=0;function o(){const o=C(e);if(o<0||isNaN(o)||0===t.reaper||void 0===e.live_start_time)return clearInterval(n),function(t,e,n){t.emit("ovp:live:countdown:complete");const o=L(t,x);if(o&&o.remove(),t.root.classList.remove("is-livecountdown"),n)return t.setState("is-source-processing",!1);t.emit("ovp:request:media:complete",e)}(t,e,void 0===e.live_start_time);var r,i,s;r=t,i=t.root,s=o,i.classList.add("is-livecountdown"),r.emit("ovp:live:countdown:tick",{remaining_time:k(s+1)}),r.hasState("is-starting")||r.setState("is-starting",!0)}l(e),o(),n=setInterval(o,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+T(e.hours)+":"+T(e.minutes)+":"+T(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 I=(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 r=window.customElements.get(n);return"function"!=typeof r?o:r})(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 D=["*.lwcdn.com","*.flowplayer.com"];function q(){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}}function V(t){const e=document.createElement("a");e.href=t;const n=e.pathname&&e.pathname.split(".");return n.length>1&&n[n.length-1]}function R(t){switch(t){case"video/mpd":return"application/dash+xml";case"video/m3u8":return"application/x-mpegurl";default:return t}}const N=e=>{var{src:n}=e,o=t(e,["src"]);return[Object.assign({src:n,type:n?R("video/"+V(n)):""},o)]};function U(t){return N({src:t})}function W(e){var{src:n,type:o}=e,r=t(e,["src","type"]);return n&&o?[Object.assign({src:n,type:o},r)]:o&&!n?[Object.assign({type:o},r)]:N(Object.assign({src:n},r))}var F;!function(t){t[t.Err=0]="Err",t[t.Ok=1]="Ok"}(F||(F={}));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,x,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("/")),_(n,o)}wants(t,e,n){return v(t,e)}init(e,o,r){const i=new WebsocketBridge(r);let c=Object.assign({},e);const l=function(t){return c?(delete c.src,n(t,c)):t};r.on("src",()=>{(r.currentSrc||r.root.classList.contains("is-livecountdown"))&&(c=!1)}),r.on("ovp:error",(function(t){r.emit("error",t.data)})),r.on("ovp:request:start",(function(){r.setState("is-waiting",!0),e.recommendations&&(e.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&&(i.disconnect(),i.connect(n))})),r.on("ovp:message:realtime",(function({data:t}){var n;const o=null==t?void 0:t.event,i=null==t?void 0:t.value,s=r.opt("metadata",{live_start_time:""});switch(o){case"METADATA":{const t=Object.assign(s,i),o=Object.assign(e,{metadata:t});o.live&&(null===(n=null==o?void 0:o.metadata)||void 0===n?void 0:n.live_start_time)&&(o.live_start_time=h(o.metadata.live_start_time)),r.setOpts(o);break}}})),r.on("beforeplay",(function(t){const n=e;if(w(n)){if(H(n))return;t.preventDefault()}})),r.on("ovp:request:media:complete",(function(t){const e=t.data;if(!e)return;var n;if(e.src&&(e.src=(n=e.src,"string"==typeof n?U(n):Array.isArray(n)||"object"!=typeof n?n.reduce((function(t,e){return"string"==typeof e&&(e=U(e)),"object"!=typeof e||Array.isArray(e)||(e=W(e)),t.concat(e)}),[]):W(n)).map(t=>(t.src&&t.src.startsWith("//")&&(t.src="https:"+t.src),t))),0==r.reaper||"object"!=typeof e||C(e)>0)return;const o=l(e);r.setOpts(o),r.setAttrs(o),o.src&&r.setSrc(o.src),r.setState("is-source-processing",!1)})),r.on("config",(function({data:t}){var n,i;if("string"==typeof e.src&&v(e.src,{}))return;if(e.src&&$(e.src))return;if((null==t?void 0:t.domains)&&(null==t?void 0:t.domains.length)&&!((t,e)=>{const n=t.split(".").reverse();return e.concat(D).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)})})(q(),t.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 r=document.createElement("p");r.textContent="Are you the site owner?";const i=document.createElement("a");i.classList.add("troubleshoot"),i.target="_blank",i.href="https://docs.flowplayer.com/troubleshooting/player#"+n.reason,i.textContent="Troubleshoot?";const s=document.createElement("img");s.src="https://flowplayer.com/user/pages/images/logo-white.png",t.append(o,r,i,s)}({root:o,video:r,data:{details:`Hostname ${window.location.hostname} is not allowed to load player ${null===(n=t.metadata)||void 0===n?void 0:n.player_id}.`,reason:"domain"}});const c=null==t?void 0:t.brand_color;return c&&r.root.style.setProperty("--fp-brand-color","#"==c[0]?c:"#"+c),"string"==typeof e.player_id&&(null===(i=null==e?void 0:e.metadata)||void 0===i?void 0:i.player_id)!==e.player_id?function(t,e){if("object"==typeof O[e])return console.debug("using Cache(%s)",e),E(t,e,O[e]);Pipe.of(e).fmap(a).fmap(s).fmap(n=>n.then(n=>E(t,e,n)).catch(console.error))}(r,e.player_id):void 0})),r.on("ovp:request:playlist:complete",(function(e){const n=e.data;if(!n||0==r.reaper)return;const{playlist:o}=n,i=t(n,["playlist"]),s=l(i);Array.isArray(s.playlist)&&(s.playlist=i),r.setOpts(s),r.setAttrs(s);const a={type:"flowplayer/playlist",items:o};r.setSrc(a),r.setState("is-source-processing",!1)})),r.on("ovp:live:countdown:start",(function(t){const n=t.data;if(!n||0==r.reaper)return;const i=l(n);if(r.setOpts(i),r.setAttrs(i),C(n)<=0)return r.emit("ovp:request:media:complete",n);L(r,x)||(o.appendChild(I(r,x)),M(r,e))})),r.on("timeupdate",(function(){var t,n,o;const i=e;w(i)?H(i)||(r.togglePlay(!1),r.emit("ended")):e.recommendations&&(null===(t=null==e?void 0:e.metadata)||void 0===t?void 0:t.media_id)&&(Array.isArray(e.recommendations)||r.currentTime/r.duration<.8||P()||(null===(n=null==e?void 0:e.metadata)||void 0===n?void 0:n.media_id)&&(null===(o=null==e?void 0:e.metadata)||void 0===o?void 0:o.player_id)&&A(r,e.metadata.media_id,e.metadata.player_id))})),r.on("reap",(function(){i.disconnect()}))}}function H(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=g;const $=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;if(null===document.currentScript)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";function t(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 r=0;for(o=Object.getOwnPropertySymbols(t);r<o.length;r++)e.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(n[o[r]]=t[o[r]])}return n}const e=t=>"object"==typeof t&&null!==t&&!Array.isArray(t),n=(...t)=>t.reduce((t,o)=>e(o)?(Object.keys(o).forEach(r=>{if(e(t[r])&&e(o[r]))return t[r]=n(t[r],o[r]);t[r]=o[r]}),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"),r=window,i=r._flowplayerTimekeeper||(r._flowplayerTimekeeper={});function s(t){return fetch(t).then(t=>t.json())}function a(){let t=[].join.call(arguments,"/");return"/"!==t[0]&&(t="/"+t),c()+"/web/public/native/config"+t}const c=()=>"https://ljsp.lwcdn.com";function l(t){(async function(){const t=i.cachedServerOffset;if(t)return t;const e=i.pendingRequest||(i.pendingRequest=fetch(o)),n=await e,r=parseInt(n.headers.get("age")||"0"),s=await n.json(),a=Date.now()-s.millisUtc-1e3*r;return i.cachedServerOffset=a,i.cachedServerOffset})().then(e=>Object.assign(t,{server_time_offset:e}))}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,e){var o,r;e="object"==typeof e?e:{};const i={title:null===(o=null==t?void 0:t.metadata)||void 0===o?void 0:o.title,description:null===(r=null==t?void 0:t.metadata)||void 0===r?void 0:r.description},s={ima:{parameters:function({media_id:t,duration:e,title:n,tags:o,category_name:r,ad_keywords:i}){return{ad_keywords:i||"",media_id:t||"",category:r||"",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,i,t,(delete(c=e).src,delete c.metadata,delete c.title,delete c.description,delete c.duration,delete c.poster,c),a);var c}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 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 _(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&&(t.setState("is-source-processing",!0),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])=>{return 200==e?b(t,n):(r=n,(o=t).setState("is-source-processing",!1),r.message?o.emit("ovp:error",r):r.status?o.emit("ovp:error",new Error(u[r.status])):o.emit("ovp:error",r));var o,r})))}function b(t,e){return t.emit("ovp:media:changed",e),function(t){return Array.isArray(t.playlist)}(e)?function(t,e){t.emit("ovp:request:playlist:complete",function(t,e){const o=Object.assign({},t),r=(null==t?void 0:t.playlist)||{},i=n(e,r),s=((null==i?void 0:i.playlist)||[]).map(t=>{e.ima&&Object.assign(t,{ima:e.ima});const n=p(t,o);return delete n.playlist,n});return delete i.ima,Object.assign(i,{playlist:s})}(t.opts,e))}(t,e):w(e)?function(t,e){var n,o;const r=(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);r&&(e.live_start_time=Pipe.of(r).fmap(h).unwrap());t.emit("ovp:live:countdown:start",Pipe.of(e).fmap(p,t.opts).unwrap())}(t,e):function(t,e){t.emit("ovp:request:media:complete",Pipe.of(e).fmap(p,t.opts).unwrap())}(t,e)}const O={};function E(t,e,n){"object"!=typeof O[e]&&(O[e]=n);const o=t.opts,r=(null==o?void 0:o.metadata)||{};r.player_id=e,o.metadata=r,n.title&&delete n.title,n.description&&delete n.description;const i=Object.assign(o,n);t.setOpts(i),n.autoplay&&t.togglePlay(!0)}let j=!1;function A(t,e,n){P()||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,n;return{poster:t.poster,src:t.src,title:null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.title,description:null===(n=null==t?void 0:t.metadata)||void 0===n?void 0:n.description,metadata:t.metadata||{},chapters:t.chapters,thumbnails:t.thumbnails,subtitles:t.subtitles}}))})}(t,e)).catch(S))}function P(){return j}function S(t){j=!0,console.error("Failed to load recommendations: %j",t)}function T(t){const e="number"==typeof t?t:parseInt(t,10);return(e>9?"":"0")+e}function L(t,e){const n=t._customElements.get(e);return n&&t.root.querySelector(n)||void 0}const x="flowplayer-live-countdown";function C(t){const e=Date.now()-(t.server_time_offset||0);return Math.floor(((t.live_start_time||0)-e)/1e3)}function M(t,e){let n=0;function o(){const o=C(e);if(o<0||isNaN(o)||0===t.reaper||void 0===e.live_start_time)return clearInterval(n),function(t,e,n){t.emit("ovp:live:countdown:complete");const o=L(t,x);if(o&&o.remove(),t.root.classList.remove("is-livecountdown"),n)return t.setState("is-source-processing",!1);t.emit("ovp:request:media:complete",e)}(t,e,void 0===e.live_start_time);var r,i,s;r=t,i=t.root,s=o,i.classList.add("is-livecountdown"),r.emit("ovp:live:countdown:tick",{remaining_time:k(s+1)}),r.hasState("is-starting")||r.setState("is-starting",!0)}l(e),o(),n=setInterval(o,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+T(e.hours)+":"+T(e.minutes)+":"+T(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 I=(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 r=window.customElements.get(n);return"function"!=typeof r?o:r})(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 D=["*.lwcdn.com","*.flowplayer.com"];function q(){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}}function V(t){const e=document.createElement("a");e.href=t;const n=e.pathname&&e.pathname.split(".");return n.length>1&&n[n.length-1]}function R(t){switch(t){case"video/mpd":return"application/dash+xml";case"video/m3u8":return"application/x-mpegurl";default:return t}}const N=e=>{var{src:n}=e,o=t(e,["src"]);return[Object.assign({src:n,type:n?R("video/"+V(n)):""},o)]};function U(t){return N({src:t})}function W(e){var{src:n,type:o}=e,r=t(e,["src","type"]);return n&&o?[Object.assign({src:n,type:o},r)]:o&&!n?[Object.assign({type:o},r)]:N(Object.assign({src:n},r))}var F;!function(t){t[t.Err=0]="Err",t[t.Ok=1]="Ok"}(F||(F={}));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,x,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("/")),_(n,o)}wants(t,e,n){return v(t,e)}init(e,o,r){const i=new WebsocketBridge(r);let c=Object.assign({},e);const l=function(t){return c?(e.autoplay!==c.autoplay&&(c.autoplay=e.autoplay),delete c.src,n(t,c)):t};r.on("src",()=>{(r.currentSrc||r.root.classList.contains("is-livecountdown"))&&(c=!1)}),r.on("ovp:error",(function(t){r.emit("error",t.data)})),r.on("ovp:request:start",(function(){r.setState("is-waiting",!0),e.recommendations&&(e.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&&(i.disconnect(),i.connect(n))})),r.on("ovp:message:realtime",(function({data:t}){var n;const o=null==t?void 0:t.event,i=null==t?void 0:t.value,s=r.opt("metadata",{live_start_time:""});switch(o){case"METADATA":{const t=Object.assign(s,i),o=Object.assign(e,{metadata:t});o.live&&(null===(n=null==o?void 0:o.metadata)||void 0===n?void 0:n.live_start_time)&&(o.live_start_time=h(o.metadata.live_start_time)),r.setOpts(o);break}}})),r.on("beforeplay",(function(t){const n=e;if(w(n)){if(H(n))return;t.preventDefault()}})),r.on("ovp:request:media:complete",(function(t){const e=t.data;if(!e)return;var n;if(e.src&&(e.src=(n=e.src,"string"==typeof n?U(n):Array.isArray(n)||"object"!=typeof n?n.reduce((function(t,e){return"string"==typeof e&&(e=U(e)),"object"!=typeof e||Array.isArray(e)||(e=W(e)),t.concat(e)}),[]):W(n)).map(t=>(t.src&&t.src.startsWith("//")&&(t.src="https:"+t.src),t))),0==r.reaper||"object"!=typeof e||C(e)>0)return;const o=l(e);r.setOpts(o),r.setAttrs(o),o.src&&r.setSrc(o.src),r.setState("is-source-processing",!1)})),r.on("config",(function({data:t}){var n,i;if("string"==typeof e.src&&v(e.src,{}))return;if(e.src&&$(e.src))return;if((null==t?void 0:t.domains)&&(null==t?void 0:t.domains.length)&&!((t,e)=>{const n=t.split(".").reverse();return e.concat(D).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)})})(q(),t.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 r=document.createElement("p");r.textContent="Are you the site owner?";const i=document.createElement("a");i.classList.add("troubleshoot"),i.target="_blank",i.href="https://docs.flowplayer.com/troubleshooting/player#"+n.reason,i.textContent="Troubleshoot?";const s=document.createElement("img");s.src="https://flowplayer.com/user/pages/images/logo-white.png",t.append(o,r,i,s)}({root:o,video:r,data:{details:`Hostname ${window.location.hostname} is not allowed to load player ${null===(n=t.metadata)||void 0===n?void 0:n.player_id}.`,reason:"domain"}});const c=null==t?void 0:t.brand_color;return c&&r.root.style.setProperty("--fp-brand-color","#"==c[0]?c:"#"+c),"string"==typeof e.player_id&&(null===(i=null==e?void 0:e.metadata)||void 0===i?void 0:i.player_id)!==e.player_id?function(t,e){if("object"==typeof O[e])return console.debug("using Cache(%s)",e),E(t,e,O[e]);Pipe.of(e).fmap(a).fmap(s).fmap(n=>n.then(n=>E(t,e,n)).catch(console.error))}(r,e.player_id):void 0})),r.on("ovp:request:playlist:complete",(function(e){const n=e.data;if(!n||0==r.reaper)return;const{playlist:o}=n,i=t(n,["playlist"]),s=l(i);Array.isArray(s.playlist)&&(s.playlist=i),r.setOpts(s),r.setAttrs(s);const a={type:"flowplayer/playlist",items:o};r.setSrc(a),r.setState("is-source-processing",!1)})),r.on("ovp:live:countdown:start",(function(t){const n=t.data;if(!n||0==r.reaper)return;const i=l(n);if(r.setOpts(i),r.setAttrs(i),C(n)<=0)return r.emit("ovp:request:media:complete",n);L(r,x)||(o.appendChild(I(r,x)),M(r,e))})),r.on("timeupdate",(function(){var t,n,o;const i=e;w(i)?H(i)||(r.togglePlay(!1),r.emit("ended")):e.recommendations&&(null===(t=null==e?void 0:e.metadata)||void 0===t?void 0:t.media_id)&&(Array.isArray(e.recommendations)||r.currentTime/r.duration<.8||P()||(null===(n=null==e?void 0:e.metadata)||void 0===n?void 0:n.media_id)&&(null===(o=null==e?void 0:e.metadata)||void 0===o?void 0:o.player_id)&&A(r,e.metadata.media_id,e.metadata.player_id))})),r.on("reap",(function(){i.disconnect()}))}}function H(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=g;const $=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;if(null===document.currentScript)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",({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
|
|
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 r=e.preview.trigger||3;(4&r||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),r=/Android/.test(i)&&!/Firefox/.test(i),n=/^((?!chrome|android).)*safari/i.test(i),o=/chrome|crios/i.test(i)&&!/opr|opera|chromium|edg|ucbrowser|googlebot/i.test(i),s=/firefox|fxios/i.test(i)&&!/seamonkey/i.test(i),a=/edg/i.test(i),d=/opr|opera/i.test(i),u=/SamsungBrowser/.test(i),f=u&&/SMART-TV/.test(i);return{controls:!t,video:function(i){return e&&document.createElement("video").canPlayType(i)},lang:e&&window.navigator.language,android:r,iphone:t,safari:n,edge:a,opera:d,chrome:o,firefox:s,ios:e&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,samsung:u,samsung_tv:u&&f,touch:"ontouchstart"in window,tizen:"tizen"in window,webOS:"webos"in window}}().touch&&2&r)&&(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;if(null===document.currentScript)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/qul.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(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.qul=t())}(this,(function(){"use strict";const e="application/vnd.apple.mpegURL";document.createElement("video").canPlayType(e);function t(t){var n;return void 0===window.MediaSource&&void 0===window.WebKitMediaSource||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),r=/chrome|crios/i.test(t)&&!/opr|opera|chromium|edg|ucbrowser|googlebot/i.test(t),s=/firefox|fxios/i.test(t)&&!/seamonkey/i.test(t),d=/edg/i.test(t),a=/opr|opera/i.test(t),u=/SamsungBrowser/.test(t),l=u&&/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,edge:d,opera:a,chrome:r,firefox:s,ios:e&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,samsung:u,samsung_tv:u&&l,touch:"ontouchstart"in window,tizen:"tizen"in window,webOS:"webos"in window}}().video(e)&&(null===(n=null==t?void 0:t.hls)||void 0===n?void 0:n.native)}function n(e,t){t.id&&clearInterval(t.id)}function o(e,t){i(e.original_src,(o,i,r)=>{if(200!=i)return n(0,t),o?e.emit("error",o):e.emit("error",{code:i,resp:r})})}function i(e,t){const n=new XMLHttpRequest;n.onload=function(){if(200==n.status)return t(void 0,n.status);try{const e=JSON.parse(n.responseText);t(void 0,"qul:"+n.status,e)}catch(e){t(e)}},n.open("GET",function(e){const t=document.createElement("a");t.href=e;const n="bust="+Date.now();return[t.protocol,"//",t.hostname,t.pathname,t.search,t.search.length?"&":"?",n].join("")}(e)),n.send()}function r(e,t){const n=new CustomEvent(e,{detail:t,cancelable:!0});return t&&Object.defineProperty(n,"data",{get:()=>t}),n}!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){}}();function s(e,t,n){const o=document.createElement("a");o.href=e;let i=encodeURIComponent(t);return n&&(i+="/dId:"+encodeURIComponent(n)),[o.protocol,"//",o.hostname,o.pathname.replace(a(o.pathname,0),i+"/"+a(o.pathname,0))].join("")}class QULPlugin{init(e,r,a){var u,l,c;const f=(null===(u=e.qul)||void 0===u?void 0:u.device_id)||(null===(l=e.qul)||void 0===l?void 0:l.dId)||a.deviceId();let v,p=null===(c=e.qul)||void 0===c?void 0:c.token;const m={};a.on("src",(function(i){var r;i.data&&(v=null===(r=i.data)||void 0===r?void 0:r.src,n(0,m),"string"==typeof v&&v.match(/\.m3u8$/)&&p&&(i.data.src=s(v,p,f),t(e)&&Object.assign(m,function(e,t){var i;const r=(null===(i=null==t?void 0:t.qul)||void 0===i?void 0:i.interval)||2e4,s={interval:Math.min(2e4,r)};return e.once("reap",(function(){n(0,s)})),s.id=setInterval(o,s.interval,e,s),setTimeout(o,0,e,s),s}(a,a.opts))))})),a.on("config",(function(e){var t,n,o,i,r,d;const u=null===(n=null===(t=e.data)||void 0===t?void 0:t.qul)||void 0===n?void 0:n.token,l=(null===(i=null===(o=e.data)||void 0===o?void 0:o.qul)||void 0===i?void 0:i.device_id)||(null===(d=null===(r=e.data)||void 0===r?void 0:r.qul)||void 0===d?void 0:d.dId);u&&u!==p&&function(e,t){p=e,a.setSrc({type:"application/x-mpegurl",src:s(v,p,t)})}(u,l)})),a.on("error",(function(e){var t,o;const r=((null===(t=e.data)||void 0===t?void 0:t.code)||"").toString();if(!r.match(/^(qul|http)/))return;n(0,m),e.preventDefault();const s=null===(o=e.data)||void 0===o?void 0:o.resp;if(s)return d(a,s,r);i(a.original_src,(e,t,n)=>{if(e)return a.emit("error",e);!isNaN(Number(t))&&Number(t)<400||d(a,n,null==t?void 0:t.toString())})}))}}function d(e,t,n){const o=(null==t?void 0:t.message)||"an error occurred during this session",i=(null==t?void 0:t.key)?e.i18n(t.key,o):o;e.pause();const s=r("qul:error",{code:n,resp:t});if(e.dispatchEvent(s),s.defaultPrevented)return;const d=window.customElements.get("flowplayer-error"),a=function(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}(e,"flowplayer-ui");if(a&&d){if(e.setState("is-error",!0),!e.root.querySelector("#qul_error")){const t=new d(e);t.id="qul_error",a.append(t)}!function(e,t,n){const o=r(t,n);e.dispatchEvent(o)}(e.root.querySelector("#qul_error"),"error",{formatted_data:{message:i}})}}function a(e,t){return e.split("/").reverse().slice(0,t+1).reverse().join("/")}return QULPlugin.events={QUL_ERROR:"qul:error"},function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;if(null===document.currentScript)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;return"function"==typeof n?(n(t),t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t),t)}(window,QULPlugin)}));
|
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 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){e.innerHTML="",t.forEach((function(t){const n=document.createElement("pre");n.classList.add("fp-cue"),function(e,t){const n=e.style,i=t.size;n.setProperty("--caption-size",i.toString());const s=t.position;s&&"auto"!==s&&t?n.setProperty("--caption-position",s.toString()):n.removeProperty("--caption-position");const o="captions-align-"+t.align;Array.from(e.classList).forEach((function(n){n!=o&&("captions-vertical"==n&&t.vertical||n.startsWith("captions")&&e.classList.remove(n))})),e.classList.add(o),e.classList.toggle("captions-vertical",!!t.vertical)}(e,t),n.appendChild(t.getCueAsHTML()),e.appendChild(n)}))}function n(){}var i;function s(e,t){if(function(e){return Object.values(i).includes(e)}(t=t||i.Anonymous))return e instanceof HTMLVideoElement&&(e.poster="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="),"crossOrigin"in e?e.crossOrigin=t:e.setAttribute("crossorigin",t),e}function o(e){const t=document.createElement("a");return t.href=e,t.origin}function r(e,t){const i=document.createElement("track");i.className="fp-track renderable",i.kind=t.kind||"captions",i.label=t.label||t.lang||"",i.lang=t.lang||"",i.id=["fp",t.lang].join("-");const r=i.track;return r.removeCue=n,"string"!=typeof t.crossorigin&&function(e,t){try{return e.src.startsWith("blob:"),o(e.src)!==o(t)}catch(e){return console.error(e),!0}}(e,t.src)&&(s(e),t.crossorigin=e.getAttribute("crossorigin")),"crossorigin"in t&&s(e,t.crossorigin),Object.keys(t).forEach(e=>{"default"!==e&&(i[e]=t[e])}),r.mode=t.default?"hidden":"disabled",e.appendChild(i),i}function l(){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),i=/Android/.test(t)&&!/Firefox/.test(t),s=/^((?!chrome|android).)*safari/i.test(t),o=/SamsungBrowser/.test(t),r=o&&/SMART-TV/.test(t);return{controls:!n,video:function(t){return e&&document.createElement("video").canPlayType(t)},lang:e&&window.navigator.language,android:i,iphone:n,safari:s,ios:e&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,samsung:o,samsung_tv:o&&r,touch:"ontouchstart"in window,tizen:"tizen"in window,webOS:"webos"in window}}!function(e){e.Anonymous="anonymous",e.UseCredentials="use-credentials",e.Empty=""}(i||(i={}));const a="is-source-processing",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 i=window.customElements.get(t);if(!i)throw new Error(`no default flowplayer component with the name ${t} exists`);const s=window.customElements.get(n);return"function"!=typeof s?i:s})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}const u="fp-on",d="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.olEle.id=f(),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.textContent="×",this.menuContainer.append(this.summaryEle,this.menu),this.menuContainer.addEventListener("click",t=>{t.preventDefault();const n=this.menuContainer.open;n||(m(),document.active_menu=this.menuContainer),this.menuContainer.open=!n,e.root.classList.toggle("has-menu-opened",!n),this.summaryEle.setAttribute("aria-expanded",n?"false":"true")}),this.addEventListener("focusin",e=>{const t=e.target;t instanceof HTMLLIElement&&t.setAttribute("aria-selected","true")}),this.addEventListener("focusout",e=>{const t=e.target;t instanceof HTMLLIElement&&t.setAttribute("aria-selected","false")}),this.append(this.menuContainer),this.summaryEle.setAttribute("aria-haspopup","true"),this.summaryEle.setAttribute("aria-controls",this.olEle.id),this.summaryEle.setAttribute("tabindex","0"),this.summaryEle.setAttribute("aria-expanded","false"),this.summaryEle.setAttribute("role","button")}get options(){return this.olEle.querySelectorAll("li")}setMenuAttrs(e){if(this.summaryEle.id||(this.summaryEle.id=e.id||f()),this.className=e.class,this.menuContainer.classList.add("fp-menu-container"),this.toggle_visibility(!0),this.olEle.setAttribute("aria-labelledby",this.summaryEle.id),this.olEle.setAttribute("role","menu"),this.summaryEle.setAttribute("aria-label",e.menuTitle||"Menu"),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.toggle_visibility(!(null==e?void 0:e.length)))}menuOption(e,t){const n=document.createElement("li");n.setAttribute("role","menuitem"),n.setAttribute("aria-selected","false"),n.setAttribute("tabindex","0"),e.icon&&n.append(e.icon);const i=document.createElement("span");i.textContent=e.text,n.append(i),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(u,n===e&&("flowplayer-subtitles-menu"!==this.localName||!t.classList.contains(u)))})}unselect_item(){this.options.forEach(e=>{e.classList.remove(u)})}toggle_visibility(e){this.classList.toggle(d,e),this.menu.style.setProperty("display",e?"none":"block")}}function m(){Array.from(document.querySelectorAll(".fp-engine")).forEach(e=>{var t;const n=e.root.querySelector("details[open].fp-menu-container");n&&(n.open=!1,null===(t=n.querySelector("summary"))||void 0===t||t.removeAttribute("aria-expanded"),e.root.classList.toggle("has-menu-opened",!1))})}function f(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function p(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 h(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)&&(m(),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 FlowplayerSubtitlesMenu extends FlowplayerMenu{constructor(e){super(e),e.on(Subtitles.events.TRACK_UPDATED,e=>this.summaryEle.classList.toggle("fp-color-text",!!e.detail))}}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,"flowplayer-subtitles-menu",FlowplayerSubtitlesMenu)}init(i,s,o){const u=c(o,"flowplayer-subtitles-menu");u instanceof FlowplayerMenu&&u.setMenuAttrs({class:"fp-cc",summaryTitle:o.i18n("cc.button","CC"),menuTitle:o.i18n("cc.menu_title","Subtitles"),options_event:Subtitles.events.TRACKS,item_selected_event:Subtitles.events.SWITCH});const d=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}(o);let m,f=[],v=[];function b(){return Array.from(o.textTracks).filter(e=>~["captions","subtitles","descriptions"].indexOf(e.kind)&&!e.removed&&e.label)}function y(){return b().find(e=>e.is_active)}function g(e){Array.from(e.querySelectorAll("track")).forEach(t=>{["captions","subtitles","descriptions"].includes(t.kind)&&e.removeChild(t)})}function E(e,t,n){p(t,Subtitles.events.TRACKS,n.map((function(t){return{text:t.label,onclick:A.bind(0,e,t)}})));const i=y();return i?b().find(e=>e===i)?void p(t,Subtitles.events.SWITCH,{selected_index:n.indexOf(i)}):w():e.emit("tracks:text:updated")}function A(e,t){var n,i;if(t==y())return w();w(),t.is_hls_embedded&&"number"==typeof t.track_id&&e.hls&&(e.hls.subtitleTrack=t.track_id),t.mode=(null===(n=e.opts.subtitles)||void 0===n?void 0:n.native)?"showing":"hidden",t.is_active=!0,e.emit("tracks:text:updated",t),(null===(i=e.opts.subtitles)||void 0===i?void 0:i.native)||e.emit("cuechange",{track:t})}function w(){const e=y();e&&(o.emit("tracks:text:updated"),e.mode="disabled",e.is_active=!1,t(d,[]))}!function(e){if(!l().ios)return;e.on("webkitbeginfullscreen",()=>{const e=y();e&&(e.mode="showing")}),e.on("webkitendfullscreen",()=>{var t;const n=v.find(e=>"showing"===e.mode);if(n&&!(null===(t=e.opts.subtitles)||void 0===t?void 0:t.native)&&(n.mode="hidden"),n!==y()){if(!n)return w();A(e,n),p(u,Subtitles.events.SWITCH,{selected_index:v.indexOf(n)})}})}(o),o.on("mount",(function(){var e,t;const n=h(o,"flowplayer-control");if(!n)return null===(e=h(o,"flowplayer-ui"))||void 0===e?void 0:e.appendChild(d);n.insertAdjacentElement("beforebegin",d),null===(t=o.hasState("is-tv")?h(o,"flowplayer-tv-menu"):n)||void 0===t||t.append(u)})),o.on("config",(function(e){var t,n;const i=null===(n=null===(t=e.data)||void 0===t?void 0:t.subtitles)||void 0===n?void 0:n.tracks;i&&f!==i&&(f=i,g(o),v=b(),E(o,u,v),f.forEach(e=>r(o,e)))})),o.on("tracks:text:all",e=>{const t=e.detail.tracks;t!==m&&(m=t,v=v.flatMap(e=>e.is_hls_embedded?(e.removed=!0,[]):e),E(o,u,v),t.filter(e=>{var t,n;return~["subtitles","captions"].indexOf((null==e?void 0:e.kind)||(null===(n=null===(t=null==e?void 0:e.subtitleTrack)||void 0===t?void 0:t.type)||void 0===n?void 0:n.toLocaleLowerCase())||"")}).forEach(e=>{var t,i,s,r,l,a,c;const u=o.addTextTrack("captions"===e.kind?"captions":"subtitles",(null===(t=e.subtitleTrack)||void 0===t?void 0:t.name)||e.label,null===(i=e.subtitleTrack)||void 0===i?void 0:i.lang);u.is_hls_embedded=!0,u.default=void 0!==(null===(s=e.subtitleTrack)||void 0===s?void 0:s.default)?null===(r=e.subtitleTrack)||void 0===r?void 0:r.default:e.default,u.track_id=null!==(a=null===(l=e.subtitleTrack)||void 0===l?void 0:l.id)&&void 0!==a?a:e._id,u.mode=u.default?"hidden":"disabled",u.removeCue=n,u.attr=null===(c=e.subtitleTrack)||void 0===c?void 0:c.attrs}))}),o.on("cues:parsed",e=>{const t=e.detail,n=v.find(e=>e.is_hls_embedded&&!e.removed&&(e.default&&"default"===t.track||e.track_id===t.track||"subtitles"+e.track_id===t.track||"captions"+e.track_id===t.track));n&&t.cues.forEach(e=>n.addCue(e))}),o.textTracks.addEventListener("addtrack",()=>{const e=b();if(v.length===e.length&&v.every((t,n)=>t===e[n]))return;let t=y();if(e.map((function(e){return~["showing","hidden"].indexOf(e.mode)&&(t=e,e.mode="disabled",e.is_active=!1),e.oncuechange=function(t){var n;if(!(e===y()||l().ios&&o.hasState("is-fullscreen")))return e.mode="disabled";(null===(n=i.subtitles)||void 0===n?void 0:n.native)||o.emit(t.type,{track:t.target})},e})),p(u,Subtitles.events.TRACKS,e.map((function(e){return{text:e.label,onclick:A.bind(0,o,e)}}))),v=e,!t)return w();A(o,t),p(u,Subtitles.events.SWITCH,{selected_index:v.indexOf(t)})}),o.on("cuechange",(function(n){var i;const s=null===(i=n.data)||void 0===i?void 0:i.track;if(!s||!["captions","subtitles","descriptions"].includes(s.kind))return;const o=Array.from(e(s,"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(d,o)})),o.on(["playlist/advance","src"],e=>{o.currentSrc&&("src"===e.type&&["is-playlist",a].some(e=>o.root.classList.contains(e))||(delete o.opts.subtitles,g(o),f=[],w(),v=[],m=[],b().forEach(e=>e.removed=!0),p(u,Subtitles.events.TRACKS,[])))})}}return Subtitles.events={TRACKS:"subs:tracks",SWITCH:"subs:change",TRACK_UPDATED:"tracks:text:updated"},function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;if(null===document.currentScript)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;"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 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){e.innerHTML="",t.forEach((function(t){const n=document.createElement("pre");n.classList.add("fp-cue"),function(e,t){const n=e.style,i=t.size;n.setProperty("--caption-size",i.toString());const s=t.position;s&&"auto"!==s&&t?n.setProperty("--caption-position",s.toString()):n.removeProperty("--caption-position");const o="captions-align-"+t.align;Array.from(e.classList).forEach((function(n){n!=o&&("captions-vertical"==n&&t.vertical||n.startsWith("captions")&&e.classList.remove(n))})),e.classList.add(o),e.classList.toggle("captions-vertical",!!t.vertical)}(e,t),n.appendChild(t.getCueAsHTML()),e.appendChild(n)}))}function n(){}var i;function s(e,t){if(function(e){return Object.values(i).includes(e)}(t=t||i.Anonymous))return e instanceof HTMLVideoElement&&(e.poster="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="),"crossOrigin"in e?e.crossOrigin=t:e.setAttribute("crossorigin",t),e}function o(e){const t=document.createElement("a");return t.href=e,t.origin}function r(e,t){const i=document.createElement("track");i.className="fp-track renderable",i.kind=t.kind||"captions",i.label=t.label||t.lang||"",i.lang=t.lang||"",i.id=["fp",t.lang].join("-");const r=i.track;return r.removeCue=n,"string"!=typeof t.crossorigin&&function(e,t){try{return e.src.startsWith("blob:"),o(e.src)!==o(t)}catch(e){return console.error(e),!0}}(e,t.src)&&(s(e),t.crossorigin=e.getAttribute("crossorigin")),"crossorigin"in t&&s(e,t.crossorigin),Object.keys(t).forEach(e=>{"default"!==e&&(i[e]=t[e])}),r.mode=t.default?"hidden":"disabled",e.appendChild(i),i}function l(){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),i=/Android/.test(t)&&!/Firefox/.test(t),s=/^((?!chrome|android).)*safari/i.test(t),o=/chrome|crios/i.test(t)&&!/opr|opera|chromium|edg|ucbrowser|googlebot/i.test(t),r=/firefox|fxios/i.test(t)&&!/seamonkey/i.test(t),l=/edg/i.test(t),a=/opr|opera/i.test(t),c=/SamsungBrowser/.test(t),u=c&&/SMART-TV/.test(t);return{controls:!n,video:function(t){return e&&document.createElement("video").canPlayType(t)},lang:e&&window.navigator.language,android:i,iphone:n,safari:s,edge:l,opera:a,chrome:o,firefox:r,ios:e&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,samsung:c,samsung_tv:c&&u,touch:"ontouchstart"in window,tizen:"tizen"in window,webOS:"webos"in window}}!function(e){e.Anonymous="anonymous",e.UseCredentials="use-credentials",e.Empty=""}(i||(i={}));const a="is-source-processing",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 i=window.customElements.get(t);if(!i)throw new Error(`no default flowplayer component with the name ${t} exists`);const s=window.customElements.get(n);return"function"!=typeof s?i:s})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}const u="fp-on",d="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.olEle.id=f(),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.textContent="×",this.menuContainer.append(this.summaryEle,this.menu),this.menuContainer.addEventListener("click",t=>{t.preventDefault();const n=this.menuContainer.open;n||(m(),document.active_menu=this.menuContainer),this.menuContainer.open=!n,e.root.classList.toggle("has-menu-opened",!n),this.summaryEle.setAttribute("aria-expanded",n?"false":"true")}),this.addEventListener("focusin",e=>{const t=e.target;t instanceof HTMLLIElement&&t.setAttribute("aria-selected","true")}),this.addEventListener("focusout",e=>{const t=e.target;t instanceof HTMLLIElement&&t.setAttribute("aria-selected","false")}),this.append(this.menuContainer),this.summaryEle.setAttribute("aria-haspopup","true"),this.summaryEle.setAttribute("aria-controls",this.olEle.id),this.summaryEle.setAttribute("tabindex","0"),this.summaryEle.setAttribute("aria-expanded","false"),this.summaryEle.setAttribute("role","button")}get options(){return this.olEle.querySelectorAll("li")}setMenuAttrs(e){if(this.summaryEle.id||(this.summaryEle.id=e.id||f()),this.className=e.class,this.menuContainer.classList.add("fp-menu-container"),this.toggle_visibility(!0),this.olEle.setAttribute("aria-labelledby",this.summaryEle.id),this.olEle.setAttribute("role","menu"),this.summaryEle.setAttribute("aria-label",e.menuTitle||"Menu"),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.toggle_visibility(!(null==e?void 0:e.length)))}menuOption(e,t){const n=document.createElement("li");n.setAttribute("role","menuitem"),n.setAttribute("aria-selected","false"),n.setAttribute("tabindex","0"),e.icon&&n.append(e.icon);const i=document.createElement("span");i.textContent=e.text,n.append(i),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(u,n===e&&("flowplayer-subtitles-menu"!==this.localName||!t.classList.contains(u)))})}unselect_item(){this.options.forEach(e=>{e.classList.remove(u)})}toggle_visibility(e){this.classList.toggle(d,e),this.menu.style.setProperty("display",e?"none":"block")}}function m(){Array.from(document.querySelectorAll(".fp-engine")).forEach(e=>{var t;const n=e.root.querySelector("details[open].fp-menu-container");n&&(n.open=!1,null===(t=n.querySelector("summary"))||void 0===t||t.removeAttribute("aria-expanded"),e.root.classList.toggle("has-menu-opened",!1))})}function f(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function p(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 h(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)&&(m(),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 FlowplayerSubtitlesMenu extends FlowplayerMenu{constructor(e){super(e),e.on(Subtitles.events.TRACK_UPDATED,e=>this.summaryEle.classList.toggle("fp-color-text",!!e.detail))}}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,"flowplayer-subtitles-menu",FlowplayerSubtitlesMenu)}init(i,s,o){const u=c(o,"flowplayer-subtitles-menu");u instanceof FlowplayerMenu&&u.setMenuAttrs({class:"fp-cc",summaryTitle:o.i18n("cc.button","CC"),menuTitle:o.i18n("cc.menu_title","Subtitles"),options_event:Subtitles.events.TRACKS,item_selected_event:Subtitles.events.SWITCH});const d=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}(o);let m,f=[],v=[];function b(){return Array.from(o.textTracks).filter(e=>~["captions","subtitles","descriptions"].indexOf(e.kind)&&!e.removed&&e.label)}function y(){return b().find(e=>e.is_active)}function g(e){Array.from(e.querySelectorAll("track")).forEach(t=>{["captions","subtitles","descriptions"].includes(t.kind)&&e.removeChild(t)})}function E(e,t,n){p(t,Subtitles.events.TRACKS,n.map((function(t){return{text:t.label,onclick:A.bind(0,e,t)}})));const i=y();return i?b().find(e=>e===i)?void p(t,Subtitles.events.SWITCH,{selected_index:n.indexOf(i)}):w():e.emit("tracks:text:updated")}function A(e,t){var n,i;if(t==y())return w();w(),t.is_hls_embedded&&"number"==typeof t.track_id&&e.hls&&(e.hls.subtitleTrack=t.track_id),t.mode=(null===(n=e.opts.subtitles)||void 0===n?void 0:n.native)?"showing":"hidden",t.is_active=!0,e.emit("tracks:text:updated",t),(null===(i=e.opts.subtitles)||void 0===i?void 0:i.native)||e.emit("cuechange",{track:t})}function w(){const e=y();e&&(o.emit("tracks:text:updated"),e.mode="disabled",e.is_active=!1,t(d,[]))}!function(e){if(!l().ios)return;e.on("webkitbeginfullscreen",()=>{const e=y();e&&(e.mode="showing")}),e.on("webkitendfullscreen",()=>{var t;const n=v.find(e=>"showing"===e.mode);if(n&&!(null===(t=e.opts.subtitles)||void 0===t?void 0:t.native)&&(n.mode="hidden"),n!==y()){if(!n)return w();A(e,n),p(u,Subtitles.events.SWITCH,{selected_index:v.indexOf(n)})}})}(o),o.on("mount",(function(){var e,t;const n=h(o,"flowplayer-control");if(!n)return null===(e=h(o,"flowplayer-ui"))||void 0===e?void 0:e.appendChild(d);n.insertAdjacentElement("beforebegin",d),null===(t=o.hasState("is-tv")?h(o,"flowplayer-tv-menu"):n)||void 0===t||t.append(u)})),o.on("config",(function(e){var t,n;const i=null===(n=null===(t=e.data)||void 0===t?void 0:t.subtitles)||void 0===n?void 0:n.tracks;i&&f!==i&&(f=i,g(o),v=b(),E(o,u,v),f.forEach(e=>r(o,e)))})),o.on("tracks:text:all",e=>{const t=e.detail.tracks;t!==m&&(m=t,v=v.flatMap(e=>e.is_hls_embedded?(e.removed=!0,[]):e),E(o,u,v),t.filter(e=>{var t,n;return~["subtitles","captions"].indexOf((null==e?void 0:e.kind)||(null===(n=null===(t=null==e?void 0:e.subtitleTrack)||void 0===t?void 0:t.type)||void 0===n?void 0:n.toLocaleLowerCase())||"")}).forEach(e=>{var t,i,s,r,l,a,c;const u=o.addTextTrack("captions"===e.kind?"captions":"subtitles",(null===(t=e.subtitleTrack)||void 0===t?void 0:t.name)||e.label,null===(i=e.subtitleTrack)||void 0===i?void 0:i.lang);u.is_hls_embedded=!0,u.default=void 0!==(null===(s=e.subtitleTrack)||void 0===s?void 0:s.default)?null===(r=e.subtitleTrack)||void 0===r?void 0:r.default:e.default,u.track_id=null!==(a=null===(l=e.subtitleTrack)||void 0===l?void 0:l.id)&&void 0!==a?a:e._id,u.mode=u.default?"hidden":"disabled",u.removeCue=n,u.attr=null===(c=e.subtitleTrack)||void 0===c?void 0:c.attrs}))}),o.on("cues:parsed",e=>{const t=e.detail,n=v.find(e=>e.is_hls_embedded&&!e.removed&&(e.default&&"default"===t.track||e.track_id===t.track||"subtitles"+e.track_id===t.track||"captions"+e.track_id===t.track));n&&t.cues.forEach(e=>n.addCue(e))}),o.textTracks.addEventListener("addtrack",()=>{const e=b();if(v.length===e.length&&v.every((t,n)=>t===e[n]))return;let t=y();if(e.map((function(e){return~["showing","hidden"].indexOf(e.mode)&&(t=e,e.mode="disabled",e.is_active=!1),e.oncuechange=function(t){var n;if(!(e===y()||l().ios&&o.hasState("is-fullscreen")))return e.mode="disabled";(null===(n=i.subtitles)||void 0===n?void 0:n.native)||o.emit(t.type,{track:t.target})},e})),p(u,Subtitles.events.TRACKS,e.map((function(e){return{text:e.label,onclick:A.bind(0,o,e)}}))),v=e,!t)return w();A(o,t),p(u,Subtitles.events.SWITCH,{selected_index:v.indexOf(t)})}),o.on("cuechange",(function(n){var i;const s=null===(i=n.data)||void 0===i?void 0:i.track;if(!s||!["captions","subtitles","descriptions"].includes(s.kind))return;const o=Array.from(e(s,"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(d,o)})),o.on(["playlist/advance","src"],e=>{o.currentSrc&&("src"===e.type&&["is-playlist",a].some(e=>o.root.classList.contains(e))||(delete o.opts.subtitles,g(o),f=[],w(),v=[],m=[],b().forEach(e=>e.removed=!0),p(u,Subtitles.events.TRACKS,[])))})}}return Subtitles.events={TRACKS:"subs:tracks",SWITCH:"subs:change",TRACK_UPDATED:"tracks:text:updated"},function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;if(null===document.currentScript)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;"function"==typeof n?n(t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t))}(window,Subtitles),Subtitles}));
|
package/plugins/tizen.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.tizen=t())}(this,(function(){"use strict";var e={BACK:"Back",BACK1:"XF86Back",EXIT:"Exit",ENTER:"Enter",PLAY:"MediaPlay",PAUSE:"MediaPause",REWIND:"MediaRewind",FORWARD:"MediaFastForward",ARROW_LEFT:"ArrowLeft",ARROW_UP:"ArrowUp",ARROW_RIGHT:"ArrowRight",ARROW_DOWN:"ArrowDown"};const t="is-hovered",s=(e,t)=>new(((e,t)=>{const s=e.get(t);if(!s)throw new Error(`no flowplayer component with the name ${t} exists`);const n=window.customElements.get(t);if(!n)throw new Error(`no default flowplayer component with the name ${t} exists`);const i=window.customElements.get(s);return"function"!=typeof i?n:i})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}class TvMenu extends FlowplayerComponent{constructor(e){super(e),this.classList.add("tv-menu"),e.on("src",()=>this.classList.remove("is-open"))}append(e){super.append(e.menu)}is_empty(){const e=this.querySelectorAll(".fp-menu");return!(e&&Array.from(e).find(e=>"none"!==e.style.display))}find_focusable_menu(e,t){const s=Array.from(this.children);return(t?s:s.slice(0).reverse()).find((t,s,n)=>"none"!==t.style.display&&s>n.indexOf(e))}}const n="is-tv-seeking";let i=void 0;function o(e,t){e.enqueueSeek(t)&&function(e){e.setState("is-kb-active",!0),clearTimeout(i),i=setTimeout((function(){e.setState("is-kb-active",!1)}),2500)}(e)}class Tizen extends class TvPlugin{constructor(e){this.umd=e,this.should_restart=!1,this.previous_current_time=0,((e,t,s)=>{window.customElements.get(t)||window.customElements.define(t,s),e.customElements.get(t)||e.customElements.set(t,t)})(e,"flowplayer-tv-menu",TvMenu)}init(e,t,n){n.setState("is-tv",!0),this.menu=s(n,"flowplayer-tv-menu"),t.append(this.menu)}keydown_listener(e,t,s,n,i){var o,r;const a=this.is_linearAd_on(s);return a||e!==t.ARROW_UP||n.classList.contains("is-open")||n.is_empty()?!a&&n.classList.contains("is-open")?this.menu_handler(e,t,n):void this.main_handler(e,t,s,a,i):(n.classList.add("is-open"),null===(r=null===(o=Array.from(n.querySelectorAll(".fp-menu")).find(e=>"block"===e.style.display))||void 0===o?void 0:o.querySelector("li"))||void 0===r?void 0:r.focus())}menu_handler(e,t,s){var n,i,o;if([t.BACK,t.BACK1,t.EXIT].includes(e))return s.classList.remove("is-open");if([t.ARROW_UP,t.ARROW_DOWN,t.ARROW_RIGHT,t.ARROW_LEFT,t.ENTER].includes(e)){const r=document.activeElement,a=null===(n=document.activeElement)||void 0===n?void 0:n.closest(".fp-menu");if(!r||!a)return;if(e===t.ENTER)return r.dispatchEvent(new Event("click"));if(e===t.ARROW_DOWN&&r.nextSibling)return r.nextSibling.focus();if(e===t.ARROW_UP&&r.previousSibling)return r.previousSibling.focus();if([t.ARROW_RIGHT,t.ARROW_LEFT].includes(e))return null===(o=null===(i=s.find_focusable_menu(a,e===t.ARROW_RIGHT))||void 0===i?void 0:i.querySelector("li"))||void 0===o?void 0:o.focus()}}main_handler(e,t,s,n,i){switch(e){case t.ENTER:return this.on_enter(s,n);case t.PLAY:return this.on_play(s,n);case t.PAUSE:return s.togglePlay(!1);case t.FORWARD:case t.ARROW_RIGHT:return this.on_seek(s,i||10,n);case t.REWIND:case t.ARROW_LEFT:return this.on_seek(s,-(i||10),n);case t.BACK:case t.BACK2:case t.BACK1:case t.EXIT:return this.on_exit(s,n);case t.ARROW_DOWN:return this.on_arrow_down(s,n)}}on_play(e,s){return s?e.togglePlay(!0):(this.is_live_status_focused()&&!e.hasState(t)&&this.live_status_toggle_focus(e,!1),e.hasState(n)?void this.on_seek_end(e,!1):e.togglePlay(!0))}on_enter(e,t){var s;return t?e.togglePlay():this.is_live_status_focused()?(null===(s=e.root.querySelector(".fp-live-status"))||void 0===s||s.dispatchEvent(new Event("click")),this.live_status_toggle_focus(e,!1)):e.hasState(n)?this.on_seek_end(e,!1):e.togglePlay()}on_exit(e,s){return s?e.emit("fullscreen:exit"):this.is_live_status_focused()?this.live_status_toggle_focus(e,!1):e.hasState(n)?this.on_seek_end(e,!0):e.hasState(t)?e.setState(t,!1):e.emit("fullscreen:exit")}on_arrow_down(e,s){if(clearTimeout(this.hover_timeout),this.hover_timeout=setTimeout(()=>{e.setState(t,!1),this.live_status_toggle_focus(e,!1)},2e3),!e.hasState(t)&&!e.hasState("is-paused"))return e.setState(t,!0);s||!e.hasState("is-live")||e.hasState("no-timeline")||this.live_status_toggle_focus(e,!0)}on_seek(e,t,s){s||e.hasState("is-live")&&e.hasState("no-timeline")||(e.hasState(n)||(this.should_restart=!e.hasState("is-paused"),this.previous_current_time=e.currentTime),e.paused||e.togglePlay(!1),e.setState(n,!0),o(e,t))}on_seek_end(e,t){e.setState(n,!1),t&&(e.currentTime=this.previous_current_time),t&&!this.should_restart||e.togglePlay(!0)}live_status_toggle_focus(e,t){const s=e.root.querySelector(".fp-live-status");s&&(t?s.focus():s.blur())}is_live_status_focused(){var e;const t=document.activeElement;return null===(e=null==t?void 0:t.classList)||void 0===e?void 0:e.contains("fp-live-status")}is_linearAd_on(e){var t,s;return!(!e.hasState("ad-paused")&&!e.hasState("ad-playing")||!(null===(s=null===(t=null==e?void 0:e.ads)||void 0===t?void 0:t.adapter)||void 0===s?void 0:s._adLinear))}}{init(t,s,n){(function(){const e="undefined"!=typeof document&&"undefined"!=typeof window,t=e?navigator.userAgent:"",s=/iP(hone|od)/i.test(t)&&!/iPad/.test(t)&&!/IEMobile/i.test(t),n=/Android/.test(t)&&!/Firefox/.test(t),i=/^((?!chrome|android).)*safari/i.test(t),o=/SamsungBrowser/.test(t),
|
|
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.tizen=t())}(this,(function(){"use strict";var e={BACK:"Back",BACK1:"XF86Back",EXIT:"Exit",ENTER:"Enter",PLAY:"MediaPlay",PAUSE:"MediaPause",REWIND:"MediaRewind",FORWARD:"MediaFastForward",ARROW_LEFT:"ArrowLeft",ARROW_UP:"ArrowUp",ARROW_RIGHT:"ArrowRight",ARROW_DOWN:"ArrowDown"};const t="is-hovered",s=(e,t)=>new(((e,t)=>{const s=e.get(t);if(!s)throw new Error(`no flowplayer component with the name ${t} exists`);const n=window.customElements.get(t);if(!n)throw new Error(`no default flowplayer component with the name ${t} exists`);const i=window.customElements.get(s);return"function"!=typeof i?n:i})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}class TvMenu extends FlowplayerComponent{constructor(e){super(e),this.classList.add("tv-menu"),e.on("src",()=>this.classList.remove("is-open"))}append(e){super.append(e.menu)}is_empty(){const e=this.querySelectorAll(".fp-menu");return!(e&&Array.from(e).find(e=>"none"!==e.style.display))}find_focusable_menu(e,t){const s=Array.from(this.children);return(t?s:s.slice(0).reverse()).find((t,s,n)=>"none"!==t.style.display&&s>n.indexOf(e))}}const n="is-tv-seeking";let i=void 0;function o(e,t){e.enqueueSeek(t)&&function(e){e.setState("is-kb-active",!0),clearTimeout(i),i=setTimeout((function(){e.setState("is-kb-active",!1)}),2500)}(e)}class Tizen extends class TvPlugin{constructor(e){this.umd=e,this.should_restart=!1,this.previous_current_time=0,((e,t,s)=>{window.customElements.get(t)||window.customElements.define(t,s),e.customElements.get(t)||e.customElements.set(t,t)})(e,"flowplayer-tv-menu",TvMenu)}init(e,t,n){n.setState("is-tv",!0),this.menu=s(n,"flowplayer-tv-menu"),t.append(this.menu)}keydown_listener(e,t,s,n,i){var o,r;const a=this.is_linearAd_on(s);return a||e!==t.ARROW_UP||n.classList.contains("is-open")||n.is_empty()?!a&&n.classList.contains("is-open")?this.menu_handler(e,t,n):void this.main_handler(e,t,s,a,i):(n.classList.add("is-open"),null===(r=null===(o=Array.from(n.querySelectorAll(".fp-menu")).find(e=>"block"===e.style.display))||void 0===o?void 0:o.querySelector("li"))||void 0===r?void 0:r.focus())}menu_handler(e,t,s){var n,i,o;if([t.BACK,t.BACK1,t.EXIT].includes(e))return s.classList.remove("is-open");if([t.ARROW_UP,t.ARROW_DOWN,t.ARROW_RIGHT,t.ARROW_LEFT,t.ENTER].includes(e)){const r=document.activeElement,a=null===(n=document.activeElement)||void 0===n?void 0:n.closest(".fp-menu");if(!r||!a)return;if(e===t.ENTER)return r.dispatchEvent(new Event("click"));if(e===t.ARROW_DOWN&&r.nextSibling)return r.nextSibling.focus();if(e===t.ARROW_UP&&r.previousSibling)return r.previousSibling.focus();if([t.ARROW_RIGHT,t.ARROW_LEFT].includes(e))return null===(o=null===(i=s.find_focusable_menu(a,e===t.ARROW_RIGHT))||void 0===i?void 0:i.querySelector("li"))||void 0===o?void 0:o.focus()}}main_handler(e,t,s,n,i){switch(e){case t.ENTER:return this.on_enter(s,n);case t.PLAY:return this.on_play(s,n);case t.PAUSE:return s.togglePlay(!1);case t.FORWARD:case t.ARROW_RIGHT:return this.on_seek(s,i||10,n);case t.REWIND:case t.ARROW_LEFT:return this.on_seek(s,-(i||10),n);case t.BACK:case t.BACK2:case t.BACK1:case t.EXIT:return this.on_exit(s,n);case t.ARROW_DOWN:return this.on_arrow_down(s,n)}}on_play(e,s){return s?e.togglePlay(!0):(this.is_live_status_focused()&&!e.hasState(t)&&this.live_status_toggle_focus(e,!1),e.hasState(n)?void this.on_seek_end(e,!1):e.togglePlay(!0))}on_enter(e,t){var s;return t?e.togglePlay():this.is_live_status_focused()?(null===(s=e.root.querySelector(".fp-live-status"))||void 0===s||s.dispatchEvent(new Event("click")),this.live_status_toggle_focus(e,!1)):e.hasState(n)?this.on_seek_end(e,!1):e.togglePlay()}on_exit(e,s){return s?e.emit("fullscreen:exit"):this.is_live_status_focused()?this.live_status_toggle_focus(e,!1):e.hasState(n)?this.on_seek_end(e,!0):e.hasState(t)?e.setState(t,!1):e.emit("fullscreen:exit")}on_arrow_down(e,s){if(clearTimeout(this.hover_timeout),this.hover_timeout=setTimeout(()=>{e.setState(t,!1),this.live_status_toggle_focus(e,!1)},2e3),!e.hasState(t)&&!e.hasState("is-paused"))return e.setState(t,!0);s||!e.hasState("is-live")||e.hasState("no-timeline")||this.live_status_toggle_focus(e,!0)}on_seek(e,t,s){s||e.hasState("is-live")&&e.hasState("no-timeline")||(e.hasState(n)||(this.should_restart=!e.hasState("is-paused"),this.previous_current_time=e.currentTime),e.paused||e.togglePlay(!1),e.setState(n,!0),o(e,t))}on_seek_end(e,t){e.setState(n,!1),t&&(e.currentTime=this.previous_current_time),t&&!this.should_restart||e.togglePlay(!0)}live_status_toggle_focus(e,t){const s=e.root.querySelector(".fp-live-status");s&&(t?s.focus():s.blur())}is_live_status_focused(){var e;const t=document.activeElement;return null===(e=null==t?void 0:t.classList)||void 0===e?void 0:e.contains("fp-live-status")}is_linearAd_on(e){var t,s;return!(!e.hasState("ad-paused")&&!e.hasState("ad-playing")||!(null===(s=null===(t=null==e?void 0:e.ads)||void 0===t?void 0:t.adapter)||void 0===s?void 0:s._adLinear))}}{init(t,s,n){(function(){const e="undefined"!=typeof document&&"undefined"!=typeof window,t=e?navigator.userAgent:"",s=/iP(hone|od)/i.test(t)&&!/iPad/.test(t)&&!/IEMobile/i.test(t),n=/Android/.test(t)&&!/Firefox/.test(t),i=/^((?!chrome|android).)*safari/i.test(t),o=/chrome|crios/i.test(t)&&!/opr|opera|chromium|edg|ucbrowser|googlebot/i.test(t),r=/firefox|fxios/i.test(t)&&!/seamonkey/i.test(t),a=/edg/i.test(t),l=/opr|opera/i.test(t),u=/SamsungBrowser/.test(t),d=u&&/SMART-TV/.test(t);return{controls:!s,video:function(t){return e&&document.createElement("video").canPlayType(t)},lang:e&&window.navigator.language,android:n,iphone:s,safari:i,edge:a,opera:l,chrome:o,firefox:r,ios:e&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,samsung:u,samsung_tv:u&&d,touch:"ontouchstart"in window,tizen:"tizen"in window,webOS:"webos"in window}})().tizen&&(super.init(t,s,n),document.addEventListener("keydown",s=>{setTimeout(()=>{var i;!s.defaultPrevented&&Object.values(e).includes(s.key)&&this.keydown_listener(s.key,e,n,this.menu,null===(i=t.tizen)||void 0===i?void 0:i.seek_step)},0)}))}}return Tizen.events={EXIT_FULLSCREEN:"fullscreen:exit"},function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;if(null===document.currentScript)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const s=e.flowplayer;"function"==typeof s?s(t):(Array.isArray(s.extensions)||(s.extensions=[]),~s.extensions.indexOf(t)||s.extensions.push(t))}(window,Tizen),Tizen}));
|
package/plugins/webos.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.webos=t())}(this,(function(){"use strict";const e="is-hovered",t=(e,t)=>new(((e,t)=>{const s=e.get(t);if(!s)throw new Error(`no flowplayer component with the name ${t} exists`);const n=window.customElements.get(t);if(!n)throw new Error(`no default flowplayer component with the name ${t} exists`);const i=window.customElements.get(s);return"function"!=typeof i?n:i})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}class TvMenu extends FlowplayerComponent{constructor(e){super(e),this.classList.add("tv-menu"),e.on("src",()=>this.classList.remove("is-open"))}append(e){super.append(e.menu)}is_empty(){const e=this.querySelectorAll(".fp-menu");return!(e&&Array.from(e).find(e=>"none"!==e.style.display))}find_focusable_menu(e,t){const s=Array.from(this.children);return(t?s:s.slice(0).reverse()).find((t,s,n)=>"none"!==t.style.display&&s>n.indexOf(e))}}const s="is-tv-seeking";let n=void 0;function i(e,t){e.enqueueSeek(t)&&function(e){e.setState("is-kb-active",!0),clearTimeout(n),n=setTimeout((function(){e.setState("is-kb-active",!1)}),2500)}(e)}var o={EXIT:461,ENTER:13,PLAY:415,PAUSE:19,REWIND:412,FORWARD:417,ARROW_LEFT:37,ARROW_UP:38,ARROW_RIGHT:39,ARROW_DOWN:40};class Webos extends class TvPlugin{constructor(e){this.umd=e,this.should_restart=!1,this.previous_current_time=0,((e,t,s)=>{window.customElements.get(t)||window.customElements.define(t,s),e.customElements.get(t)||e.customElements.set(t,t)})(e,"flowplayer-tv-menu",TvMenu)}init(e,s,n){n.setState("is-tv",!0),this.menu=t(n,"flowplayer-tv-menu"),s.append(this.menu)}keydown_listener(e,t,s,n,i){var o,r;const a=this.is_linearAd_on(s);return a||e!==t.ARROW_UP||n.classList.contains("is-open")||n.is_empty()?!a&&n.classList.contains("is-open")?this.menu_handler(e,t,n):void this.main_handler(e,t,s,a,i):(n.classList.add("is-open"),null===(r=null===(o=Array.from(n.querySelectorAll(".fp-menu")).find(e=>"block"===e.style.display))||void 0===o?void 0:o.querySelector("li"))||void 0===r?void 0:r.focus())}menu_handler(e,t,s){var n,i,o;if([t.BACK,t.BACK1,t.EXIT].includes(e))return s.classList.remove("is-open");if([t.ARROW_UP,t.ARROW_DOWN,t.ARROW_RIGHT,t.ARROW_LEFT,t.ENTER].includes(e)){const r=document.activeElement,a=null===(n=document.activeElement)||void 0===n?void 0:n.closest(".fp-menu");if(!r||!a)return;if(e===t.ENTER)return r.dispatchEvent(new Event("click"));if(e===t.ARROW_DOWN&&r.nextSibling)return r.nextSibling.focus();if(e===t.ARROW_UP&&r.previousSibling)return r.previousSibling.focus();if([t.ARROW_RIGHT,t.ARROW_LEFT].includes(e))return null===(o=null===(i=s.find_focusable_menu(a,e===t.ARROW_RIGHT))||void 0===i?void 0:i.querySelector("li"))||void 0===o?void 0:o.focus()}}main_handler(e,t,s,n,i){switch(e){case t.ENTER:return this.on_enter(s,n);case t.PLAY:return this.on_play(s,n);case t.PAUSE:return s.togglePlay(!1);case t.FORWARD:case t.ARROW_RIGHT:return this.on_seek(s,i||10,n);case t.REWIND:case t.ARROW_LEFT:return this.on_seek(s,-(i||10),n);case t.BACK:case t.BACK2:case t.BACK1:case t.EXIT:return this.on_exit(s,n);case t.ARROW_DOWN:return this.on_arrow_down(s,n)}}on_play(t,n){return n?t.togglePlay(!0):(this.is_live_status_focused()&&!t.hasState(e)&&this.live_status_toggle_focus(t,!1),t.hasState(s)?void this.on_seek_end(t,!1):t.togglePlay(!0))}on_enter(e,t){var n;return t?e.togglePlay():this.is_live_status_focused()?(null===(n=e.root.querySelector(".fp-live-status"))||void 0===n||n.dispatchEvent(new Event("click")),this.live_status_toggle_focus(e,!1)):e.hasState(s)?this.on_seek_end(e,!1):e.togglePlay()}on_exit(t,n){return n?t.emit("fullscreen:exit"):this.is_live_status_focused()?this.live_status_toggle_focus(t,!1):t.hasState(s)?this.on_seek_end(t,!0):t.hasState(e)?t.setState(e,!1):t.emit("fullscreen:exit")}on_arrow_down(t,s){if(clearTimeout(this.hover_timeout),this.hover_timeout=setTimeout(()=>{t.setState(e,!1),this.live_status_toggle_focus(t,!1)},2e3),!t.hasState(e)&&!t.hasState("is-paused"))return t.setState(e,!0);s||!t.hasState("is-live")||t.hasState("no-timeline")||this.live_status_toggle_focus(t,!0)}on_seek(e,t,n){n||e.hasState("is-live")&&e.hasState("no-timeline")||(e.hasState(s)||(this.should_restart=!e.hasState("is-paused"),this.previous_current_time=e.currentTime),e.paused||e.togglePlay(!1),e.setState(s,!0),i(e,t))}on_seek_end(e,t){e.setState(s,!1),t&&(e.currentTime=this.previous_current_time),t&&!this.should_restart||e.togglePlay(!0)}live_status_toggle_focus(e,t){const s=e.root.querySelector(".fp-live-status");s&&(t?s.focus():s.blur())}is_live_status_focused(){var e;const t=document.activeElement;return null===(e=null==t?void 0:t.classList)||void 0===e?void 0:e.contains("fp-live-status")}is_linearAd_on(e){var t,s;return!(!e.hasState("ad-paused")&&!e.hasState("ad-playing")||!(null===(s=null===(t=null==e?void 0:e.ads)||void 0===t?void 0:t.adapter)||void 0===s?void 0:s._adLinear))}}{init(e,t,s){(function(){const e="undefined"!=typeof document&&"undefined"!=typeof window,t=e?navigator.userAgent:"",s=/iP(hone|od)/i.test(t)&&!/iPad/.test(t)&&!/IEMobile/i.test(t),n=/Android/.test(t)&&!/Firefox/.test(t),i=/^((?!chrome|android).)*safari/i.test(t),o=/SamsungBrowser/.test(t),
|
|
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.webos=t())}(this,(function(){"use strict";const e="is-hovered",t=(e,t)=>new(((e,t)=>{const s=e.get(t);if(!s)throw new Error(`no flowplayer component with the name ${t} exists`);const n=window.customElements.get(t);if(!n)throw new Error(`no default flowplayer component with the name ${t} exists`);const i=window.customElements.get(s);return"function"!=typeof i?n:i})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}class TvMenu extends FlowplayerComponent{constructor(e){super(e),this.classList.add("tv-menu"),e.on("src",()=>this.classList.remove("is-open"))}append(e){super.append(e.menu)}is_empty(){const e=this.querySelectorAll(".fp-menu");return!(e&&Array.from(e).find(e=>"none"!==e.style.display))}find_focusable_menu(e,t){const s=Array.from(this.children);return(t?s:s.slice(0).reverse()).find((t,s,n)=>"none"!==t.style.display&&s>n.indexOf(e))}}const s="is-tv-seeking";let n=void 0;function i(e,t){e.enqueueSeek(t)&&function(e){e.setState("is-kb-active",!0),clearTimeout(n),n=setTimeout((function(){e.setState("is-kb-active",!1)}),2500)}(e)}var o={EXIT:461,ENTER:13,PLAY:415,PAUSE:19,REWIND:412,FORWARD:417,ARROW_LEFT:37,ARROW_UP:38,ARROW_RIGHT:39,ARROW_DOWN:40};class Webos extends class TvPlugin{constructor(e){this.umd=e,this.should_restart=!1,this.previous_current_time=0,((e,t,s)=>{window.customElements.get(t)||window.customElements.define(t,s),e.customElements.get(t)||e.customElements.set(t,t)})(e,"flowplayer-tv-menu",TvMenu)}init(e,s,n){n.setState("is-tv",!0),this.menu=t(n,"flowplayer-tv-menu"),s.append(this.menu)}keydown_listener(e,t,s,n,i){var o,r;const a=this.is_linearAd_on(s);return a||e!==t.ARROW_UP||n.classList.contains("is-open")||n.is_empty()?!a&&n.classList.contains("is-open")?this.menu_handler(e,t,n):void this.main_handler(e,t,s,a,i):(n.classList.add("is-open"),null===(r=null===(o=Array.from(n.querySelectorAll(".fp-menu")).find(e=>"block"===e.style.display))||void 0===o?void 0:o.querySelector("li"))||void 0===r?void 0:r.focus())}menu_handler(e,t,s){var n,i,o;if([t.BACK,t.BACK1,t.EXIT].includes(e))return s.classList.remove("is-open");if([t.ARROW_UP,t.ARROW_DOWN,t.ARROW_RIGHT,t.ARROW_LEFT,t.ENTER].includes(e)){const r=document.activeElement,a=null===(n=document.activeElement)||void 0===n?void 0:n.closest(".fp-menu");if(!r||!a)return;if(e===t.ENTER)return r.dispatchEvent(new Event("click"));if(e===t.ARROW_DOWN&&r.nextSibling)return r.nextSibling.focus();if(e===t.ARROW_UP&&r.previousSibling)return r.previousSibling.focus();if([t.ARROW_RIGHT,t.ARROW_LEFT].includes(e))return null===(o=null===(i=s.find_focusable_menu(a,e===t.ARROW_RIGHT))||void 0===i?void 0:i.querySelector("li"))||void 0===o?void 0:o.focus()}}main_handler(e,t,s,n,i){switch(e){case t.ENTER:return this.on_enter(s,n);case t.PLAY:return this.on_play(s,n);case t.PAUSE:return s.togglePlay(!1);case t.FORWARD:case t.ARROW_RIGHT:return this.on_seek(s,i||10,n);case t.REWIND:case t.ARROW_LEFT:return this.on_seek(s,-(i||10),n);case t.BACK:case t.BACK2:case t.BACK1:case t.EXIT:return this.on_exit(s,n);case t.ARROW_DOWN:return this.on_arrow_down(s,n)}}on_play(t,n){return n?t.togglePlay(!0):(this.is_live_status_focused()&&!t.hasState(e)&&this.live_status_toggle_focus(t,!1),t.hasState(s)?void this.on_seek_end(t,!1):t.togglePlay(!0))}on_enter(e,t){var n;return t?e.togglePlay():this.is_live_status_focused()?(null===(n=e.root.querySelector(".fp-live-status"))||void 0===n||n.dispatchEvent(new Event("click")),this.live_status_toggle_focus(e,!1)):e.hasState(s)?this.on_seek_end(e,!1):e.togglePlay()}on_exit(t,n){return n?t.emit("fullscreen:exit"):this.is_live_status_focused()?this.live_status_toggle_focus(t,!1):t.hasState(s)?this.on_seek_end(t,!0):t.hasState(e)?t.setState(e,!1):t.emit("fullscreen:exit")}on_arrow_down(t,s){if(clearTimeout(this.hover_timeout),this.hover_timeout=setTimeout(()=>{t.setState(e,!1),this.live_status_toggle_focus(t,!1)},2e3),!t.hasState(e)&&!t.hasState("is-paused"))return t.setState(e,!0);s||!t.hasState("is-live")||t.hasState("no-timeline")||this.live_status_toggle_focus(t,!0)}on_seek(e,t,n){n||e.hasState("is-live")&&e.hasState("no-timeline")||(e.hasState(s)||(this.should_restart=!e.hasState("is-paused"),this.previous_current_time=e.currentTime),e.paused||e.togglePlay(!1),e.setState(s,!0),i(e,t))}on_seek_end(e,t){e.setState(s,!1),t&&(e.currentTime=this.previous_current_time),t&&!this.should_restart||e.togglePlay(!0)}live_status_toggle_focus(e,t){const s=e.root.querySelector(".fp-live-status");s&&(t?s.focus():s.blur())}is_live_status_focused(){var e;const t=document.activeElement;return null===(e=null==t?void 0:t.classList)||void 0===e?void 0:e.contains("fp-live-status")}is_linearAd_on(e){var t,s;return!(!e.hasState("ad-paused")&&!e.hasState("ad-playing")||!(null===(s=null===(t=null==e?void 0:e.ads)||void 0===t?void 0:t.adapter)||void 0===s?void 0:s._adLinear))}}{init(e,t,s){(function(){const e="undefined"!=typeof document&&"undefined"!=typeof window,t=e?navigator.userAgent:"",s=/iP(hone|od)/i.test(t)&&!/iPad/.test(t)&&!/IEMobile/i.test(t),n=/Android/.test(t)&&!/Firefox/.test(t),i=/^((?!chrome|android).)*safari/i.test(t),o=/chrome|crios/i.test(t)&&!/opr|opera|chromium|edg|ucbrowser|googlebot/i.test(t),r=/firefox|fxios/i.test(t)&&!/seamonkey/i.test(t),a=/edg/i.test(t),l=/opr|opera/i.test(t),u=/SamsungBrowser/.test(t),c=u&&/SMART-TV/.test(t);return{controls:!s,video:function(t){return e&&document.createElement("video").canPlayType(t)},lang:e&&window.navigator.language,android:n,iphone:s,safari:i,edge:a,opera:l,chrome:o,firefox:r,ios:e&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,samsung:u,samsung_tv:u&&c,touch:"ontouchstart"in window,tizen:"tizen"in window,webOS:"webos"in window}})().webOS&&(super.init(e,t,s),document.addEventListener("keydown",t=>{setTimeout(()=>{var n;!t.defaultPrevented&&Object.values(o).includes(t.keyCode)&&this.keydown_listener(t.keyCode,o,s,this.menu,null===(n=e.webos)||void 0===n?void 0:n.seek_step)},0)}))}}return Webos.events={EXIT_FULLSCREEN:"fullscreen:exit"},function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;if(null===document.currentScript)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const s=e.flowplayer;"function"==typeof s?s(t):(Array.isArray(s.extensions)||(s.extensions=[]),~s.extensions.indexOf(t)||s.extensions.push(t))}(window,Webos),Webos}));
|