@flowplayer/player 3.40.0-rc → 3.40.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core.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 +1 -1
- package/plugins/analytics.js +1 -1
- package/plugins/asel.js +1 -1
- package/plugins/qsel.js +1 -1
- package/plugins/rts.js +6 -6
- package/plugins/share.js +1 -1
- package/plugins/speed.js +1 -1
- package/plugins/ssai.js +1 -1
- package/plugins/ui-redesign.js +1 -1
- package/plugins/vtsel.js +1 -1
package/plugins/analytics.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.analytics=t())}(this,function(){"use strict";const e=(...e)=>e.reduce((e,t)=>Object.assign(Object.assign({},e),t),{}),t=(e,t)=>{const r=e.lastIndexOf(t);return~r&&e.splice(r,1),e};class RequestQueue{static of(){return new RequestQueue}static is_empty(e){return 0==e.pending.length}static is_high_water(e){return e.open.length==RequestQueue.MAX_OPEN_REQUESTS}static maybe_spawn_req(e){if(RequestQueue.is_empty(e))return e;if(RequestQueue.is_high_water(e))return e;try{const t=RequestQueue.lpop(e);t&&RequestQueue.request(e,t)}catch(e){}}static increment_failures(e){return e.stats.failures++,e.stats.failures>RequestQueue.MAX_FAILURE_COUNT&&(e.stats.ttl=Date.now()+RequestQueue.REQUEST_TTL_MS),e}static handle_error(e,t){RequestQueue.rm(e,t),RequestQueue.increment_failures(e)}static request(e,[t,r,n]){if(Date.now()<e.stats.ttl)return;const i=new XMLHttpRequest;e.open.push(i),i.timeout=RequestQueue.REQUEST_TIMEOUT_MS,i.ontimeout=function(){RequestQueue.handle_error(e,i)},i.onerror=function(t){RequestQueue.handle_error(e,i)},i.onreadystatechange=function(){i.readyState==XMLHttpRequest.DONE&&RequestQueue.rm(e,i),Math.floor(i.status/100)},i.onload=function(){RequestQueue.rm(e,i),e.stats.failures&&e.stats.failures--},i.open(r,t),i.setRequestHeader("Content-Type","text/plain;charset=UTF-8");try{i.send(JSON.stringify(n))}catch(e){}}static rpush(e,...t){return t.forEach(t=>{e.pending.length>=RequestQueue.MAX_PENDING||(e.pending.push(t),RequestQueue.maybe_spawn_req(e))}),e}static lpop(e){return e.pending.shift()}static rm(e,r){return t(e.open,r),e}constructor(){this.pending=[],this.open=[],this.stats={failures:0,ttl:0}}}RequestQueue.MAX_OPEN_REQUESTS=3,RequestQueue.MAX_PENDING=5,RequestQueue.REQUEST_TIMEOUT_MS=4e3,RequestQueue.REQUEST_TTL_MS=5e3,RequestQueue.MAX_FAILURE_COUNT=3;var r=RequestQueue.of();const n=/:([a-zA-Z_]+)/g;class Log{static prepare(e,t){const r=document.createEvent("Event");return r.initEvent(e,!1,!0),r.ns=e,r.data=t,r}static of(e){return new Log(e)}constructor(e){this.emitter=e}info(e){this.emitter.dispatchEvent(Log.prepare(Log.NAMESPACE.INFO,e))}error(e){this.emitter.dispatchEvent(Log.prepare(Log.NAMESPACE.ERROR,e))}warn(e){this.emitter.dispatchEvent(Log.prepare(Log.NAMESPACE.WARN,e))}}var i;Log.NAMESPACE={INFO:"tracker:info",ERROR:"tracker:err",WARN:"tracker:warn"},function(e){e.POST="POST",e.PUT="PUT",e.GET="GET"}(i||(i={}));class Tracker{static of(e,t){return new Tracker(e,t)}static ensure_required_keys(e,t){return e.required_keys.filter(e=>!(e in t))}static pluck_valid_keys(t,r){return((t,...r)=>Object.keys(t).filter(e=>~r.indexOf(e)).reduce((r,n)=>e(r,{[n]:t[n]}),{}))(r,...t.valid_keys)}static merge_metadata(t,r={}){return t.metadata=Tracker.pluck_valid_keys(t,e(t.metadata,r)),t}static assert_emitter_api(e){if("function"!=typeof(e||{}).addEventListener)throw new Error("Tracker() received an emitter that does not implement the addEventListener method");if("function"!=typeof(e||{}).removeEventListener)throw new Error("Tracker() received an emitter that does not implement the removeEventListener method")}static create_listener(e,t,r){var n;e.listeners.push([t,r]),null===(n=e.emitter)||void 0===n||n.addEventListener(t,r)}constructor(t,i={}){const o=this;if(this.emitter=t,this.url=i.url,this.log=Log.of(this.emitter),this.verb=i.verb,this.metadata=e({},i.metadata||{}),this.rq=i.rq||r,this.events=i.events||[],this.required_keys=i.required_keys||[],this.optional_keys=i.optional_keys||[],this.listeners=[],this.valid_keys=this.required_keys.slice(0).concat(this.optional_keys),Tracker.assert_emitter_api(this.emitter),void 0===Tracker.verb[this.verb])throw new Error(`invalid HTTP verb[${this.verb}] passed`);if("string"!=typeof this.url)throw new Error(`invalid API url[${this.url}] passed`);Tracker.TRACKERS.push(this),o.events.forEach(t=>{Tracker.create_listener(this,t,(r={})=>{var i;if(null===(i=this.emitter)||void 0===i?void 0:i.hasState("consent-no-tracking"))return;const a=e(o.metadata,{event_type:t},r.data||r),s=function(e,t){return e.replace(n,e=>{const r=e.slice(1,e.length);return r in t?t[r].toString():e})}(o.url,a),u=Tracker.pluck_valid_keys(o,a),d=Tracker.ensure_required_keys(o,u);if(d.length)return o.log.error(`Tracker.validate_metadata() failed for\n Event[${t}]\n missing keys: ${d}\n payload:\n ${JSON.stringify(u,null,2)}`);this.rq&&RequestQueue.rpush(this.rq,[s,this.verb,u])})})}destroy(){this.listeners.forEach(([e,t])=>{var r;return null===(r=this.emitter)||void 0===r?void 0:r.removeEventListener(e,t)}),delete this.rq,delete this.emitter,t(Tracker.TRACKERS,this)}put(e={}){return Tracker.merge_metadata(this,e),this}}var o;Tracker.TRACKERS=[],Tracker.QUEUE=r,Tracker.verb=i,function(e){e[e.ADS=2]="ADS",e[e.ANALYTICS=4]="ANALYTICS",e[e.NO_METERING=8]="NO_METERING",e[e.DEVELOPER_PLAN=16]="DEVELOPER_PLAN",e[e.WOWZA_VIDEO=32]="WOWZA_VIDEO"}(o||(o={}));const a=["localhost","127.0.0.1","0.0.0.0","s.codepen.io","cdpn.io","try.flowplayer.com"];function s(e,t){return!!~a.indexOf(e)||e.indexOf(t)===e.length-t.length}s.check_whitelist=function(e){return!!~a.indexOf(e)};function u(e){this.message=e}u.prototype=new Error,u.prototype.name="InvalidCharacterError";var d="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new u("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,i=0,o=0,a="";n=t.charAt(o++);~n&&(r=i%4?64*r+n:n,i++%4)?a+=String.fromCharCode(255&r>>(-2*i&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return a};var c=function(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(d(e).replace(/(.)/g,function(e,t){var r=t.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r}))}(t)}catch(e){return d(t)}};function l(e){this.message=e}l.prototype=new Error,l.prototype.name="InvalidTokenError";var f=function(e,t){if("string"!=typeof e)throw new l("Invalid token specified");var r=!0===(t=t||{}).header?0:1;try{return JSON.parse(c(e.split(".")[r]))}catch(e){throw new l("Invalid token specified: "+e.message)}};f.InvalidTokenError=l;const p="production";function _(e,t){const r={valid_jwt:!1,raw:"",data:{acl:0},exp:0};let n={c:"{}",exp:0};t=t||{};try{n=f(e),r.valid_jwt=!0}catch(e){}return r.raw=e,r.data=JSON.parse(n.c),r.exp=n.exp,t.require_valid_token&&_.validate(r),r}function h(e){return{grant:e,is_granted:t=>(e&t)===t}}function m(e,t,r){const n=function(e){return Array.isArray(e)?e.slice(0):e.split(".")}(t);for(;n.length;){if(null==e)return r;const t=n.shift();if("string"!=typeof t)return r;e=e[t]}return null==e?r:e}_.validate=function(e){if("string"==typeof e&&(e=_(e)),!e||!e.raw){if(s.check_whitelist(window.location.hostname)||"dev"===p.toString())return!0;throw new Error("No token provided in configuration")}if(!e.valid_jwt)throw new Error("Invalid token provided");const t=window.location.hostname,r=s.bind(null,t);if("dev"!==p.toString()&&e.data.domain&&e.data.domain.length&&!e.data.domain.some(r))throw new Error("Domain not allowed");if("dev"!==p.toString()&&1e3*e.exp-Date.now()<0)throw new Error("Expired token");return!0},_.id=function(e){if(e)return"string"==typeof e&&(e=_(e)),e.data.id},h.of=h,h.from_token=function(e){const t=_(e,{require_valid_token:!0});return h.of(t.data.acl)},h.permissions=o;var v="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};var y="ping",k="display",g="view";const w=["sitegroup_id","session_id","media_id","site_id","player_id","video_type"],E=["created","position"],T=["player_version","created","source","category","category_id","autoplay","muted","customer_user_id"];const R="is-seeking";const q=100,A=1e3;function S(e,t){return e.duration/1===e.duration&&Object.assign(t,function(e){const t=e/q;return{segment_duration:t,breakpoints:Array(...Array(q)).map(function(e,r){return Math.floor(r*t*A)/A})}}(e.duration))}function O(e,t,r){if(!t.segment_duration&&!S(e,t))return;const n=function(e,t,r){const n=t.last_idx,i=r?99:b(e,t);return t.last_idx=i,i<=n?[]:t.breakpoints.slice(n,99==i?100:i).map(function(e){return t.breakpoints.indexOf(e)})}(e,t,r);0!=n.length&&e.emit(y,{position:n})}function b(e,t){return Math.min(Math.floor(e.currentTime/t.segment_duration),99)}function N(){try{const e=window.location!==window.parent.location?document.referrer:document.location.href;return"string"==typeof e&&e.slice(0,200)}catch(e){return!1}}var Q;const x="vod",L="live",I=[k,y,g];function M(e,t,r){switch(null==t?void 0:t.kind){case"live":return function(e,t){const r=Date.now();r-t.last_tracked_ts<6e4||(t.last_tracked_ts=r,++t.ticks,e.emit(y,{position:60*t.ticks}))}(e,t);case"vod":return O(e,t,"boolean"==typeof r&&r)}}function P(e){const t=e.ads;return void 0!==t&&(void 0!==t.schedule&&("function"==typeof t.hasPreroll&&(t.currentRequests?t.currentRequests:!!t.adPlaying||!(!t.hasPreroll()||0!=t.nextIndex))))}const C=((Q=class Analytics{init(e,t,r){if(!h.from_token(e.token||"").is_granted(h.permissions.ANALYTICS))return;if(r.analytics)return;const n=r.analytics={ticker:void 0,last_media_id:"",ended:!1,played:!1},i={locked:void 0,ttl:6e3,task:()=>{r.hasState(R)||M(r,n.ticker)}};const o={session_id:r.deviceId(),autoplay:r.autoplay,muted:r.muted,player_id:e.player_id,customer_user_id:e.customer_user_id,player_version:"3.40.0-rc"},a=Tracker.of(r,{verb:Tracker.verb.POST,url:"https://ptm.flowplayer.com/:video_type/:sitegroup_id/:event_type",events:I,required_keys:w,optional_keys:T.concat(E).slice(0),metadata:o});r.on("reap",function(){a&&a.destroy()}),r.on("config",function(t){if(!a)return;const i=m(t,"data.metadata",{});if(!i.media_id&&i.stream_target_id&&(i.media_id=i.stream_target_id),!i.media_id)return n.last_media_id="";if(n.last_media_id===i.media_id)return;n.played=!1,n.last_media_id=i.media_id;const o=m(e,"analytics",{});a.put(i),a.put(o);const s=m(e,"metadata.live_start_time",e.live)?L:x;a.put({video_type:s,source:e.source||N()||""}),n.ticker=e.live?{ticks:0,last_tracked_ts:Date.now(),kind:"live"}:{last_idx:0,segment_duration:0,breakpoints:[],kind:"vod"},n.ended=!1,r.emit(k)});let s=0;r.on("playing",function(){if(!a)return;if(s||n.played||!n.last_media_id)return;a.put({muted:r.muted});const e=P(r);if(e)return s=Promise.resolve(e).then(function(){n.played=!0,r.emit(g),s=0}).catch(function(){s=0});n.played=!0,r.emit(g)}),r.on("timeupdate",function(){var t;a&&(s||P(r)||n.ended||!n.last_media_id||r.hasState(R)||(!e.live&&r.currentTime+.25>=r.duration&&M(r,n.ticker,!0),(t=i).locked||(t.locked=setTimeout(function(){return t.task(),function(e){return e.locked=void 0,e}(t)},t.ttl))))}),r.on("seeked",function(){a&&n.last_media_id&&n.ticker&&"vod"==n.ticker.kind&&function(e,t){S(e,t),t.last_idx=b(e,t)}(r,n.ticker)}),r.on("timeline/gesture/start",function(){M(r,n.ticker)}),r.on("ended",function(){a&&n.last_media_id&&function(e,t){t.ended||(t.ended=!0,M(e,t.ticker))}(r,n)})}}).pluginName="analytics",Q),U=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 r=e.flowplayer;return"function"==typeof r?(r(t),t):(Array.isArray(r.extensions)||(r.extensions=[]),~r.extensions.indexOf(t)||r.extensions.push(t),t)}("undefined"!=typeof window?window:void 0!==v?v:{},C);return U});
|
|
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.analytics=t())}(this,function(){"use strict";const e=(...e)=>e.reduce((e,t)=>Object.assign(Object.assign({},e),t),{}),t=(e,t)=>{const r=e.lastIndexOf(t);return~r&&e.splice(r,1),e};class RequestQueue{static of(){return new RequestQueue}static is_empty(e){return 0==e.pending.length}static is_high_water(e){return e.open.length==RequestQueue.MAX_OPEN_REQUESTS}static maybe_spawn_req(e){if(RequestQueue.is_empty(e))return e;if(RequestQueue.is_high_water(e))return e;try{const t=RequestQueue.lpop(e);t&&RequestQueue.request(e,t)}catch(e){}}static increment_failures(e){return e.stats.failures++,e.stats.failures>RequestQueue.MAX_FAILURE_COUNT&&(e.stats.ttl=Date.now()+RequestQueue.REQUEST_TTL_MS),e}static handle_error(e,t){RequestQueue.rm(e,t),RequestQueue.increment_failures(e)}static request(e,[t,r,n]){if(Date.now()<e.stats.ttl)return;const i=new XMLHttpRequest;e.open.push(i),i.timeout=RequestQueue.REQUEST_TIMEOUT_MS,i.ontimeout=function(){RequestQueue.handle_error(e,i)},i.onerror=function(t){RequestQueue.handle_error(e,i)},i.onreadystatechange=function(){i.readyState==XMLHttpRequest.DONE&&RequestQueue.rm(e,i),Math.floor(i.status/100)},i.onload=function(){RequestQueue.rm(e,i),e.stats.failures&&e.stats.failures--},i.open(r,t),i.setRequestHeader("Content-Type","text/plain;charset=UTF-8");try{i.send(JSON.stringify(n))}catch(e){}}static rpush(e,...t){return t.forEach(t=>{e.pending.length>=RequestQueue.MAX_PENDING||(e.pending.push(t),RequestQueue.maybe_spawn_req(e))}),e}static lpop(e){return e.pending.shift()}static rm(e,r){return t(e.open,r),e}constructor(){this.pending=[],this.open=[],this.stats={failures:0,ttl:0}}}RequestQueue.MAX_OPEN_REQUESTS=3,RequestQueue.MAX_PENDING=5,RequestQueue.REQUEST_TIMEOUT_MS=4e3,RequestQueue.REQUEST_TTL_MS=5e3,RequestQueue.MAX_FAILURE_COUNT=3;var r=RequestQueue.of();const n=/:([a-zA-Z_]+)/g;class Log{static prepare(e,t){const r=document.createEvent("Event");return r.initEvent(e,!1,!0),r.ns=e,r.data=t,r}static of(e){return new Log(e)}constructor(e){this.emitter=e}info(e){this.emitter.dispatchEvent(Log.prepare(Log.NAMESPACE.INFO,e))}error(e){this.emitter.dispatchEvent(Log.prepare(Log.NAMESPACE.ERROR,e))}warn(e){this.emitter.dispatchEvent(Log.prepare(Log.NAMESPACE.WARN,e))}}var i;Log.NAMESPACE={INFO:"tracker:info",ERROR:"tracker:err",WARN:"tracker:warn"},function(e){e.POST="POST",e.PUT="PUT",e.GET="GET"}(i||(i={}));class Tracker{static of(e,t){return new Tracker(e,t)}static ensure_required_keys(e,t){return e.required_keys.filter(e=>!(e in t))}static pluck_valid_keys(t,r){return((t,...r)=>Object.keys(t).filter(e=>~r.indexOf(e)).reduce((r,n)=>e(r,{[n]:t[n]}),{}))(r,...t.valid_keys)}static merge_metadata(t,r={}){return t.metadata=Tracker.pluck_valid_keys(t,e(t.metadata,r)),t}static assert_emitter_api(e){if("function"!=typeof(e||{}).addEventListener)throw new Error("Tracker() received an emitter that does not implement the addEventListener method");if("function"!=typeof(e||{}).removeEventListener)throw new Error("Tracker() received an emitter that does not implement the removeEventListener method")}static create_listener(e,t,r){var n;e.listeners.push([t,r]),null===(n=e.emitter)||void 0===n||n.addEventListener(t,r)}constructor(t,i={}){const o=this;if(this.emitter=t,this.url=i.url,this.log=Log.of(this.emitter),this.verb=i.verb,this.metadata=e({},i.metadata||{}),this.rq=i.rq||r,this.events=i.events||[],this.required_keys=i.required_keys||[],this.optional_keys=i.optional_keys||[],this.listeners=[],this.valid_keys=this.required_keys.slice(0).concat(this.optional_keys),Tracker.assert_emitter_api(this.emitter),void 0===Tracker.verb[this.verb])throw new Error(`invalid HTTP verb[${this.verb}] passed`);if("string"!=typeof this.url)throw new Error(`invalid API url[${this.url}] passed`);Tracker.TRACKERS.push(this),o.events.forEach(t=>{Tracker.create_listener(this,t,(r={})=>{var i;if(null===(i=this.emitter)||void 0===i?void 0:i.hasState("consent-no-tracking"))return;const a=e(o.metadata,{event_type:t},r.data||r),s=function(e,t){return e.replace(n,e=>{const r=e.slice(1,e.length);return r in t?t[r].toString():e})}(o.url,a),u=Tracker.pluck_valid_keys(o,a),d=Tracker.ensure_required_keys(o,u);if(d.length)return o.log.error(`Tracker.validate_metadata() failed for\n Event[${t}]\n missing keys: ${d}\n payload:\n ${JSON.stringify(u,null,2)}`);this.rq&&RequestQueue.rpush(this.rq,[s,this.verb,u])})})}destroy(){this.listeners.forEach(([e,t])=>{var r;return null===(r=this.emitter)||void 0===r?void 0:r.removeEventListener(e,t)}),delete this.rq,delete this.emitter,t(Tracker.TRACKERS,this)}put(e={}){return Tracker.merge_metadata(this,e),this}}var o;Tracker.TRACKERS=[],Tracker.QUEUE=r,Tracker.verb=i,function(e){e[e.ADS=2]="ADS",e[e.ANALYTICS=4]="ANALYTICS",e[e.NO_METERING=8]="NO_METERING",e[e.DEVELOPER_PLAN=16]="DEVELOPER_PLAN",e[e.WOWZA_VIDEO=32]="WOWZA_VIDEO"}(o||(o={}));const a=["localhost","127.0.0.1","0.0.0.0","s.codepen.io","cdpn.io","try.flowplayer.com"];function s(e,t){return!!~a.indexOf(e)||e.indexOf(t)===e.length-t.length}s.check_whitelist=function(e){return!!~a.indexOf(e)};function u(e){this.message=e}u.prototype=new Error,u.prototype.name="InvalidCharacterError";var d="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new u("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,i=0,o=0,a="";n=t.charAt(o++);~n&&(r=i%4?64*r+n:n,i++%4)?a+=String.fromCharCode(255&r>>(-2*i&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return a};var c=function(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(d(e).replace(/(.)/g,function(e,t){var r=t.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r}))}(t)}catch(e){return d(t)}};function l(e){this.message=e}l.prototype=new Error,l.prototype.name="InvalidTokenError";var f=function(e,t){if("string"!=typeof e)throw new l("Invalid token specified");var r=!0===(t=t||{}).header?0:1;try{return JSON.parse(c(e.split(".")[r]))}catch(e){throw new l("Invalid token specified: "+e.message)}};f.InvalidTokenError=l;const p="production";function _(e,t){const r={valid_jwt:!1,raw:"",data:{acl:0},exp:0};let n={c:"{}",exp:0};t=t||{};try{n=f(e),r.valid_jwt=!0}catch(e){}return r.raw=e,r.data=JSON.parse(n.c),r.exp=n.exp,t.require_valid_token&&_.validate(r),r}function h(e){return{grant:e,is_granted:t=>(e&t)===t}}function m(e,t,r){const n=function(e){return Array.isArray(e)?e.slice(0):e.split(".")}(t);for(;n.length;){if(null==e)return r;const t=n.shift();if("string"!=typeof t)return r;e=e[t]}return null==e?r:e}_.validate=function(e){if("string"==typeof e&&(e=_(e)),!e||!e.raw){if(s.check_whitelist(window.location.hostname)||"dev"===p.toString())return!0;throw new Error("No token provided in configuration")}if(!e.valid_jwt)throw new Error("Invalid token provided");const t=window.location.hostname,r=s.bind(null,t);if("dev"!==p.toString()&&e.data.domain&&e.data.domain.length&&!e.data.domain.some(r))throw new Error("Domain not allowed");if("dev"!==p.toString()&&1e3*e.exp-Date.now()<0)throw new Error("Expired token");return!0},_.id=function(e){if(e)return"string"==typeof e&&(e=_(e)),e.data.id},h.of=h,h.from_token=function(e){const t=_(e,{require_valid_token:!0});return h.of(t.data.acl)},h.permissions=o;var v="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};var y="ping",k="display",g="view";const w=["sitegroup_id","session_id","media_id","site_id","player_id","video_type"],E=["created","position"],T=["player_version","created","source","category","category_id","autoplay","muted","customer_user_id"];const R="is-seeking";const q=100,A=1e3;function S(e,t){return e.duration/1===e.duration&&Object.assign(t,function(e){const t=e/q;return{segment_duration:t,breakpoints:Array(...Array(q)).map(function(e,r){return Math.floor(r*t*A)/A})}}(e.duration))}function O(e,t,r){if(!t.segment_duration&&!S(e,t))return;const n=function(e,t,r){const n=t.last_idx,i=r?99:b(e,t);return t.last_idx=i,i<=n?[]:t.breakpoints.slice(n,99==i?100:i).map(function(e){return t.breakpoints.indexOf(e)})}(e,t,r);0!=n.length&&e.emit(y,{position:n})}function b(e,t){return Math.min(Math.floor(e.currentTime/t.segment_duration),99)}function N(){try{const e=window.location!==window.parent.location?document.referrer:document.location.href;return"string"==typeof e&&e.slice(0,200)}catch(e){return!1}}var Q;const x="vod",L="live",I=[k,y,g];function M(e,t,r){switch(null==t?void 0:t.kind){case"live":return function(e,t){const r=Date.now();r-t.last_tracked_ts<6e4||(t.last_tracked_ts=r,++t.ticks,e.emit(y,{position:60*t.ticks}))}(e,t);case"vod":return O(e,t,"boolean"==typeof r&&r)}}function P(e){const t=e.ads;return void 0!==t&&(void 0!==t.schedule&&("function"==typeof t.hasPreroll&&(t.currentRequests?t.currentRequests:!!t.adPlaying||!(!t.hasPreroll()||0!=t.nextIndex))))}const C=((Q=class Analytics{init(e,t,r){if(!h.from_token(e.token||"").is_granted(h.permissions.ANALYTICS))return;if(r.analytics)return;const n=r.analytics={ticker:void 0,last_media_id:"",ended:!1,played:!1},i={locked:void 0,ttl:6e3,task:()=>{r.hasState(R)||M(r,n.ticker)}};const o={session_id:r.deviceId(),autoplay:r.autoplay,muted:r.muted,player_id:e.player_id,customer_user_id:e.customer_user_id,player_version:"3.40.0-rc.2"},a=Tracker.of(r,{verb:Tracker.verb.POST,url:"https://ptm.flowplayer.com/:video_type/:sitegroup_id/:event_type",events:I,required_keys:w,optional_keys:T.concat(E).slice(0),metadata:o});r.on("reap",function(){a&&a.destroy()}),r.on("config",function(t){if(!a)return;const i=m(t,"data.metadata",{});if(!i.media_id&&i.stream_target_id&&(i.media_id=i.stream_target_id),!i.media_id)return n.last_media_id="";if(n.last_media_id===i.media_id)return;n.played=!1,n.last_media_id=i.media_id;const o=m(e,"analytics",{});a.put(i),a.put(o);const s=m(e,"metadata.live_start_time",e.live)?L:x;a.put({video_type:s,source:e.source||N()||""}),n.ticker=e.live?{ticks:0,last_tracked_ts:Date.now(),kind:"live"}:{last_idx:0,segment_duration:0,breakpoints:[],kind:"vod"},n.ended=!1,r.emit(k)});let s=0;r.on("playing",function(){if(!a)return;if(s||n.played||!n.last_media_id)return;a.put({muted:r.muted});const e=P(r);if(e)return s=Promise.resolve(e).then(function(){n.played=!0,r.emit(g),s=0}).catch(function(){s=0});n.played=!0,r.emit(g)}),r.on("timeupdate",function(){var t;a&&(s||P(r)||n.ended||!n.last_media_id||r.hasState(R)||(!e.live&&r.currentTime+.25>=r.duration&&M(r,n.ticker,!0),(t=i).locked||(t.locked=setTimeout(function(){return t.task(),function(e){return e.locked=void 0,e}(t)},t.ttl))))}),r.on("seeked",function(){a&&n.last_media_id&&n.ticker&&"vod"==n.ticker.kind&&function(e,t){S(e,t),t.last_idx=b(e,t)}(r,n.ticker)}),r.on("timeline/gesture/start",function(){M(r,n.ticker)}),r.on("ended",function(){a&&n.last_media_id&&function(e,t){t.ended||(t.ended=!0,M(e,t.ticker))}(r,n)})}}).pluginName="analytics",Q),U=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 r=e.flowplayer;return"function"==typeof r?(r(t),t):(Array.isArray(r.extensions)||(r.extensions=[]),~r.extensions.indexOf(t)||r.extensions.push(t),t)}("undefined"!=typeof window?window:void 0!==v?v:{},C);return U});
|
package/plugins/asel.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.asel=t())}(this,function(){"use strict";const e="click",t="audio:set",n="audio:update",s="audio:tracks";var i=Object.freeze({__proto__:null,SET:t,SWITCH:n,TRACKS:s});function o(e,t,n){const s=function(e){return Array.isArray(e)?e.slice(0):e.split(".")}(t);for(;s.length;){if(null==e)return n;const t=s.shift();if("string"!=typeof t)return n;e=e[t]}return null==e?n:e}const r=navigator.languages||[navigator.language];const a="@flowplayer/audio/track";function l(e,n){e.emit(t,n),n.autoselect&&e._storage.setItem(a,n.lang)}function c(e){return e.toLowerCase()}function u(e,t,n){t=t.slice(0);const s={},i=e.getItem(a);let l=function(){try{return r.reduce((e,t)=>~t.indexOf("-")?e.concat(t,t.split("-")[0]):e.concat(t),[])}catch(e){return[]}}().map(c),u=-1;if("number"==typeof n)return n;for("string"==typeof n&&(n=n.toLowerCase(),~l.indexOf(n)&&l.splice(l.indexOf(n),1),l.unshift(c(n))),Array.isArray(n)&&(l=n.map(c));t.length;){++u;const e=t.shift();if(null==e?void 0:e.autoselect){if(i==e.lang)return console.debug("restoring lang from previous session: ",i),u;if(e.default&&(s.fallback=[u,e]),e.lang&&~l.indexOf(e.lang.toLowerCase())){const t=l.indexOf(e.lang);if(t<o(s,"by_lang.2",1/0)&&(s.by_lang=[u,e,t]),0===t)break}}}return o(s,"by_lang.0",o(s,"fallback.0",void 0))}const d=(e,t)=>new(((e,t)=>{const n=e.get(t);if(!n)throw new Error(`no flowplayer component with the name ${t} exists`);const s=window.customElements.get(t);if(!s)throw new Error(`no default flowplayer component with the name ${t} exists`);const i=window.customElements.get(n);return"function"!=typeof i?s:i})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}const m="has-menu-opened",f="fp-menu-container",h="fp-on",p="fp-invis",y="details[open]."+f;class FlowplayerMenu extends FlowplayerComponent{constructor(t){super(t),this.player=t,this.menuContainer=document.createElement("details"),this.summaryEle=document.createElement("summary"),this.menuHeader=document.createElement("div"),this.menuTitle=document.createElement("h3"),this.olEle=document.createElement("ol"),this.olEle.id=g(),this.menu=document.createElement("div"),this.closeEle=document.createElement("span"),this.menuHeader.classList.add("fp-menu-header"),this.menuHeader.append(this.menuTitle,this.closeEle),this.menu.classList.add("fp-menu"),this.menu.append(this.menuHeader,this.olEle),this.closeEle.classList.add("fp-close"),this.closeEle.textContent="×",this.menuContainer.classList.add(f),this.menuContainer.append(this.summaryEle,this.menu),this.menuContainer.addEventListener(e,e=>{if(e.defaultPrevented)return;e.preventDefault();const n=this.menuContainer.open;n||(v(),document.active_menu=this.menuContainer),this.menuContainer.open=!n,t.root.classList.toggle(m,!n),this.summaryEle.setAttribute("aria-expanded",n?"false":"true")}),this.addEventListener("focusin",e=>{e.target;HTMLLIElement}),this.addEventListener("focusout",e=>{e.target;HTMLLIElement}),this.append(this.menuContainer),this.olEle.setAttribute("aria-labelledby",this.summaryEle.id),this.olEle.setAttribute("role","menu"),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.className=e.class,this.toggle_visibility(!0),this.summaryEle.id||(this.summaryEle.id=e.id||g()),this.summaryEle.setAttribute("aria-label",e.menuTitle||"Menu"),e.summaryTitle&&(this.summaryEle.textContent=e.summaryTitle),e.summaryIcon){const t=d(this.player,e.summaryIcon);t.setAttribute("tabindex",""),this.summaryEle.append(t)}e.menuTitle&&(this.menuTitle.textContent=e.menuTitle),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(t,n){const s=document.createElement("li");s.setAttribute("tabindex","0"),t.icon&&s.append(t.icon);const i=document.createElement("span");i.textContent=t.text,s.append(i),this.olEle.appendChild(s),t.isButton?(s.setAttribute("role","menuitem"),s.addEventListener(e,()=>{"function"==typeof t.onclick&&t.onclick()})):(s.setAttribute("role","menuitemradio"),s.setAttribute("aria-checked","false"),s.addEventListener(e,()=>{this.select_item(n),"function"==typeof t.onclick&&t.onclick()}),t.selected&&this.select_item(n))}select_item(e){var t;if(this.options[e]&&!(null===(t=this.options[e])||void 0===t?void 0:t.hasAttribute("aria-checked")))throw new Error("Cannot select a button-only item");this.options.forEach((t,n)=>{t.hasAttribute("aria-checked")&&(t.classList.toggle(h,n===e),t.setAttribute("aria-checked",n===e?"true":"false"))})}unselect_item(){this.options.forEach(e=>{e.classList.remove(h),e.hasAttribute("aria-checked")&&e.setAttribute("aria-checked","false")})}toggle_visibility(e){this.classList.toggle(p,e),this.menu.style.setProperty("display",e?"none":"flex")}}function v(){Array.from(document.querySelectorAll(".fp-engine")).forEach(e=>{var t;const n=e.root.querySelector(y);n&&(n.open=!1,null===(t=n.querySelector("summary"))||void 0===t||t.removeAttribute("aria-expanded"),e.root.classList.toggle(m,!1))})}function g(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function E(e,t,n){const s=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(s),e}document.addEventListener(e,function(e){this.active_menu&&!e.composedPath().includes(this.active_menu)&&(v(),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){}}();const
|
|
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.asel=t())}(this,function(){"use strict";const e="click",t="audio:set",n="audio:update",s="audio:tracks";var i=Object.freeze({__proto__:null,SET:t,SWITCH:n,TRACKS:s});function o(e,t,n){const s=function(e){return Array.isArray(e)?e.slice(0):e.split(".")}(t);for(;s.length;){if(null==e)return n;const t=s.shift();if("string"!=typeof t)return n;e=e[t]}return null==e?n:e}const r=navigator.languages||[navigator.language];const a="@flowplayer/audio/track";function l(e,n){e.emit(t,n),n.autoselect&&e._storage.setItem(a,n.lang)}function c(e){return e.toLowerCase()}function u(e,t,n){t=t.slice(0);const s={},i=e.getItem(a);let l=function(){try{return r.reduce((e,t)=>~t.indexOf("-")?e.concat(t,t.split("-")[0]):e.concat(t),[])}catch(e){return[]}}().map(c),u=-1;if("number"==typeof n)return n;for("string"==typeof n&&(n=n.toLowerCase(),~l.indexOf(n)&&l.splice(l.indexOf(n),1),l.unshift(c(n))),Array.isArray(n)&&(l=n.map(c));t.length;){++u;const e=t.shift();if(null==e?void 0:e.autoselect){if(i==e.lang)return console.debug("restoring lang from previous session: ",i),u;if(e.default&&(s.fallback=[u,e]),e.lang&&~l.indexOf(e.lang.toLowerCase())){const t=l.indexOf(e.lang);if(t<o(s,"by_lang.2",1/0)&&(s.by_lang=[u,e,t]),0===t)break}}}return o(s,"by_lang.0",o(s,"fallback.0",void 0))}const d=(e,t)=>new(((e,t)=>{const n=e.get(t);if(!n)throw new Error(`no flowplayer component with the name ${t} exists`);const s=window.customElements.get(t);if(!s)throw new Error(`no default flowplayer component with the name ${t} exists`);const i=window.customElements.get(n);return"function"!=typeof i?s:i})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}const m="has-menu-opened",f="fp-menu-container",h="fp-on",p="fp-invis",y="details[open]."+f;class FlowplayerMenu extends FlowplayerComponent{constructor(t){super(t),this.player=t,this.menuContainer=document.createElement("details"),this.summaryEle=document.createElement("summary"),this.menuHeader=document.createElement("div"),this.menuTitle=document.createElement("h3"),this.olEle=document.createElement("ol"),this.olEle.id=g(),this.menu=document.createElement("div"),this.closeEle=document.createElement("span"),this.menuHeader.classList.add("fp-menu-header"),this.menuHeader.append(this.menuTitle,this.closeEle),this.menu.classList.add("fp-menu"),this.menu.append(this.menuHeader,this.olEle),this.closeEle.classList.add("fp-close"),this.closeEle.textContent="×",this.menuContainer.classList.add(f),this.menuContainer.append(this.summaryEle,this.menu),this.menuContainer.addEventListener(e,e=>{if(e.defaultPrevented)return;e.preventDefault();const n=this.menuContainer.open;n||(v(),document.active_menu=this.menuContainer),this.menuContainer.open=!n,t.root.classList.toggle(m,!n),this.summaryEle.setAttribute("aria-expanded",n?"false":"true")}),this.addEventListener("focusin",e=>{e.target;HTMLLIElement}),this.addEventListener("focusout",e=>{e.target;HTMLLIElement}),this.append(this.menuContainer),this.olEle.setAttribute("aria-labelledby",this.summaryEle.id),this.olEle.setAttribute("role","menu"),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.className=e.class,this.toggle_visibility(!0),this.summaryEle.id||(this.summaryEle.id=e.id||g()),this.summaryEle.setAttribute("aria-label",e.menuTitle||"Menu"),e.summaryTitle&&(this.summaryEle.textContent=e.summaryTitle),e.summaryIcon){const t=d(this.player,e.summaryIcon);t.setAttribute("tabindex",""),this.summaryEle.append(t)}e.menuTitle&&(this.menuTitle.textContent=e.menuTitle),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(t,n){const s=document.createElement("li");s.setAttribute("tabindex","0"),t.icon&&s.append(t.icon);const i=document.createElement("span");i.textContent=t.text,s.append(i),this.olEle.appendChild(s),t.isButton?(s.setAttribute("role","menuitem"),s.addEventListener(e,()=>{"function"==typeof t.onclick&&t.onclick()})):(s.setAttribute("role","menuitemradio"),s.setAttribute("aria-checked","false"),s.addEventListener(e,()=>{this.select_item(n),"function"==typeof t.onclick&&t.onclick()}),t.selected&&this.select_item(n))}select_item(e){var t;if(this.options[e]&&!(null===(t=this.options[e])||void 0===t?void 0:t.hasAttribute("aria-checked")))throw new Error("Cannot select a button-only item");this.options.forEach((t,n)=>{t.hasAttribute("aria-checked")&&(t.classList.toggle(h,n===e),t.setAttribute("aria-checked",n===e?"true":"false"))})}unselect_item(){this.options.forEach(e=>{e.classList.remove(h),e.hasAttribute("aria-checked")&&e.setAttribute("aria-checked","false")})}toggle_visibility(e){this.classList.toggle(p,e),this.menu.style.setProperty("display",e?"none":"flex")}}function v(){Array.from(document.querySelectorAll(".fp-engine")).forEach(e=>{var t;const n=e.root.querySelector(y);n&&(n.open=!1,null===(t=n.querySelector("summary"))||void 0===t||t.removeAttribute("aria-expanded"),e.root.classList.toggle(m,!1))})}function g(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function E(e,t,n){const s=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(s),e}function b(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}document.addEventListener(e,function(e){this.active_menu&&!e.composedPath().includes(this.active_menu)&&(v(),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){}}();const w="flowplayer-audio-menu";var _;const k=((_=class Asel{constructor(e){((e,t,n)=>{window.customElements.get(t)||window.customElements.define(t,n),e.customElements.get(t)||e.customElements.set(t,t)})(e,w,class extends FlowplayerMenu{})}init(e,r,a){if(!1===e.asel)return;let c=[];const m=d(a,w);m instanceof FlowplayerMenu&&m.setMenuAttrs({summaryTitle:a.i18n("audio.button_txt"),menuTitle:a.i18n("audio.menu_title"),class:"fp-asel",options_event:_.events.TRACKS,item_selected_event:_.events.SWITCH});const f=function(e){const n={tracks:[],events:i};return Object.assign(n,{set:function(s){if(!("number"!=typeof s||s<0||s>n.tracks.length-1))return e.emit(t,n.tracks[s]),n},get:function(e){if("number"==typeof e)return n.tracks[e]}}),n}(a);a.asel=f,a.on("mount",function(){var e;const t=null!==(e=b(a,a.hasState("is-tv")?"flowplayer-tv-menu":"flowplayer-asel-mount-zone"))&&void 0!==e?e:b(a,"flowplayer-control");null==t||t.append(m)}),a.on("src",()=>{f.tracks=[],f.active_track=void 0,E(m,_.events.TRACKS,[])}),a.on(s,function(t){if(!Array.isArray(t.data)||t.data.length===c.length&&t.data.every((e,t)=>e===c[t]))return;c=t.data,f.tracks=c.slice();const n=o(e,"asel.sort");"function"==typeof n&&f.tracks.sort(n),E(m,_.events.TRACKS,Array.from({length:f.tracks.length}).map((e,t)=>{const n=f.tracks[t];return{text:n.name||n.label||n.lang,onclick:l.bind(0,a,n)}})),f.active_track=f.tracks.find(e=>e.enabled),f.active_track&&E(m,_.events.SWITCH,{selected_index:f.tracks.indexOf(f.active_track)});const s=u(a._storage,f.tracks,o(e,"asel.default_lang",!1));return m instanceof FlowplayerMenu&&m.toggle_visibility(t.data.length<2),void 0!==s?f.set(s):void 0}),a.on(n,function(e){var t;null===(t=a.asel)||void 0===t||t.tracks.find((t,n)=>{var s,i;t!==e.detail&&t.id!==(null!==(i=null===(s=e.detail)||void 0===s?void 0:s.id)&&void 0!==i?i:-1)||(a.asel.active_track=t,E(m,_.events.SWITCH,{selected_index:n}))})}),a.audioTracks&&(a.audioTracks.addEventListener("addtrack",function(){a.hls||a.emit(s,Array.from(a.audioTracks))}),a.on(t,function(e){if(a.hls)return;const t=e.detail;f.active_track=t,t&&Array.from(a.audioTracks).forEach(e=>{e.enabled=t.id===e.id,e.enabled&&E(m,_.events.SWITCH,{selected_index:f.tracks.indexOf(t)})})}))}}).pluginName="asel",_.events=i,_);return 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,k)});
|
package/plugins/qsel.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.qsel=t())}(this,function(){"use strict";function e(e,t,i){const n=function(e){return Array.isArray(e)?e.slice(0):e.split(".")}(t);for(;n.length;){if(null==e)return i;const t=n.shift();if("string"!=typeof t)return i;e=e[t]}return null==e?i:e}const t="click",i="qualities",n=(e,t)=>new(((e,t)=>{const i=e.get(t);if(!i)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 s=window.customElements.get(i);return"function"!=typeof s?n:s})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}const s="has-menu-opened",l="fp-menu-container",o="fp-on",r="fp-invis",a="details[open]."+l;class FlowplayerMenu extends FlowplayerComponent{constructor(e){super(e),this.player=e,this.menuContainer=document.createElement("details"),this.summaryEle=document.createElement("summary"),this.menuHeader=document.createElement("div"),this.menuTitle=document.createElement("h3"),this.olEle=document.createElement("ol"),this.olEle.id=c(),this.menu=document.createElement("div"),this.closeEle=document.createElement("span"),this.menuHeader.classList.add("fp-menu-header"),this.menuHeader.append(this.menuTitle,this.closeEle),this.menu.classList.add("fp-menu"),this.menu.append(this.menuHeader,this.olEle),this.closeEle.classList.add("fp-close"),this.closeEle.textContent="×",this.menuContainer.classList.add(l),this.menuContainer.append(this.summaryEle,this.menu),this.menuContainer.addEventListener(t,t=>{if(t.defaultPrevented)return;t.preventDefault();const i=this.menuContainer.open;i||(u(),document.active_menu=this.menuContainer),this.menuContainer.open=!i,e.root.classList.toggle(s,!i),this.summaryEle.setAttribute("aria-expanded",i?"false":"true")}),this.addEventListener("focusin",e=>{e.target;HTMLLIElement}),this.addEventListener("focusout",e=>{e.target;HTMLLIElement}),this.append(this.menuContainer),this.olEle.setAttribute("aria-labelledby",this.summaryEle.id),this.olEle.setAttribute("role","menu"),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.className=e.class,this.toggle_visibility(!0),this.summaryEle.id||(this.summaryEle.id=e.id||c()),this.summaryEle.setAttribute("aria-label",e.menuTitle||"Menu"),e.summaryTitle&&(this.summaryEle.textContent=e.summaryTitle),e.summaryIcon){const t=n(this.player,e.summaryIcon);t.setAttribute("tabindex",""),this.summaryEle.append(t)}e.menuTitle&&(this.menuTitle.textContent=e.menuTitle),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,i){const n=document.createElement("li");n.setAttribute("tabindex","0"),e.icon&&n.append(e.icon);const s=document.createElement("span");s.textContent=e.text,n.append(s),this.olEle.appendChild(n),e.isButton?(n.setAttribute("role","menuitem"),n.addEventListener(t,()=>{"function"==typeof e.onclick&&e.onclick()})):(n.setAttribute("role","menuitemradio"),n.setAttribute("aria-checked","false"),n.addEventListener(t,()=>{this.select_item(i),"function"==typeof e.onclick&&e.onclick()}),e.selected&&this.select_item(i))}select_item(e){var t;if(this.options[e]&&!(null===(t=this.options[e])||void 0===t?void 0:t.hasAttribute("aria-checked")))throw new Error("Cannot select a button-only item");this.options.forEach((t,i)=>{t.hasAttribute("aria-checked")&&(t.classList.toggle(o,i===e),t.setAttribute("aria-checked",i===e?"true":"false"))})}unselect_item(){this.options.forEach(e=>{e.classList.remove(o),e.hasAttribute("aria-checked")&&e.setAttribute("aria-checked","false")})}toggle_visibility(e){this.classList.toggle(r,e),this.menu.style.setProperty("display",e?"none":"flex")}}function u(){Array.from(document.querySelectorAll(".fp-engine")).forEach(e=>{var t;const i=e.root.querySelector(a);i&&(i.open=!1,null===(t=i.querySelector("summary"))||void 0===t||t.removeAttribute("aria-expanded"),e.root.classList.toggle(s,!1))})}function c(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function d(e,t,i){const n=function(e,t){const i=new CustomEvent(e,{detail:t,cancelable:!0});return t&&Object.defineProperty(i,"data",{get:()=>t}),i}(t,i);return e.dispatchEvent(n),e}document.addEventListener(t,function(e){this.active_menu&&!e.composedPath().includes(this.active_menu)&&(u(),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){}}();const
|
|
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.qsel=t())}(this,function(){"use strict";function e(e,t,i){const n=function(e){return Array.isArray(e)?e.slice(0):e.split(".")}(t);for(;n.length;){if(null==e)return i;const t=n.shift();if("string"!=typeof t)return i;e=e[t]}return null==e?i:e}const t="click",i="qualities",n=(e,t)=>new(((e,t)=>{const i=e.get(t);if(!i)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 s=window.customElements.get(i);return"function"!=typeof s?n:s})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}const s="has-menu-opened",l="fp-menu-container",o="fp-on",r="fp-invis",a="details[open]."+l;class FlowplayerMenu extends FlowplayerComponent{constructor(e){super(e),this.player=e,this.menuContainer=document.createElement("details"),this.summaryEle=document.createElement("summary"),this.menuHeader=document.createElement("div"),this.menuTitle=document.createElement("h3"),this.olEle=document.createElement("ol"),this.olEle.id=c(),this.menu=document.createElement("div"),this.closeEle=document.createElement("span"),this.menuHeader.classList.add("fp-menu-header"),this.menuHeader.append(this.menuTitle,this.closeEle),this.menu.classList.add("fp-menu"),this.menu.append(this.menuHeader,this.olEle),this.closeEle.classList.add("fp-close"),this.closeEle.textContent="×",this.menuContainer.classList.add(l),this.menuContainer.append(this.summaryEle,this.menu),this.menuContainer.addEventListener(t,t=>{if(t.defaultPrevented)return;t.preventDefault();const i=this.menuContainer.open;i||(u(),document.active_menu=this.menuContainer),this.menuContainer.open=!i,e.root.classList.toggle(s,!i),this.summaryEle.setAttribute("aria-expanded",i?"false":"true")}),this.addEventListener("focusin",e=>{e.target;HTMLLIElement}),this.addEventListener("focusout",e=>{e.target;HTMLLIElement}),this.append(this.menuContainer),this.olEle.setAttribute("aria-labelledby",this.summaryEle.id),this.olEle.setAttribute("role","menu"),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.className=e.class,this.toggle_visibility(!0),this.summaryEle.id||(this.summaryEle.id=e.id||c()),this.summaryEle.setAttribute("aria-label",e.menuTitle||"Menu"),e.summaryTitle&&(this.summaryEle.textContent=e.summaryTitle),e.summaryIcon){const t=n(this.player,e.summaryIcon);t.setAttribute("tabindex",""),this.summaryEle.append(t)}e.menuTitle&&(this.menuTitle.textContent=e.menuTitle),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,i){const n=document.createElement("li");n.setAttribute("tabindex","0"),e.icon&&n.append(e.icon);const s=document.createElement("span");s.textContent=e.text,n.append(s),this.olEle.appendChild(n),e.isButton?(n.setAttribute("role","menuitem"),n.addEventListener(t,()=>{"function"==typeof e.onclick&&e.onclick()})):(n.setAttribute("role","menuitemradio"),n.setAttribute("aria-checked","false"),n.addEventListener(t,()=>{this.select_item(i),"function"==typeof e.onclick&&e.onclick()}),e.selected&&this.select_item(i))}select_item(e){var t;if(this.options[e]&&!(null===(t=this.options[e])||void 0===t?void 0:t.hasAttribute("aria-checked")))throw new Error("Cannot select a button-only item");this.options.forEach((t,i)=>{t.hasAttribute("aria-checked")&&(t.classList.toggle(o,i===e),t.setAttribute("aria-checked",i===e?"true":"false"))})}unselect_item(){this.options.forEach(e=>{e.classList.remove(o),e.hasAttribute("aria-checked")&&e.setAttribute("aria-checked","false")})}toggle_visibility(e){this.classList.toggle(r,e),this.menu.style.setProperty("display",e?"none":"flex")}}function u(){Array.from(document.querySelectorAll(".fp-engine")).forEach(e=>{var t;const i=e.root.querySelector(a);i&&(i.open=!1,null===(t=i.querySelector("summary"))||void 0===t||t.removeAttribute("aria-expanded"),e.root.classList.toggle(s,!1))})}function c(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function d(e,t,i){const n=function(e,t){const i=new CustomEvent(e,{detail:t,cancelable:!0});return t&&Object.defineProperty(i,"data",{get:()=>t}),i}(t,i);return e.dispatchEvent(n),e}function h(e,t){const i=e._customElements.get(t);return i&&e.root.querySelector(i)||void 0}document.addEventListener(t,function(e){this.active_menu&&!e.composedPath().includes(this.active_menu)&&(u(),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){}}();const m="flowplayer-quality-menu",p="quality:set";var f,y=Object.freeze({__proto__:null,SET_QUALITY:p,TRACKS:"quality:tracks",SWITCH:"quality:update",QUALITIES:i});function E(e){return e instanceof FlowplayerMenu}function v(e){return e.find(e=>"level"in e&&-1===e.level||"index"in e&&-1===e.index)}function g(e,t){return t||(e.height&&e.width&&e.height>e.width?`${e.width}p${e.height>1279?" HD":""}`:e.height?`${e.height}p${e.height>719?" HD":""}`:e.width?`${e.width}p${e.width>1279?" HD":""}`:"name"in e&&e.name?e.name:"0p")}function b(e,t,i,n){const s=v(t),l=e.querySelector("li:last-child span");l&&s&&(l.textContent=n?`${g(s)} - ${g(i)}`:g(s)+"")}function w(t,i,n,s){if(E(n)&&!e(i.opts,"qsel.labels")){const e=s===v(t.qualities);e&&-1===t.current.index||b(n,t.qualities,e?t.qualities[t.current.index]:s,e)}i.emit(p,s)}const x=((f=class Qsel{constructor(e){this.qualities=[],this.current={automatic:!0,index:-1},((e,t,i)=>{window.customElements.get(t)||window.customElements.define(t,i),e.customElements.get(t)||e.customElements.set(t,t)})(e,m,class extends FlowplayerMenu{})}init(t,s,l){const o=n(l,m);E(o)&&o.setMenuAttrs({summaryTitle:"HD",menuTitle:l.i18n("qsel.menu_title"),class:"fp-qsel",options_event:f.events.TRACKS,item_selected_event:f.events.SWITCH}),l.on("src",()=>{this.qualities=[],this.current={automatic:!0,index:-1},d(o,f.events.TRACKS,[])}),l.on("mount",function(){var e;const t=null!==(e=h(l,l.hasState("is-tv")?"flowplayer-tv-menu":"flowplayer-qsel-mount-zone"))&&void 0!==e?e:h(l,"flowplayer-control");null==t||t.append(o)}),l.on("qualitychange",i=>{const n=i.detail;var s,l;this.current.automatic=n.automatic,this.current.index=(s=this.qualities,l=n.after,s.findIndex(e=>"level"in e&&"level"in l?e.level===l.level:"id"in e?e.id===l.id:void 0)),!E(o)||e(t,"qsel.labels")||this.qualities.length<2||(d(o,f.events.SWITCH,{selected_index:this.current.automatic&&v(this.qualities)?this.qualities.length-1:this.current.index}),b(o,this.qualities,this.qualities[this.current.index],this.current.automatic))}),l.on(i,i=>{if(!Array.isArray(i.detail))return;this.qualities=i.detail;const n=e(t,"qsel.labels",[]);if(d(o,f.events.TRACKS,this.qualities.flatMap((e,t)=>"boolean"!=typeof n[t]||n[t]?{text:g(e,n[t]),onclick:w.bind(this,this,l,o,e)}:[])),E(o)&&o.toggle_visibility(this.qualities.length<2),this.qualities.length<2)return d(o,f.events.SWITCH,{selected_index:0});if(!e(t,"qsel.labels")){if(-1===this.current.index)return v(this.qualities)&&d(o,f.events.SWITCH,{selected_index:this.qualities.length-1});d(o,f.events.SWITCH,{selected_index:this.current.automatic&&v(this.qualities)?this.qualities.length-1:this.current.index}),E(o)&&this.current.automatic&&b(o,this.qualities,this.qualities[this.current.index],this.current.automatic)}})}}).pluginName="qsel",f.events=y,f);return 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 i=e.flowplayer;return"function"==typeof i?(i(t),t):(Array.isArray(i.extensions)||(i.extensions=[]),~i.extensions.indexOf(t)||i.extensions.push(t),t)}(window,x)});
|