@flowplayer/player 3.29.0 → 3.30.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/index.d.ts +4 -4
- package/package.json +2 -2
- package/plugins/ads.d.ts +4 -4
- package/plugins/ads.js +2 -2
- package/plugins/airplay.d.ts +4 -4
- package/plugins/airplay.js +1 -1
- package/plugins/analytics.d.ts +4 -4
- package/plugins/analytics.js +1 -1
- package/plugins/asel.d.ts +4 -4
- package/plugins/asel.js +1 -1
- package/plugins/audio.d.ts +4 -4
- package/plugins/audio.js +1 -1
- package/plugins/chapters.d.ts +4 -4
- package/plugins/chapters.js +1 -1
- package/plugins/chromecast.d.ts +4 -4
- package/plugins/chromecast.js +1 -1
- package/plugins/comscore.d.ts +4 -4
- package/plugins/comscore.js +1 -1
- package/plugins/consent.d.ts +4 -4
- package/plugins/consent.js +1 -1
- package/plugins/context-menu.d.ts +4 -4
- package/plugins/context-menu.js +1 -1
- package/plugins/cuepoints.d.ts +4 -4
- package/plugins/cuepoints.js +1 -1
- package/plugins/dash.d.ts +4 -4
- package/plugins/dash.js +2 -5
- package/plugins/drm.d.ts +4 -4
- package/plugins/drm.js +1 -1
- package/plugins/endscreen.d.ts +4 -4
- package/plugins/endscreen.js +1 -1
- package/plugins/fas.d.ts +4 -4
- package/plugins/fas.js +1 -1
- package/plugins/float-on-scroll.d.ts +4 -4
- package/plugins/float-on-scroll.js +1 -1
- package/plugins/ga4.d.ts +4 -4
- package/plugins/ga4.js +1 -1
- package/plugins/gemius.d.ts +4 -4
- package/plugins/gemius.js +1 -1
- package/plugins/google-analytics.d.ts +4 -4
- package/plugins/google-analytics.js +1 -1
- package/plugins/hls.d.ts +4 -4
- package/plugins/hls.js +1 -1
- package/plugins/id3.d.ts +4 -4
- package/plugins/id3.js +1 -1
- package/plugins/iframe.d.ts +4 -4
- package/plugins/iframe.js +1 -1
- package/plugins/keyboard.d.ts +4 -4
- package/plugins/keyboard.js +1 -1
- package/plugins/media-session.d.ts +4 -4
- package/plugins/media-session.js +1 -1
- package/plugins/message.d.ts +4 -4
- package/plugins/message.js +1 -1
- package/plugins/ovp.d.ts +10 -4
- package/plugins/ovp.js +1 -1
- package/plugins/playlist.d.ts +4 -4
- package/plugins/playlist.js +1 -1
- package/plugins/preview.d.ts +4 -4
- package/plugins/preview.js +1 -1
- package/plugins/qsel.d.ts +4 -4
- package/plugins/qsel.js +1 -1
- package/plugins/qul.d.ts +4 -4
- package/plugins/qul.js +1 -1
- package/plugins/rts.d.ts +4 -4
- package/plugins/rts.js +7 -7
- package/plugins/share.d.ts +4 -4
- package/plugins/share.js +1 -1
- package/plugins/speed.d.ts +4 -4
- package/plugins/speed.js +1 -1
- package/plugins/ssai.d.ts +4 -4
- package/plugins/ssai.js +2 -2
- package/plugins/subtitles.d.ts +4 -4
- package/plugins/subtitles.js +1 -1
- package/plugins/thumbnails.d.ts +4 -4
- package/plugins/thumbnails.js +1 -1
- package/plugins/tizen.d.ts +4 -4
- package/plugins/tizen.js +1 -1
- package/plugins/vtsel.d.ts +4 -4
- package/plugins/vtsel.js +1 -1
- package/plugins/webos.d.ts +4 -4
- package/plugins/webos.js +1 -1
- package/util/loader.d.ts +4 -4
package/plugins/airplay.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { BitrateInfo } from 'dashjs';
|
|
2
1
|
import type { Get } from 'type-fest';
|
|
3
2
|
import type { HlsConfig } from 'hls.js';
|
|
4
3
|
import type { Level } from 'hls.js';
|
|
4
|
+
import type { Representation } from 'dashjs';
|
|
5
5
|
import type { TupleToUnion } from 'type-fest';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -1478,7 +1478,7 @@ PROGRESS = "progress";
|
|
|
1478
1478
|
*/
|
|
1479
1479
|
declare type QselOption = (Level & {
|
|
1480
1480
|
level: number;
|
|
1481
|
-
}) |
|
|
1481
|
+
}) | Representation | {
|
|
1482
1482
|
name: string | number;
|
|
1483
1483
|
encodingId: string;
|
|
1484
1484
|
spatialLayerId: number;
|
|
@@ -1526,8 +1526,8 @@ QUALITY_CHANGE = "qualitychange";
|
|
|
1526
1526
|
* @public
|
|
1527
1527
|
*/
|
|
1528
1528
|
declare type QualityChangeEventDetail = {
|
|
1529
|
-
before?: Level |
|
|
1530
|
-
after?: Level |
|
|
1529
|
+
before?: Level | Representation;
|
|
1530
|
+
after?: Level | Representation;
|
|
1531
1531
|
plugin: string;
|
|
1532
1532
|
automatic: boolean;
|
|
1533
1533
|
/* Excluded from this release type: downscale */
|
package/plugins/airplay.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.airplay=t())}(this,
|
|
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.airplay=t())}(this,function(){"use strict";const e=(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 r=window.customElements.get(n);return"function"!=typeof r?i:r})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}class FlowplayerIcon extends FlowplayerComponent{constructor(e,t){super(e),this.classList.add("fp-icon",t.name),t.title&&this.setAttribute("title",t.title),t.title&&this.setAttribute("aria-label",t.title),t.translation_key&&this.setAttribute("aria-label",e.i18n(t.translation_key)),this.setAttribute("tabindex","0"),this.setAttribute("focusable","true")}}const t="flowplayer-airplay-icon";var n=Object.freeze({__proto__:null,START:"airplay:start",STOP:"airplay:stop"});const i={name:"fp-airplay"};var r;const s=((r=class Airplay{static unsupported(){return!("WebKitPlaybackTargetAvailabilityEvent"in window)}static update(e,t){const n=t.availability===r.AVAILABLE&&!!e.currentSrc&&0!==e.currentSrc.indexOf("blob");e.setState(r.AVAILABLE_CLASS,n)}static render(n){var i;const r=e(n,t);null===(i=function(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}(n,"flowplayer-header-right-zone"))||void 0===i||i.prepend(r)}constructor(e){((e,t,n)=>{window.customElements.get(t)||window.customElements.define(t,n),e.customElements.get(t)||e.customElements.set(t,t)})(e,t,class extends FlowplayerIcon{constructor(e){super(e,i),this.addEventListener("click",function(){e.webkitShowPlaybackTargetPicker()})}})}init({airplay:e,hls:t},n,i){r.unsupported()||!1===e||(i.setOpts({hls:Object.assign({},{native:!0},t)}),r.render(i),i.setAttribute("x-webkit-airplay","allow"),i.on(r.AVAILABILITY_CHANGE,function(e){r.update(i,e)}),i.on(r.WIRELESS_CHANGE,function(){return i.emit(i.webkitCurrentPlaybackTargetIsWireless?r.events.START:r.events.STOP),i.setState(r.ACTIVE_CLASS,i.webkitCurrentPlaybackTargetIsWireless)}))}}).pluginName="airplay",r.ACTIVE_CLASS="is-airplay",r.AVAILABLE_CLASS="is-airplay-available",r.AVAILABILITY_CHANGE="webkitplaybacktargetavailabilitychanged",r.WIRELESS_CHANGE="webkitcurrentplaybacktargetiswirelesschanged",r.AVAILABLE="available",r.events=n,r);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,s)});
|
package/plugins/analytics.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { BitrateInfo } from 'dashjs';
|
|
2
1
|
import type { Get } from 'type-fest';
|
|
3
2
|
import type { Level } from 'hls.js';
|
|
3
|
+
import type { Representation } from 'dashjs';
|
|
4
4
|
import type { TupleToUnion } from 'type-fest';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -1472,7 +1472,7 @@ PROGRESS = "progress";
|
|
|
1472
1472
|
*/
|
|
1473
1473
|
declare type QselOption = (Level & {
|
|
1474
1474
|
level: number;
|
|
1475
|
-
}) |
|
|
1475
|
+
}) | Representation | {
|
|
1476
1476
|
name: string | number;
|
|
1477
1477
|
encodingId: string;
|
|
1478
1478
|
spatialLayerId: number;
|
|
@@ -1520,8 +1520,8 @@ QUALITY_CHANGE = "qualitychange";
|
|
|
1520
1520
|
* @public
|
|
1521
1521
|
*/
|
|
1522
1522
|
declare type QualityChangeEventDetail = {
|
|
1523
|
-
before?: Level |
|
|
1524
|
-
after?: Level |
|
|
1523
|
+
before?: Level | Representation;
|
|
1524
|
+
after?: Level | Representation;
|
|
1525
1525
|
plugin: string;
|
|
1526
1526
|
automatic: boolean;
|
|
1527
1527
|
/* Excluded from this release type: downscale */
|
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,o;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={})=>{const i=e(o.metadata,{event_type:t},r.data||r),a=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,i),s=Tracker.pluck_valid_keys(o,i),u=Tracker.ensure_required_keys(o,s);if(u.length)return o.log.error(`Tracker.validate_metadata() failed for\n Event[${t}]\n missing keys: ${u}\n payload:\n ${JSON.stringify(s,null,2)}`);this.rq&&RequestQueue.rpush(this.rq,[a,this.verb,s])})})}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}}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"];function R(e,t){return e.duration/1===e.duration&&Object.assign(t,function(e){const t=e/100;return{segment_duration:t,breakpoints:Array(...Array(100)).map((function(e,r){return Math.floor(r*t*1e3)/1e3}))}}(e.duration))}function q(e,t,r){if(!t.segment_duration&&!R(e,t))return;const n=function(e,t,r){const n=t.last_idx,i=r?99:A(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 A(e,t){return Math.min(Math.floor(e.currentTime/t.segment_duration),99)}function S(){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 O;const b="vod",N="live",Q=[k,y,g];function x(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 q(e,t,"boolean"==typeof r&&r)}}function L(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 I=((O=class Analytics{init(e,t,r){if(!h.from_token(e.token||"").is_granted(h.permissions.ANALYTICS))return;if(r.hasState("consent-no-tracking"))return;if(r.analytics)return;const n=r.analytics={ticker:void 0,last_media_id:"",ended:!1},i={locked:void 0,ttl:6e3,task:()=>{x(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.29.0"},a=Tracker.of(r,{verb:Tracker.verb.POST,url:"https://ptm.flowplayer.com/:video_type/:sitegroup_id/:event_type",events:Q,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;const o=m(a,"metadata.media_id");if(o&&i.media_id==o)return;const s=m(e,"analytics",{});a.put(i),a.put(s);const u=m(e,"metadata.live_start_time",e.live)?N:b;a.put({video_type:u,source:e.source||S()||""}),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||function(e,t){return e.metadata.media_id&&e.metadata.media_id==t.last_media_id}(a,n))return;a.put({muted:r.muted});const e=L(r);if(e)return s=Promise.resolve(e).then((function(){n.last_media_id=a.metadata.media_id,r.emit(g),s=0})).catch((function(){s=0}));n.last_media_id=a.metadata.media_id,r.emit(g)})),r.on("timeupdate",(function(){var t;a&&(s||L(r)||n.ended||(!e.live&&r.currentTime+.25>=r.duration&&x(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.ticker&&"vod"==n.ticker.kind&&function(e,t){R(e,t),t.last_idx=A(e,t)}(r,n.ticker)})),r.on("ended",(function(){a&&function(e,t){t.ended||(t.ended=!0,x(e,t.ticker))}(r,n)}))}}).pluginName="analytics",O);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 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:{},I)}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.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,o;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={})=>{const i=e(o.metadata,{event_type:t},r.data||r),a=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,i),s=Tracker.pluck_valid_keys(o,i),u=Tracker.ensure_required_keys(o,s);if(u.length)return o.log.error(`Tracker.validate_metadata() failed for\n Event[${t}]\n missing keys: ${u}\n payload:\n ${JSON.stringify(s,null,2)}`);this.rq&&RequestQueue.rpush(this.rq,[a,this.verb,s])})})}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}}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=100,q=1e3;function A(e,t){return e.duration/1===e.duration&&Object.assign(t,function(e){const t=e/R;return{segment_duration:t,breakpoints:Array(...Array(R)).map(function(e,r){return Math.floor(r*t*q)/q})}}(e.duration))}function S(e,t,r){if(!t.segment_duration&&!A(e,t))return;const n=function(e,t,r){const n=t.last_idx,i=r?99:O(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 O(e,t){return Math.min(Math.floor(e.currentTime/t.segment_duration),99)}function b(){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 N;const Q="vod",x="live",L=[k,y,g];function I(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 S(e,t,"boolean"==typeof r&&r)}}function M(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 P=((N=class Analytics{init(e,t,r){if(!h.from_token(e.token||"").is_granted(h.permissions.ANALYTICS))return;if(r.hasState("consent-no-tracking"))return;if(r.analytics)return;const n=r.analytics={ticker:void 0,last_media_id:"",ended:!1},i={locked:void 0,ttl:6e3,task:()=>{I(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.30.0"},a=Tracker.of(r,{verb:Tracker.verb.POST,url:"https://ptm.flowplayer.com/:video_type/:sitegroup_id/:event_type",events:L,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;const o=m(a,"metadata.media_id");if(o&&i.media_id==o)return;const s=m(e,"analytics",{});a.put(i),a.put(s);const u=m(e,"metadata.live_start_time",e.live)?x:Q;a.put({video_type:u,source:e.source||b()||""}),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||function(e,t){return e.metadata.media_id&&e.metadata.media_id==t.last_media_id}(a,n))return;a.put({muted:r.muted});const e=M(r);if(e)return s=Promise.resolve(e).then(function(){n.last_media_id=a.metadata.media_id,r.emit(g),s=0}).catch(function(){s=0});n.last_media_id=a.metadata.media_id,r.emit(g)}),r.on("timeupdate",function(){var t;a&&(s||M(r)||n.ended||(!e.live&&r.currentTime+.25>=r.duration&&I(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.ticker&&"vod"==n.ticker.kind&&function(e,t){A(e,t),t.last_idx=O(e,t)}(r,n.ticker)}),r.on("ended",function(){a&&function(e,t){t.ended||(t.ended=!0,I(e,t.ticker))}(r,n)})}}).pluginName="analytics",N),C=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:{},P);return C});
|
package/plugins/asel.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { BitrateInfo } from 'dashjs';
|
|
2
1
|
import type { Get } from 'type-fest';
|
|
3
2
|
import type Hls from 'hls.js';
|
|
4
3
|
import type { Level } from 'hls.js';
|
|
5
4
|
import type { LevelAttributes } from 'hls.js';
|
|
5
|
+
import type { Representation } from 'dashjs';
|
|
6
6
|
import type { TupleToUnion } from 'type-fest';
|
|
7
7
|
|
|
8
8
|
/* Excluded from this release type: AnyLoader */
|
|
@@ -1589,7 +1589,7 @@ PROGRESS = "progress";
|
|
|
1589
1589
|
*/
|
|
1590
1590
|
declare type QselOption = (Level & {
|
|
1591
1591
|
level: number;
|
|
1592
|
-
}) |
|
|
1592
|
+
}) | Representation | {
|
|
1593
1593
|
name: string | number;
|
|
1594
1594
|
encodingId: string;
|
|
1595
1595
|
spatialLayerId: number;
|
|
@@ -1637,8 +1637,8 @@ QUALITY_CHANGE = "qualitychange";
|
|
|
1637
1637
|
* @public
|
|
1638
1638
|
*/
|
|
1639
1639
|
declare type QualityChangeEventDetail = {
|
|
1640
|
-
before?: Level |
|
|
1641
|
-
after?: Level |
|
|
1640
|
+
before?: Level | Representation;
|
|
1641
|
+
after?: Level | Representation;
|
|
1642
1642
|
plugin: string;
|
|
1643
1643
|
automatic: boolean;
|
|
1644
1644
|
/* Excluded from this release type: downscale */
|
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,
|
|
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 a=navigator.languages||[navigator.language];const r="@flowplayer/audio/track";function l(e,n){e.emit(t,n),n.autoselect&&e._storage.setItem(r,n.lang)}function c(e){return e.toLowerCase()}function u(e,t,n){t=t.slice(0);const s={},i=e.getItem(r);let l=function(){try{return a.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",p="fp-on",h="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=>{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.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("role","menuitem"),s.setAttribute("aria-selected","false"),s.setAttribute("tabindex","0"),t.icon&&s.append(t.icon);const i=document.createElement("span");i.textContent=t.text,s.append(i),s.addEventListener(e,()=>{this.select_item(n),"function"==typeof t.onclick&&t.onclick()}),this.olEle.appendChild(s),t.selected&&this.select_item(n)}select_item(e){this.options.forEach((t,n)=>{t.classList.toggle(p,n===e)})}unselect_item(){this.options.forEach(e=>{e.classList.remove(p)})}toggle_visibility(e){this.classList.toggle(h,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 b="flowplayer-audio-menu";var _;const w=((_=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,b,class extends FlowplayerMenu{})}init(e,a,r){if(!1===e.asel)return;let c=[];const m=d(r,b);m instanceof FlowplayerMenu&&m.setMenuAttrs({summaryTitle:r.i18n("audio.button_txt"),menuTitle:r.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}(r);r.asel=f,r.on("mount",function(){var e;null===(e=function(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}(r,r.hasState("is-tv")?"flowplayer-tv-menu":"flowplayer-control"))||void 0===e||e.append(m)}),r.on("src",()=>{f.tracks=[],f.active_track=void 0,E(m,_.events.TRACKS,[])}),r.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,r,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(r._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}),r.on(n,function(e){var t;null===(t=r.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)||(r.asel.active_track=t,E(m,_.events.SWITCH,{selected_index:n}))})}),r.audioTracks&&(r.audioTracks.addEventListener("addtrack",function(){r.hls||r.emit(s,Array.from(r.audioTracks))}),r.on(t,function(e){if(r.hls)return;const t=e.detail;f.active_track=t,t&&Array.from(r.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,w)});
|
package/plugins/audio.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { BitrateInfo } from 'dashjs';
|
|
2
1
|
import type { Get } from 'type-fest';
|
|
3
2
|
import type { Level } from 'hls.js';
|
|
3
|
+
import type { Representation } from 'dashjs';
|
|
4
4
|
import type { TupleToUnion } from 'type-fest';
|
|
5
5
|
|
|
6
6
|
/* Excluded from this release type: AnyLoader */
|
|
@@ -1472,7 +1472,7 @@ PROGRESS = "progress";
|
|
|
1472
1472
|
*/
|
|
1473
1473
|
declare type QselOption = (Level & {
|
|
1474
1474
|
level: number;
|
|
1475
|
-
}) |
|
|
1475
|
+
}) | Representation | {
|
|
1476
1476
|
name: string | number;
|
|
1477
1477
|
encodingId: string;
|
|
1478
1478
|
spatialLayerId: number;
|
|
@@ -1520,8 +1520,8 @@ QUALITY_CHANGE = "qualitychange";
|
|
|
1520
1520
|
* @public
|
|
1521
1521
|
*/
|
|
1522
1522
|
declare type QualityChangeEventDetail = {
|
|
1523
|
-
before?: Level |
|
|
1524
|
-
after?: Level |
|
|
1523
|
+
before?: Level | Representation;
|
|
1524
|
+
after?: Level | Representation;
|
|
1525
1525
|
plugin: string;
|
|
1526
1526
|
automatic: boolean;
|
|
1527
1527
|
/* Excluded from this release type: downscale */
|
package/plugins/audio.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((n="undefined"!=typeof globalThis?globalThis:n||self).flowplayer=n.flowplayer||{},n.flowplayer.audio=e())}(this,
|
|
1
|
+
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((n="undefined"!=typeof globalThis?globalThis:n||self).flowplayer=n.flowplayer||{},n.flowplayer.audio=e())}(this,function(){"use strict";function n(n,e,o){const t=function(n){return Array.isArray(n)?n.slice(0):n.split(".")}(e);for(;t.length;){if(null==n)return o;const e=t.shift();if("string"!=typeof e)return o;n=n[e]}return null==n?o:n}class Audio{constructor(n){this.umd=n}init(e,o,t){var i,r;let u=e.poster,s=!1,d=!1;function l(){t.setState("is-audio-player",s),t.setState("show-controls-only",!u)}function a(){var o,i;!1!==n(e,"audio")&&e.is_native&&!d&&(s=0===(null===(o=t.videoTracks)||void 0===o?void 0:o.length)&&(null===(i=t.audioTracks)||void 0===i?void 0:i.length)>0,l())}t.on("config",function(e){u=n(e,"data.poster",u);const o=n(e,"data.ui",{});d=!!(8192&o)}),t.on("audioonlysource",function(){!1!==n(e,"audio")&&(t.setOpts({muted:!1}),s=!0,l())}),t.on("src",function(){!1!==n(e,"audio")&&(s=d,l())}),null===(i=t.videoTracks)||void 0===i||i.addEventListener("addtrack",a),null===(r=t.audioTracks)||void 0===r||r.addEventListener("addtrack",a)}}Audio.pluginName="audio";return function(n,e){if("object"==typeof exports&&"undefined"!=typeof module)return e;if(null===document.currentScript)return e;"flowplayer"in n||(n.flowplayer={extensions:[]});const o=n.flowplayer;return"function"==typeof o?(o(e),e):(Array.isArray(o.extensions)||(o.extensions=[]),~o.extensions.indexOf(e)||o.extensions.push(e),e)}(window,Audio)});
|
package/plugins/chapters.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { BitrateInfo } from 'dashjs';
|
|
2
1
|
import type { Get } from 'type-fest';
|
|
3
2
|
import type { Level } from 'hls.js';
|
|
3
|
+
import type { Representation } from 'dashjs';
|
|
4
4
|
import type { TupleToUnion } from 'type-fest';
|
|
5
5
|
|
|
6
6
|
/* Excluded from this release type: AnyLoader */
|
|
@@ -1474,7 +1474,7 @@ PROGRESS = "progress";
|
|
|
1474
1474
|
*/
|
|
1475
1475
|
declare type QselOption = (Level & {
|
|
1476
1476
|
level: number;
|
|
1477
|
-
}) |
|
|
1477
|
+
}) | Representation | {
|
|
1478
1478
|
name: string | number;
|
|
1479
1479
|
encodingId: string;
|
|
1480
1480
|
spatialLayerId: number;
|
|
@@ -1522,8 +1522,8 @@ QUALITY_CHANGE = "qualitychange";
|
|
|
1522
1522
|
* @public
|
|
1523
1523
|
*/
|
|
1524
1524
|
declare type QualityChangeEventDetail = {
|
|
1525
|
-
before?: Level |
|
|
1526
|
-
after?: Level |
|
|
1525
|
+
before?: Level | Representation;
|
|
1526
|
+
after?: Level | Representation;
|
|
1527
1527
|
plugin: string;
|
|
1528
1528
|
automatic: boolean;
|
|
1529
1529
|
/* Excluded from this release type: downscale */
|
package/plugins/chapters.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.chapters=t())}(this,(function(){"use strict";function e(){}var t;function n(e,n){if(function(e){return Object.values(t).includes(e)}(n=n||t.Anonymous))return e instanceof HTMLVideoElement&&(e.poster="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="),"crossOrigin"in e?e.crossOrigin=n:e.setAttribute("crossorigin",n),e}function r(e){const t=document.createElement("a");return t.href=e,t.origin}function i(t,i){const s=document.createElement("track");s.className="fp-track renderable",s.kind=i.kind||"captions",s.label=i.label||i.lang||"",s.lang=i.lang||"",s.id=["fp",i.lang].join("-");const o=s.track;return o.removeCue=e,"string"!=typeof i.crossorigin&&function(e,t){try{return e.src.startsWith("blob:"),r(e.src)!==r(t)}catch(e){return console.error(e),!0}}(t,i.src)&&(n(t),i.crossorigin=t.getAttribute("crossorigin")),"crossorigin"in i&&n(t,i.crossorigin),Object.keys(i).forEach(e=>{"default"!==e&&(s[e]=i[e])}),o.mode=i.default?"hidden":"disabled",t.appendChild(s),s}!function(e){e.Anonymous="anonymous",e.UseCredentials="use-credentials",e.Empty=""}(t||(t={}));var s=Object.freeze({__proto__:null,CHAPTER_CHANGED:"chapter:changed",CHAPTERS_NEW:"chapters:new"});function o(e,t,n){const r=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(r),e}function a(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}function c(...e){const t=document.createElement("div");return 0==e.length||t.classList.add(...e),t}!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 l="flowplayer-timeline-bar",u="is-source-processing";class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}document.addEventListener("click",(function(e){this.active_menu&&!e.composedPath().includes(this.active_menu)&&(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))}),this.active_menu=void 0)}));const d={passive:!0};var h;function p(t,n){let r=0,i=-1,s=-1;const o=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5),a=t.classList;t.id=o,a.remove(h.GRABBING),a.remove(h.TOUCHING);const c=n.onseek||e,l=n.onstart||e,u=n.onend||e,p=n.onmouse||e,_=n.ontouch||e,v=n.ontouchend||e;function g(e){!function(){const e=t.getBoundingClientRect();r=e.left,i=e.width}();let n=(function(e){return"function"==typeof window.TouchEvent&&e instanceof TouchEvent}(e)?e.changedTouches[0].pageX:e.pageX)-r;return n>i&&(n=i),n<0&&(n=0),n/i*100}function y(e){const n=g(e);n!=s&&(c(t,n),s=n)}return t.addEventListener("touchstart",(function(e){f(t,e)&&(a.add(h.TOUCHING),m(t.parentElement)&&(a.add(h.GRABBING),_(t,g(e)),l(t,g(e)),y(e)))}),d),t.addEventListener("touchmove",(function(e){y(e),p(t,g(e))}),d),t.addEventListener("touchend",(function(e){setTimeout((function(){a.remove(h.TOUCHING)}),500),f(t,e)&&(a.remove(h.GRABBING),v(t,g(e)),u(t,g(e)),i=0)}),d),t.addEventListener("touchcancel",(function(){a.remove(h.GRABBING,h.TOUCHING),i=0}),d),t.addEventListener("mousedown",(function(e){a.contains(h.TOUCHING)||(document.addEventListener("mousemove",y),a.add(h.GRABBING),l(t,g(e)),e.preventDefault(),y(e))})),t.addEventListener("mousemove",(function(e){a.contains(h.TOUCHING)||p(t,g(e))})),document.addEventListener("mouseup",(function(e){a.contains(h.TOUCHING)||(document.removeEventListener("mousemove",y),a.contains(h.GRABBING)&&(a.remove(h.GRABBING),u(t,g(e)),i=0))})),t}function f(e,t){const n=t.target;return!!n&&(n&&!n.closest(e.id)||!m(e.parentElement)||!e.classList.contains(h.TOUCHING))}function m(e){if(!e)return!1;const t=window.getComputedStyle(e);return"0"!==t.width&&"0"!==t.height&&"0"!==t.opacity&&"none"!==t.display&&"hidden"!==t.visibility}function _(e){const t="number"==typeof e?e:parseInt(e,10);return(t>9?"":"0")+t}function v(e){if(isNaN(e)||e>=Number.MAX_SAFE_INTEGER)return"";const t=e<0?"-":"";e=Math.round(Math.abs(e));const n=Math.floor(e/3600);let r=Math.floor(e/60);return e-=60*r,n>=1?(r-=60*n,t+n+":"+_(r)+":"+_(e)):t+_(r)+":"+_(e)}function g(e,t){if(!e.parentElement)return;const n=e.clientWidth/e.parentElement.clientWidth*100/2;e.style.left=t-n+"%",e.style.display="block"}function y(e,t){if(isNaN(e.duration))return;const n=e.buffered;n.length&&(t.style.width=Math.min(n.end(n.length-1)/e.duration*100,100)+"%")}function E(e,t){e.style.width="0",t.style.display="none"}!function(e){e.GRABBING="has-grab",e.TOUCHING="has-touch"}(h||(h={}));function b(e,t){const n=e.seekable;if("object"!=typeof e.opts||0==n.length)return{head:0,tail:0};const r=function(e){var t;const n=e.seekable;return n.length?e.hasState("is-chromecast-playing")||!(null===(t=e.hls)||void 0===t?void 0:t.liveSyncPosition)?n.end(n.length-1):e.hls.liveSyncPosition:0}(e),i=t||e.live_state.dvr_window;return{head:r,tail:"number"!=typeof i||r-i<0?n.start(0):r-i}}function A(e,t,n){if(!t.seekable||0==t.seekable.length)return;g(n,e);const r=b(t),i=(100-Math.max(0,Math.min(e,100)))/100*(r.head-r.tail);n.innerText="-"+v(i)}function w(e,t){e/=100,t.currentTime=function(e,t){if(t>1||t<0)return console.warn("cannot calculate a percent outside of range(0..1)"),0;const n=b(e);return n.tail+t*(n.head-n.tail)}(t,e)}function k(e,t){e.style.width="0",t.style.display="none"}class FlowplayerTimelineBar extends FlowplayerComponent{constructor(e){let t;super(e),this.bufferEle=c("fp-buffer"),this.progress=c("fp-progress","fp-color"),this.tooltipEle=c("fp-timestamp"),this.proposedSeekBar=c("fp-hover"),this.dragger=c("fp-dragger","fp-color"),this.classList.add("fp-timeline","fp-bar"),this.tooltipEle.style.display="none",this.setAttribute("role","slider"),this.setAttribute("tabindex","0"),this.setAttribute("aria-label",e.i18n("core.timeline_aria_label","Seek slider")),this.setAttribute("aria-valuenow","0"),this.progress.append(this.dragger),this.append(this.bufferEle,this.progress,this.proposedSeekBar,this.tooltipEle);const n=requestAnimationFrame;let r=void 0;const i=()=>{var n;0==e.reaper||t.live||(n=e,this.progress.style.width=n.currentTime/n.duration*100+"%",r=void 0,e.paused||this.classList.contains(h.GRABBING)||r||(r=setTimeout(i,200)))},s=()=>!!this.player.opt("seekable",!0)&&!isNaN(this.player.duration);p(this,{onseek:(n,r)=>{if(s())switch(!!t.live){case!0:A(r,e,this.tooltipEle);break;case!1:!function(e,t,n){const r=t.duration*(e/100);if(t.disabled&&r>t.currentTime)return!1;n.style.width=e+"%",t.currentTime=r}(r,e,this.progress),g(this.tooltipEle,r)}},onstart:()=>{s()&&(e.emit("timeline/gesture/start"),!e.hasState("is-casting")&&e.setState("is-seeking",!0),t.live||function(e){e.style.display="block"}(this.tooltipEle))},onend:function(r,s){n(i),0!=t.seekable&&t.live&&w(s,e)},ontouchend:()=>{t.live?k(this.proposedSeekBar,this.tooltipEle):E(this.proposedSeekBar,this.tooltipEle),setTimeout(()=>e.emit("timeline/gesture/end"),0)},onmouse:(n,r)=>{if(s()&&(e.emit("timeline/gesture/move",{percent:r}),!this.classList.contains(h.GRABBING)))switch(!!t.live){case!0:!function(e,t){t.style.width=e+"%"}(r,this.proposedSeekBar),A(r,e,this.tooltipEle);break;case!1:!function(e,t){t.style.width=e+"%"}(r,this.proposedSeekBar),function(e,t,n){isNaN(e)||isNaN(t.duration)||(g(n,e),n.textContent=v(e/100*t.duration))}(r,e,this.tooltipEle)}}}),e.on("config",(function(e){e.data&&(t=e.data)})),e.on("playing",()=>n(i)),e.on("progress",()=>{0==e.reaper||t.live||y(e,this.bufferEle)}),e.on("dvr",e=>{this.progress.style.width=e.detail+"%"}),e.on("timeupdate",()=>{0!=e.reaper&&(n(i),this.setAttribute("aria-valuenow",e.currentTime+""),this.setAttribute("aria-valuetext",Math.round(e.currentTime)+" "+e.i18n("core.seconds","Seconds")),t.live||y(e,this.bufferEle))}),e.on("loadedmetadata",()=>{0!=e.reaper&&(t.live||y(e,this.bufferEle))}),e.on("durationchange",t=>{if(0==e.reaper)return;const n=function(e){return e.opt("live",!1)||e.duration>=Number.MAX_SAFE_INTEGER}(e)?function(e){return isFinite(e.duration)?e.duration:0==e.seekable.length?0:b(e).head}(e):t.data||e.duration;isNaN(n)||(this.setAttribute("aria-valuemax",n+""),this.setAttribute("aria-valuemin","0"))}),this.addEventListener("mouseleave",()=>{e.emit("timeline/gesture/end"),t.live?k(this.proposedSeekBar,this.tooltipEle):E(this.proposedSeekBar,this.tooltipEle)})}}class FlowplayerChaptersTimelineBar extends FlowplayerTimelineBar{constructor(e){super(e),this.handleChapters(e)}handleChapters(e){const t=document.createElement("div");let n;this.addEventListener("chapters:new",e=>{t.innerText="",this.querySelectorAll(".fp-chapter").forEach(e=>this.removeChild(e)),e.data&&e.data.forEach(e=>{const r=document.createElement("div");r.className="fp-chapter",r.style.left=e.left,r.style.bottom=r.style.top="0",r.style.width=e.width,r.title=e.title,r.onmouseover=()=>{t.innerText=e.title},r.onmouseleave=()=>{t.innerText=n||""},this.appendChild(r)})}),this.addEventListener("chapter:changed",r=>{var i;const s=r.data;s&&(t.parentNode||(null===(i=a(e,"flowplayer-control"))||void 0===i||i.insertAdjacentElement("beforebegin",t),t.classList.toggle("fp-togglable",!0),t.classList.toggle("fp-chapter-info",!0)),n=s,t.innerText=s)})}}var T;const N=((T=class Chapters{constructor(t){this._track_added_handler=e,this._cue_changed_handler=e,this.chapters=[],this.render=this.render.bind(this),t.customElements.get(l)===l&&(((e,t,n)=>{window.customElements.get(t)||window.customElements.define(t,n),e.customElements.get(t)||e.customElements.set(t,t)})(t,"flowplayer-chapters-timeline-bar",FlowplayerChaptersTimelineBar),t.customElements.set(l,"flowplayer-chapters-timeline-bar"))}init(e,t,n){this._root=t,this._player=n,this._timeline=a(n,l),this._track_added_handler=this.track_added.bind(this,n),this._cue_changed_handler=this.cue_changed.bind(this,n),n.textTracks.addEventListener("addtrack",this._track_added_handler),this.wireup(n,e),n.chapters=this,n.on("config",e=>{e.data&&this.wireup(n,e.data)}),n.on(["playlist/advance","src"],e=>{n.currentSrc&&("src"===e.type&&["is-playlist",u].some(e=>n.root.classList.contains(e))||(this._current_chapters_src=void 0,delete n.opts.chapters,this.wiredown(n)))}),n.on("reap",()=>{this.wiredown(n),n.textTracks.removeEventListener("addtrack",this._track_added_handler),n.off("durationchange",this.render)}),n.on("durationchange",this.render)}track_added(e,t){}cue_changed(e,t){var n;this._current_chapters_track&&(this.current_cue=this._current_chapters_track.track.activeCues?this._current_chapters_track.track.activeCues[0]:void 0,this._timeline&&o(this._timeline,"chapter:changed",null===(n=this.current_cue)||void 0===n?void 0:n.text))}set_chapters(e){this.chapters=e,this.render()}jump(e){this._player&&this.chapters[e]&&(this._player.currentTime=this.chapters[e].start)}current(){if(this.current_cue)return this.chapters.find(e=>e.cue==this.current_cue)}render(){if(!this._root||!this._player||!this._timeline)return;const e=this._player.duration;isFinite(e)&&(o(this._timeline,"chapters:new",this.chapters.map(t=>({title:t.label,left:t.start/e*100+"%",width:(t.end-t.start)/e*100+"%"}))),this._root.classList.toggle("has-chapters",!!this.chapters.length))}wireup(e,t){const n=Array.isArray(t.chapters)?t.chapters[0]:t.chapters;n&&n.src!==this._current_chapters_src&&(this._current_chapters_track=i(e,Object.assign(Object.assign({},n),{kind:"chapters",default:!0})),this._current_chapters_track.onload=()=>{var e;(null===(e=this._current_chapters_track)||void 0===e?void 0:e.track.cues)&&this.set_chapters(Array.from(this._current_chapters_track.track.cues).filter(e=>e instanceof VTTCue).map(e=>{const t=e;return{start:e.startTime,end:e.endTime,cue:t,label:t.text}}))},this._current_chapters_src=n.src,this._current_chapters_track.addEventListener("cuechange",this._cue_changed_handler))}wiredown(e){this.set_chapters([]),this._current_chapters_track&&(this._current_chapters_track.removeEventListener("cuechange",this._cue_changed_handler),e.removeChild(this._current_chapters_track),this._current_chapters_track=void 0)}}).events=s,T.pluginName="chapters",T);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,N)}));
|
|
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.chapters=t())}(this,function(){"use strict";function e(){}var t;function n(e,n){if(function(e){return Object.values(t).includes(e)}(n=n||t.Anonymous))return e instanceof HTMLVideoElement&&(e.poster="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="),"crossOrigin"in e?e.crossOrigin=n:e.setAttribute("crossorigin",n),e}function r(e){const t=document.createElement("a");return t.href=e,t.origin}function i(t,i){const s=document.createElement("track");s.className="fp-track renderable",s.kind=i.kind||"captions",s.label=i.label||i.lang||"",s.lang=i.lang||"",s.id=["fp",i.lang].join("-");const o=s.track;return o.removeCue=e,"string"!=typeof i.crossorigin&&function(e,t){try{return e.src.startsWith("blob:"),r(e.src)!==r(t)}catch(e){return console.error(e),!0}}(t,i.src)&&(n(t),i.crossorigin=t.getAttribute("crossorigin")),"crossorigin"in i&&n(t,i.crossorigin),Object.keys(i).forEach(e=>{"default"!==e&&(s[e]=i[e])}),o.mode=i.default?"hidden":"disabled",t.appendChild(s),s}!function(e){e.Anonymous="anonymous",e.UseCredentials="use-credentials",e.Empty=""}(t||(t={}));const s="mousemove",o="durationchange",a="config",c="chapter:changed",l="chapters:new";var u=Object.freeze({__proto__:null,CHAPTER_CHANGED:c,CHAPTERS_NEW:l});function d(e,t,n){const r=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(r),e}function h(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}function p(...e){const t=document.createElement("div");return 0==e.length||t.classList.add(...e),t}!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 f="flowplayer-timeline-bar",m="flowplayer-chapters-timeline-bar",_="is-source-processing";class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}document.addEventListener("click",function(e){this.active_menu&&!e.composedPath().includes(this.active_menu)&&(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))}),this.active_menu=void 0)});const v={passive:!0};var g;function y(t,n){let r=0,i=-1,o=-1;const a=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5),c=t.classList;t.id=a,c.remove(g.GRABBING),c.remove(g.TOUCHING);const l=n.onseek||e,u=n.onstart||e,d=n.onend||e,h=n.onmouse||e,p=n.ontouch||e,f=n.ontouchend||e;function m(e){!function(){const e=t.getBoundingClientRect();r=e.left,i=e.width}();let n=(function(e){return"function"==typeof window.TouchEvent&&e instanceof TouchEvent}(e)?e.changedTouches[0].pageX:e.pageX)-r;return n>i&&(n=i),n<0&&(n=0),n/i*100}function _(e){const n=m(e);n!=o&&(l(t,n),o=n)}return t.addEventListener("touchstart",function(e){E(t,e)&&(c.add(g.TOUCHING),b(t.parentElement)&&(c.add(g.GRABBING),p(t,m(e)),u(t,m(e)),_(e)))},v),t.addEventListener("touchmove",function(e){_(e),h(t,m(e))},v),t.addEventListener("touchend",function(e){setTimeout(function(){c.remove(g.TOUCHING)},500),E(t,e)&&(c.remove(g.GRABBING),f(t,m(e)),d(t,m(e)),i=0)},v),t.addEventListener("touchcancel",function(){c.remove(g.GRABBING,g.TOUCHING),i=0},v),t.addEventListener("mousedown",function(e){c.contains(g.TOUCHING)||(document.addEventListener(s,_),c.add(g.GRABBING),u(t,m(e)),e.preventDefault(),_(e))}),t.addEventListener(s,function(e){c.contains(g.TOUCHING)||h(t,m(e))}),document.addEventListener("mouseup",function(e){c.contains(g.TOUCHING)||(document.removeEventListener(s,_),c.contains(g.GRABBING)&&(c.remove(g.GRABBING),d(t,m(e)),i=0))}),t}function E(e,t){const n=t.target;return!!n&&(n&&!n.closest(e.id)||!b(e.parentElement)||!e.classList.contains(g.TOUCHING))}function b(e){if(!e)return!1;const t=window.getComputedStyle(e);return"0"!==t.width&&"0"!==t.height&&"0"!==t.opacity&&"none"!==t.display&&"hidden"!==t.visibility}function A(e){const t="number"==typeof e?e:parseInt(e,10);return(t>9?"":"0")+t}function w(e){if(isNaN(e)||e>=Number.MAX_SAFE_INTEGER)return"";const t=e<0?"-":"";e=Math.round(Math.abs(e));const n=Math.floor(e/3600);let r=Math.floor(e/60);return e-=60*r,n>=1?(r-=60*n,t+n+":"+A(r)+":"+A(e)):t+A(r)+":"+A(e)}function k(e,t){if(!e.parentElement)return;const n=e.clientWidth/e.parentElement.clientWidth*100/2;e.style.left=t-n+"%",e.style.display="block"}function T(e,t){if(isNaN(e.duration))return;const n=e.buffered;n.length&&(t.style.width=Math.min(n.end(n.length-1)/e.duration*100,100)+"%")}function N(e,t){e.style.width="0",t.style.display="none"}!function(e){e.GRABBING="has-grab",e.TOUCHING="has-touch"}(g||(g={}));const C="is-chromecast-playing";function B(e,t){const n=e.seekable;if("object"!=typeof e.opts||0==n.length)return{head:0,tail:0};const r=function(e){var t;const n=e.seekable;return n.length?e.hasState(C)||!(null===(t=e.hls)||void 0===t?void 0:t.liveSyncPosition)?n.end(n.length-1):e.hls.liveSyncPosition:0}(e),i=t||e.live_state.dvr_window;return{head:r,tail:"number"!=typeof i||r-i<0?n.start(0):r-i}}function G(e,t,n){if(!t.seekable||0==t.seekable.length)return;k(n,e);const r=B(t),i=(100-Math.max(0,Math.min(e,100)))/100*(r.head-r.tail);n.innerText="-"+w(i)}function L(e,t){e/=100,t.currentTime=function(e,t){if(t>1||t<0)return console.warn("cannot calculate a percent outside of range(0..1)"),0;const n=B(e);return n.tail+t*(n.head-n.tail)}(t,e)}function S(e,t){e.style.width="0",t.style.display="none"}class FlowplayerTimelineBar extends FlowplayerComponent{constructor(e){let t;super(e),this.bufferEle=p("fp-buffer"),this.progress=p("fp-progress","fp-color"),this.tooltipEle=p("fp-timestamp"),this.proposedSeekBar=p("fp-hover"),this.dragger=p("fp-dragger","fp-color"),this.classList.add("fp-timeline","fp-bar"),this.tooltipEle.style.display="none",this.setAttribute("role","slider"),this.setAttribute("tabindex","0"),this.setAttribute("aria-label",e.i18n("core.timeline_aria_label","Seek slider")),this.setAttribute("aria-valuenow","0"),this.progress.append(this.dragger),this.append(this.bufferEle,this.progress,this.proposedSeekBar,this.tooltipEle);const n=requestAnimationFrame;let r;const i=()=>{var n;0==e.reaper||t.live||(n=e,this.progress.style.width=n.currentTime/n.duration*100+"%",r=void 0,e.paused||this.classList.contains(g.GRABBING)||r||(r=setTimeout(i,200)))},s=()=>!!this.player.opt("seekable",!0)&&!isNaN(this.player.duration);y(this,{onseek:(n,r)=>{if(s())switch(!!t.live){case!0:G(r,e,this.tooltipEle);break;case!1:!function(e,t,n){const r=t.duration*(e/100);if(t.disabled&&r>t.currentTime)return!1;n.style.width=e+"%",t.currentTime=r}(r,e,this.progress),k(this.tooltipEle,r)}},onstart:()=>{s()&&(e.emit("timeline/gesture/start"),!e.hasState("is-casting")&&e.setState("is-seeking",!0),t.live||function(e){e.style.display="block"}(this.tooltipEle))},onend:function(r,s){n(i),0!=t.seekable&&t.live&&L(s,e)},ontouchend:()=>{t.live?S(this.proposedSeekBar,this.tooltipEle):N(this.proposedSeekBar,this.tooltipEle),setTimeout(()=>e.emit("timeline/gesture/end"),0)},onmouse:(n,r)=>{if(s()&&(e.emit("timeline/gesture/move",{percent:r}),!this.classList.contains(g.GRABBING)))switch(!!t.live){case!0:!function(e,t){t.style.width=e+"%"}(r,this.proposedSeekBar),G(r,e,this.tooltipEle);break;case!1:!function(e,t){t.style.width=e+"%"}(r,this.proposedSeekBar),function(e,t,n){isNaN(e)||isNaN(t.duration)||(k(n,e),n.textContent=w(e/100*t.duration))}(r,e,this.tooltipEle)}}}),e.on(a,function(e){e.data&&(t=e.data)}),e.on("playing",()=>n(i)),e.on("progress",()=>{0==e.reaper||t.live||T(e,this.bufferEle)}),e.on("dvr",e=>{this.progress.style.width=e.detail+"%"}),e.on("timeupdate",()=>{0!=e.reaper&&(n(i),this.setAttribute("aria-valuenow",e.currentTime+""),this.setAttribute("aria-valuetext",Math.round(e.currentTime)+" "+e.i18n("core.seconds","Seconds")),t.live||T(e,this.bufferEle))}),e.on("loadedmetadata",()=>{0!=e.reaper&&(t.live||T(e,this.bufferEle))}),e.on(o,t=>{if(0==e.reaper)return;const n=function(e){return e.opt("live",!1)||e.duration>=Number.MAX_SAFE_INTEGER}(e),r=n?function(e){return isFinite(e.duration)?e.duration:0==e.seekable.length?0:B(e).head}(e):t.data||e.duration;isNaN(r)||(this.setAttribute("aria-valuemax",r+""),this.setAttribute("aria-valuemin","0"))}),this.addEventListener("mouseleave",()=>{e.emit("timeline/gesture/end"),t.live?S(this.proposedSeekBar,this.tooltipEle):N(this.proposedSeekBar,this.tooltipEle)})}}class FlowplayerChaptersTimelineBar extends FlowplayerTimelineBar{constructor(e){super(e),this.handleChapters(e)}handleChapters(e){const t=document.createElement("div");let n;this.addEventListener(l,e=>{t.innerText="",this.querySelectorAll(".fp-chapter").forEach(e=>this.removeChild(e)),e.data&&e.data.forEach(e=>{const r=document.createElement("div");r.className="fp-chapter",r.style.left=e.left,r.style.bottom=r.style.top="0",r.style.width=e.width,r.title=e.title,r.onmouseover=()=>{t.innerText=e.title},r.onmouseleave=()=>{t.innerText=n||""},this.appendChild(r)})}),this.addEventListener(c,r=>{var i;const s=r.data;s&&(t.parentNode||(null===(i=h(e,"flowplayer-control"))||void 0===i||i.insertAdjacentElement("beforebegin",t),t.classList.toggle("fp-togglable",!0),t.classList.toggle("fp-chapter-info",!0)),n=s,t.innerText=s)})}}var x;const I=((x=class Chapters{constructor(t){this._track_added_handler=e,this._cue_changed_handler=e,this.chapters=[],this.render=this.render.bind(this),t.customElements.get(f)===f&&(((e,t,n)=>{window.customElements.get(t)||window.customElements.define(t,n),e.customElements.get(t)||e.customElements.set(t,t)})(t,m,FlowplayerChaptersTimelineBar),t.customElements.set(f,m))}init(e,t,n){this._root=t,this._player=n,this._timeline=h(n,f),this._track_added_handler=this.track_added.bind(this,n),this._cue_changed_handler=this.cue_changed.bind(this,n),n.textTracks.addEventListener("addtrack",this._track_added_handler),this.wireup(n,e),n.chapters=this,n.on(a,e=>{e.data&&this.wireup(n,e.data)}),n.on(["playlist/advance","src"],e=>{n.currentSrc&&("src"===e.type&&["is-playlist",_].some(e=>n.root.classList.contains(e))||(this._current_chapters_src=void 0,delete n.opts.chapters,this.wiredown(n)))}),n.on("reap",()=>{this.wiredown(n),n.textTracks.removeEventListener("addtrack",this._track_added_handler),n.off(o,this.render)}),n.on(o,this.render)}track_added(e,t){}cue_changed(e,t){var n;this._current_chapters_track&&(this.current_cue=this._current_chapters_track.track.activeCues?this._current_chapters_track.track.activeCues[0]:void 0,this._timeline&&d(this._timeline,c,null===(n=this.current_cue)||void 0===n?void 0:n.text))}set_chapters(e){this.chapters=e,this.render()}jump(e){this._player&&this.chapters[e]&&(this._player.currentTime=this.chapters[e].start)}current(){if(this.current_cue)return this.chapters.find(e=>e.cue==this.current_cue)}render(){if(!this._root||!this._player||!this._timeline)return;const e=this._player.duration;isFinite(e)&&(d(this._timeline,l,this.chapters.map(t=>({title:t.label,left:t.start/e*100+"%",width:(t.end-t.start)/e*100+"%"}))),this._root.classList.toggle("has-chapters",!!this.chapters.length))}wireup(e,t){const n=Array.isArray(t.chapters)?t.chapters[0]:t.chapters;n&&n.src!==this._current_chapters_src&&(this._current_chapters_track=i(e,Object.assign(Object.assign({},n),{kind:"chapters",default:!0})),this._current_chapters_track.onload=()=>{var e;(null===(e=this._current_chapters_track)||void 0===e?void 0:e.track.cues)&&this.set_chapters(Array.from(this._current_chapters_track.track.cues).filter(e=>e instanceof VTTCue).map(e=>{const t=e;return{start:e.startTime,end:e.endTime,cue:t,label:t.text}}))},this._current_chapters_src=n.src,this._current_chapters_track.addEventListener("cuechange",this._cue_changed_handler))}wiredown(e){this.set_chapters([]),this._current_chapters_track&&(this._current_chapters_track.removeEventListener("cuechange",this._cue_changed_handler),e.removeChild(this._current_chapters_track),this._current_chapters_track=void 0)}}).events=u,x.pluginName="chapters",x);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,I)});
|
package/plugins/chromecast.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { BitrateInfo } from 'dashjs';
|
|
2
1
|
import type { Get } from 'type-fest';
|
|
3
2
|
import type { Level } from 'hls.js';
|
|
3
|
+
import type { Representation } from 'dashjs';
|
|
4
4
|
import type { TupleToUnion } from 'type-fest';
|
|
5
5
|
|
|
6
6
|
/* Excluded from this release type: AnyLoader */
|
|
@@ -1537,7 +1537,7 @@ PROGRESS = "progress";
|
|
|
1537
1537
|
*/
|
|
1538
1538
|
declare type QselOption = (Level & {
|
|
1539
1539
|
level: number;
|
|
1540
|
-
}) |
|
|
1540
|
+
}) | Representation | {
|
|
1541
1541
|
name: string | number;
|
|
1542
1542
|
encodingId: string;
|
|
1543
1543
|
spatialLayerId: number;
|
|
@@ -1585,8 +1585,8 @@ QUALITY_CHANGE = "qualitychange";
|
|
|
1585
1585
|
* @public
|
|
1586
1586
|
*/
|
|
1587
1587
|
declare type QualityChangeEventDetail = {
|
|
1588
|
-
before?: Level |
|
|
1589
|
-
after?: Level |
|
|
1588
|
+
before?: Level | Representation;
|
|
1589
|
+
after?: Level | Representation;
|
|
1590
1590
|
plugin: string;
|
|
1591
1591
|
automatic: boolean;
|
|
1592
1592
|
/* Excluded from this release type: downscale */
|
package/plugins/chromecast.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.chromecast=t())}(this,(function(){"use strict";function e(e){const t=document.createElement("a");t.href=e;const n=t.pathname&&t.pathname.split(".");return n.length>1&&n[n.length-1]}function t(e){switch(e){case"video/mpd":return"application/dash+xml";case"video/m3u8":return"application/x-mpegurl";default:return e}}const n=n=>{var{src:o}=n,r=function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}(n,["src"]);return[Object.assign({src:o,type:o?t("video/"+e(o)):""},r)]};function o(e){return n({src:e})}class Pipe{static of(e){return new Pipe(e)}static maybe(e,t,...n){return null==e?e:t.apply(e,[e,...n])}constructor(e){this.data=e}tap(e,...t){return e.apply(this,[this.data,...t]),new Pipe(this.data)}fmap(e,...t){const n=e.apply(this,[this.data,...t]);return new Pipe(n)}unwrap(){return this.data}}const r="chromecast:idle";var a=Object.freeze({__proto__:null,CAST_AVAILABLE:"chromecast:available",CAST_UNAVAILABLE:"chromecast:unavailable",CAST_START_CASTING:"chromecast:start",CAST_IDLE:r,CAST_STATE_CHANGED:"chromecast:state:changed",CAST_SESSION_CHANGED:"chromecast:session:changed",CAST_FIELD_UPDATE:"chromecast:field:update",CAST_MEDIA_LOAD_REQUEST:"chromecast:media"});const s={AAC:"aac",AC3:"ac3",E_AC3:"e_ac3",FMP4:"fmp4",MP3:"mp3",TS:"ts",TS_AAC:"ts_aac"},i={FMP4:"fmp4",MPEG2_TS:"mpeg2_ts"},c=/(video\/mp4)|(application\/x-mpegurl)|(video\/mpd)|(application\/dash\+xml)/;function l(){var e;return(null===(e=g())||void 0===e?void 0:e.getCurrentSession())||null}function u(e){return h(e).unwrap().shift()}function d(e,t){const n=e.opts.chromecast;(null==n?void 0:n.hlsSegmentFormat)&&Object.values(s).includes(n.hlsSegmentFormat.toLowerCase())&&(t.hlsSegmentFormat=n.hlsSegmentFormat),(null==n?void 0:n.hlsVideoSegmentFormat)&&Object.values(i).includes(n.hlsVideoSegmentFormat.toLowerCase())&&(t.hlsVideoSegmentFormat=n.hlsVideoSegmentFormat)}function m(){var e;return(null===(e=l())||void 0===e?void 0:e.getMediaSession())||null}function p(e){var t,n;const o=h(e).unwrap().map((function(e){return null==e?void 0:e.src})),r=null===(n=null===(t=m())||void 0===t?void 0:t.media)||void 0===n?void 0:n.contentId;return!!r&&!!~o.indexOf(r)}function f(e){var t;return(null===(t=e.type)||void 0===t?void 0:t.match(c))||!1}function v(e,t){if(!t.opts.src)return e;const n=(Array.isArray(t.opts.src)?t.opts.src:[t.opts.src]).map(e=>"string"==typeof e?o(e)[0]:e);return e.map(e=>{const t=n.find(t=>t.src===e.src);return t&&t.drm?Object.assign(Object.assign({},e),{drm:t.drm}):e})}function h(e){return Pipe.of(e).fmap(()=>e.original_src||[]).fmap((function(e){return"string"==typeof e?o(e):e})).fmap(v,e).fmap((function(e){return e.filter(f)}))}function g(){var e,t,n;return null===(n=null===(t=null===(e=window.cast)||void 0===e?void 0:e.framework)||void 0===t?void 0:t.CastContext)||void 0===n?void 0:n.getInstance()}function y(e,t){var n;null===(n=w.casting_player)||void 0===n||n.emit(e,t)}function S(e,t,n){e.forEach((function(e){e!==w.casting_player&&e.emit(t,n)}))}function _(e,t,n){e.forEach((function(e){e.emit(t,n)}))}const w={remote_player:void 0,controller:void 0,listener:void 0};function E(e){w.controller&&w.listener&&w.controller.removeEventListener(cast.framework.RemotePlayerEventType.ANY_CHANGE,w.listener),w.remote_player=new cast.framework.RemotePlayer,w.controller=new cast.framework.RemotePlayerController(w.remote_player),w.listener=b.bind(null,e),w.controller.addEventListener(cast.framework.RemotePlayerEventType.ANY_CHANGE,w.listener)}function b(e,t){var n;if((null===(n=g())||void 0===n?void 0:n.getCastState())!==cast.framework.CastState.NOT_CONNECTED)return"IDLE"===t.value?S(e,r):void y("chromecast:field:update",t)}function T(e){return Array.from(e.textTracks).filter(e=>["subtitles","captions"].includes(e.kind))}function A(e){return T(e).flatMap((t,n)=>{try{const o=e.querySelector("#"+t.id);if(!(o instanceof HTMLTrackElement&&o.lang))return[];const r=new chrome.cast.media.Track(n+1e3,chrome.cast.media.TrackType.TEXT);return r.trackContentType="text/vtt",r.subtype=chrome.cast.media.TextTrackType.SUBTITLES,r.trackContentId=o.src,r.name=o.label,r.language=o.lang,r}catch(e){return[]}})}function C(e){var t;const n=new chrome.cast.media.EditTracksInfoRequest(e);null===(t=m())||void 0===t||t.editTracksInfo(n,console.debug,console.error)}var k=Object.freeze({__proto__:null,getCurrentSession:l,getMedia:u,setMediaSegmentFormat:d,getMediaSession:m,isSame:p,is_supported_media:f,injectDRMConfiguration:v,normalizeSrc:h,getCastContext:g,broadcast_to_active:y,broadcast_to_idle:S,broadcast:_,SINGLETONS:w,refresh_singletons:E,onremotechange:b,tracks:T,cast_tracks:A,editTracks:C});var O=Object.freeze({__proto__:null,STABLE:"940D4BE4",CANARY:"6F71FA7C",LOCAL:"5258CA32"});const L="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1";function P(e,t,n){if(document.querySelector("script[src='"+L+"']"))return x(n);!function(){const e=document.createElement("script");e.async=!0,e.src=L,document.head.appendChild(e)}(),window.__onGCastApiAvailable=function(){!function(e,t,n){var o;if(!I())return;const r=(null===(o=e.chromecast)||void 0===o?void 0:o.app)||"940D4BE4",a=g();if(!a)return;a.setOptions({receiverApplicationId:r,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}),a.addEventListener(cast.framework.CastContextEventType.CAST_STATE_CHANGED,(function(e){_(n,"chromecast:state:changed",e)})),a.addEventListener(cast.framework.CastContextEventType.SESSION_STATE_CHANGED,(function(e){E(n),_(n,"chromecast:session:changed",e)}))}(e,0,n),x(n)}}function I(){return"object"==typeof window.cast&&"object"==typeof chrome.cast}function x(e){if(I())return _(e,"chromecast:available");_(e,"chromecast:unavailable")}const N="is-chromecast-playing";function D(e,t){const n=e.seekable;if("object"!=typeof e.opts||0==n.length)return{head:0,tail:0};const o=function(e){var t;const n=e.seekable;return n.length?e.hasState(N)||!(null===(t=e.hls)||void 0===t?void 0:t.liveSyncPosition)?n.end(n.length-1):e.hls.liveSyncPosition:0}(e),r=t||e.live_state.dvr_window;return{head:o,tail:"number"!=typeof r||o-r<0?n.start(0):o-r}}function M(e){const t=e.currentTime,n=D(e);return{progress:Math.min(100,Math.max(0,(t-n.tail)/(n.head-n.tail)*100)),is_live:t-n.head>=-10}}const j={player:void 0,listener:void 0};function F(e,t,n,o){var a,s,i,c,p;const f=l();if(!f)return;const v=u(e);if(!v||!v.src)return;w.casting_player=e;const h=new chrome.cast.media.MediaInfo(v.src,v.type||"");h.metadata=new chrome.cast.media.GenericMediaMetadata,function(e){j.player&&j.listener&&j.player.off("playing",j.listener);const t={currentTime:e.currentSessionTime,liveState:e.live_state,progress:M(e).progress};j.player=e,j.listener=()=>{setTimeout(()=>{!function(e,t){const n=m();if(!n)return;if(-1!==n.media.duration)return e.currentTime=t.currentTime;const o=n.liveSeekableRange;if(!o||"number"!=typeof o.end||"number"!=typeof o.start)return;if(void 0===t.liveState.dvr_window||!t.liveState.dvr)return;e.currentTime=(o.end-o.start)*(t.progress/100)}(e,t)},1e3)},e.once("playing",j.listener)}(e);const g={health:e.health,text_tracks:A(e),active_tracks:{active_audio:(null===(s=null===(a=null==e?void 0:e.asel)||void 0===a?void 0:a.active_track)||void 0===s?void 0:s.name)||(null===(c=null===(i=null==e?void 0:e.asel)||void 0===i?void 0:i.active_track)||void 0===c?void 0:c.lang),active_text:null===(p=T(e).find(e=>e.is_active))||void 0===p?void 0:p.label}};v.drm&&(g.drm=v.drm),localStorage.__fpChromecastDebug&&(g.debug=!0),e.opt("ads")&&(g.ads=e.opt("ads")),h.customData=g,d(e,h);const y=new chrome.cast.media.LoadRequest(h);y.customData=e.opt("chromecast",{}),y.customData.metadata=e.opt("metadata"),e.emit("chromecast:media",{request:y}),console.debug("cast:request(%o)",y),f.loadMedia(y).then(()=>{e.emit("remotesession:started"),e.setState("has-casted",!0),e.setState("is-casting",!0),E(t);const n=w.remote_player;n&&(e.volume=n.volumeLevel,e.muted=n.isMuted),S(t,r)},o)}function R(){return!!m()}function G(){return!!l()}function q(){var e;return null===(e=l())||void 0===e?void 0:e.getCastDevice().friendlyName}function H(){var e;return(null===(e=null==k?void 0:l())||void 0===e?void 0:e.getMediaSession()).getEstimatedLiveSeekableRange()}function V(){var e,t;return null===(t=null===(e=m())||void 0===e?void 0:e.media)||void 0===t?void 0:t.duration}function U(){var e;return null===(e=m())||void 0===e?void 0:e.playerState}function B(e){var t;return e?z(e):null===(t=m())||void 0===t?void 0:t.getEstimatedTime()}function z(e){const t=m();if(!t)return e;const n=new chrome.cast.media.SeekRequest;return n.currentTime=e,t.seek(n,console.debug,console.error),e}function Y(){var e;return null===(e=m())||void 0===e?void 0:e.play(new chrome.cast.media.PlayRequest,console.debug,console.error)}function J(){var e;return null===(e=m())||void 0===e?void 0:e.pause(new chrome.cast.media.PauseRequest,console.debug,console.error)}var X=Object.freeze({__proto__:null,load:F,has_media:R,exists:G,device_name:q,seekable_ranges:H,duration:V,state:U,currentTime:B,seek:z,play:Y,pause:J});function $(e,t){if(!e.root)return;const n=e.root.querySelector(".fp-chromecast p");if(!n)return;let o="";o=e.i18n("chromecast.message","{{state}} on {{device}}").replace("{{device}}",(null==t?void 0:t.device)||"chromecast"),o=o.replace("{{state}}",((null==t?void 0:t.state)||"").toLowerCase()),n.textContent=o}const Q="currentTime",K="duration",W="playerState",Z="videoInfo",ee="volumeLevel",te="isMuted",ne="liveSeekableRange",oe=(e,t)=>new(((e,t)=>{const n=e.get(t);if(!n)throw new Error(`no flowplayer component with the name ${t} exists`);const o=window.customElements.get(t);if(!o)throw new Error(`no default flowplayer component with the name ${t} exists`);const r=window.customElements.get(n);return"function"!=typeof r?o:r})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}class FlowplayerChromecastIcon extends FlowplayerComponent{constructor(e){super(e),this.classList.add("fp-cast-button"),this.setAttribute("tabindex","-1"),this.setAttribute("role","button"),this.setAttribute("aria-hidden","true"),this.cast_launcher=document.createElement("google-cast-launcher"),this.cast_launcher.setAttribute("inert","true"),this.append(this.cast_launcher),this.addEventListener("click",t=>{const n=l();if(n)return n.endSession(!0);e.emit("chromecast:start"),t.target===this&&this.cast_launcher.click()}),e.on("chromecast:state:changed",t=>{const n=t.detail.castState;n&&(this.setAttribute("tabindex",n===cast.framework.CastState.NO_DEVICES_AVAILABLE?"-1":"0"),this.setAttribute("aria-hidden",(n===cast.framework.CastState.NO_DEVICES_AVAILABLE)+""),this.setAttribute("aria-label",n===cast.framework.CastState.NOT_CONNECTED?e.i18n("chromecast.start","start casting"):e.i18n("chromecast.stop","stop casting")))})}}function re(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}class ChromecastPlugin{constructor(e){var t,n,o;this.flowplayer=e,t=e,n="flowplayer-chromecast-icon",o=FlowplayerChromecastIcon,window.customElements.get(n)||window.customElements.define(n,o),t.customElements.get(n)||t.customElements.set(n,n)}init(e,t,n){if("https:"!==location.protocol&&"localhost"!==location.hostname&&"127.0.0.1"!==location.hostname)return console.warn("Secure URL required to enable Chromecast");P(e,0,this.flowplayer.instances),n.on("mount",(function(){const t=re(n,"flowplayer-middle");t&&function(e,t){const n=document.createElement("div");n.className="fp-chromecast";const o=document.createElement("p");t.poster&&(n.style.backgroundImage=["url(",t.poster,")"].join("")),n.append(o),e.prepend(n)}(t,{poster:e.poster});const o=re(n,"flowplayer-header-right-zone");o&&o.prepend(oe(n,"flowplayer-chromecast-icon"))})),n.on("chromecast:available",()=>{n.setState("is-cast-available",!0),function(e,t){const n={play:function(){return new Promise(n=>p(e)?n(Y()):R()?n(F(e,t,console.debug,console.error)):(F(e,t,console.debug,console.error),void n()))},pause:function(){return p(e)?J():HTMLMediaElement.prototype.pause.call(e)}};n.currentTime={get:B,set:B},n.seekable={get:()=>{const e=H();return{start:()=>(null==e?void 0:e.start)||0,end:()=>(null==e?void 0:e.end)||0,length:1}}},n.duration={get:V},n.paused={get:function(){return"PAUSED"===U()}},n.playing={get:function(){return"PLAYING"===U()}},Object.keys(n).forEach((function(t){if("object"==typeof n[t])return Object.defineProperty(e,t,{get:function(){var o,r;return p(e)?n[t].get():null===(r=null===(o=Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype,t))||void 0===o?void 0:o.get)||void 0===r?void 0:r.call(this)},set:function(o){var r,a;return p(e)?n[t].set(o):null===(a=null===(r=Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype,t))||void 0===r?void 0:r.set)||void 0===a?void 0:a.call(this,o)}});const o=e[t];e[t]=function(){const r=[].slice.apply(arguments);return G()?n[t].apply(e,r):o.apply(e,r)}}))}(n,this.flowplayer.instances)}),n.on("chromecast:unavailable",(function(){n.setState("is-cast-available",!1)})),n.on("chromecast:start",()=>{if(w.casting_player=n,this.flowplayer.instances.forEach(e=>{e.togglePlay(!1),e.currentSessionTime=e.hasState("is-ended")?0:e.currentTime}),R())return F(n,this.flowplayer.instances,console.debug,console.error)}),n.on("volumechange",()=>{const e=w.remote_player,t=w.controller;if(!R()||!e||!t)return;const o=n.volume,r=n.muted;o!==e.volumeLevel&&(e.volumeLevel=o,t.setVolumeLevel()),r!==e.isMuted&&t.muteOrUnmute()}),n.on("tracks:text:updated",(function(e){var t,o,r;if(R())return e.data?void C((null===(r=null===(o=null===(t=m())||void 0===t?void 0:t.media)||void 0===o?void 0:o.tracks)||void 0===r?void 0:r.filter(e=>"TEXT"===e.type).filter(e=>{var t;return e.name===(null===(t=T(n).find(e=>e.is_active))||void 0===t?void 0:t.label)}).map(e=>e.trackId))||[]):C([])})),n.on("audio:update",()=>{R()&&setTimeout(()=>{var e,t,o,r,a;const s=null===(e=null==n?void 0:n.asel)||void 0===e?void 0:e.active_track,i=null===(a=null===(r=null===(o=null===(t=m())||void 0===t?void 0:t.media)||void 0===o?void 0:o.tracks)||void 0===r?void 0:r.filter(e=>"AUDIO"===e.type).find(e=>void 0!==e.name?e.name===(null==s?void 0:s.name):e.language===(null==s?void 0:s.lang)))||void 0===a?void 0:a.trackId;"number"==typeof i&&C([i])},0)}),n.on(r,()=>{if(n.setState("is-starting",!0),!n.hasState("is-casting"))return;const e=n.opt("duration");"number"==typeof e&&Math.abs(e-n.currentSessionTime)<=1&&(n.currentSessionTime=0,n.setState("is-paused",!1),n.emit("ended")),n.emit("remotesession:ended",{currentTime:n.currentSessionTime}),this.reset_state(n)}),n.on("chromecast:field:update",(function(e){if(!e.data)return;const{field:t,value:o}=e.data;switch(t){case K:return void(-1!==o||n.opts.live||n.setOpts({live:!0}));case te:return n.muted=o;case ee:return n.volume=o;case ne:return n.emit("dvr/window",o.end-o.start);case Q:return Math.abs(o-n.currentSessionTime)>=1.5&&n.emit("seeked"),n.currentSessionTime=o,n.emit("timeupdate",o);case W:return"PLAYING"==o?n.emit("playing"):"PAUSED"==o?n.emit("pause"):void 0;case Z:var r=(o||{}).fake_session||X;return $(n,{device:r.device_name(),state:r.state()}),r.hide_controls&&n.setState("no-chromecast-controls",!0),n.setState("is-starting",!1),n.hasState("is-loaded")||-1===n.duration||n.setOpts({duration:n.duration}),n.setState(N,!0)}})),n.on("chromecast:session:changed",e=>{if(e.data)switch(e.detail.sessionState){case cast.framework.SessionState.SESSION_ENDED:if(!n.hasState("is-casting"))return;return w.casting_player=void 0,n.emit("remotesession:ended",{currentTime:n.currentSessionTime}),this.reset_state(n);case cast.framework.SessionState.SESSION_RESUMED:if(!p(n))return;return w.casting_player=n,n.setState(n.paused?"is-paused":"is-playing",!0),n.setState("is-casting",!0),n.setState("has-casted",!0),n.setState(N,!0),n.emit("timeupdate"),n.currentSessionTime=n.currentTime,$(n,{device:q(),state:U()}),n.setState("is-starting",!1);case cast.framework.SessionState.SESSION_STARTED:if(n!==w.casting_player)return;F(n,this.flowplayer.instances,console.debug,console.error)}})}reset_state(e){e.setState(N,!1),e.setState("is-casting",!1),e.setState("is-playing",!1),e.setState("is-paused",!0),e.setState("is-starting",!0)}}ChromecastPlugin.pluginName="chromecast",ChromecastPlugin.apps=O,ChromecastPlugin.events=a,ChromecastPlugin.hlsSegmentFormat={audio:s,video: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,ChromecastPlugin)}));
|
|
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.chromecast=t())}(this,function(){"use strict";function e(e){const t=document.createElement("a");t.href=e;const n=t.pathname&&t.pathname.split(".");return n.length>1&&n[n.length-1]}function t(e){switch(e){case"video/mpd":return"application/dash+xml";case"video/m3u8":return"application/x-mpegurl";default:return e}}const n=n=>{var{src:o}=n,r=function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}(n,["src"]);return[Object.assign({src:o,type:o?t("video/"+e(o)):""},r)]};function o(e){return n({src:e})}class Pipe{static of(e){return new Pipe(e)}static maybe(e,t,...n){return null==e?e:t.apply(e,[e,...n])}constructor(e){this.data=e}tap(e,...t){return e.apply(this,[this.data,...t]),new Pipe(this.data)}fmap(e,...t){const n=e.apply(this,[this.data,...t]);return new Pipe(n)}unwrap(){return this.data}}const r="chromecast:available",a="chromecast:unavailable",i="chromecast:start",s="chromecast:idle",c="chromecast:state:changed",l="chromecast:session:changed",u="chromecast:field:update",d="chromecast:media";var m=Object.freeze({__proto__:null,CAST_AVAILABLE:r,CAST_UNAVAILABLE:a,CAST_START_CASTING:i,CAST_IDLE:s,CAST_STATE_CHANGED:c,CAST_SESSION_CHANGED:l,CAST_FIELD_UPDATE:u,CAST_MEDIA_LOAD_REQUEST:d});const p={AAC:"aac",AC3:"ac3",E_AC3:"e_ac3",FMP4:"fmp4",MP3:"mp3",TS:"ts",TS_AAC:"ts_aac"},f={FMP4:"fmp4",MPEG2_TS:"mpeg2_ts"},v=/(video\/mp4)|(application\/x-mpegurl)|(video\/mpd)|(application\/dash\+xml)/;function h(){var e;return(null===(e=b())||void 0===e?void 0:e.getCurrentSession())||null}function S(e){return T(e).unwrap().shift()}function y(e,t){const n=e.opts.chromecast;(null==n?void 0:n.hlsSegmentFormat)&&Object.values(p).includes(n.hlsSegmentFormat.toLowerCase())&&(t.hlsSegmentFormat=n.hlsSegmentFormat),(null==n?void 0:n.hlsVideoSegmentFormat)&&Object.values(f).includes(n.hlsVideoSegmentFormat.toLowerCase())&&(t.hlsVideoSegmentFormat=n.hlsVideoSegmentFormat)}function g(){var e;return(null===(e=h())||void 0===e?void 0:e.getMediaSession())||null}function _(e){var t,n;const o=T(e).unwrap().map(function(e){return null==e?void 0:e.src}),r=null===(n=null===(t=g())||void 0===t?void 0:t.media)||void 0===n?void 0:n.contentId;return!!r&&!!~o.indexOf(r)}function w(e){var t;return(null===(t=e.type)||void 0===t?void 0:t.match(v))||!1}function E(e,t){if(!t.opts.src)return e;const n=(Array.isArray(t.opts.src)?t.opts.src:[t.opts.src]).map(e=>"string"==typeof e?o(e)[0]:e);return e.map(e=>{const t=n.find(t=>t.src===e.src);return t&&t.drm?Object.assign(Object.assign({},e),{drm:t.drm}):e})}function T(e){return Pipe.of(e).fmap(()=>e.original_src||[]).fmap(function(e){return"string"==typeof e?o(e):e}).fmap(E,e).fmap(function(e){return e.filter(w)})}function b(){var e,t,n;return null===(n=null===(t=null===(e=window.cast)||void 0===e?void 0:e.framework)||void 0===t?void 0:t.CastContext)||void 0===n?void 0:n.getInstance()}function A(e,t){var n;null===(n=O.casting_player)||void 0===n||n.emit(e,t)}function C(e,t,n){e.forEach(function(e){e!==O.casting_player&&e.emit(t,n)})}function k(e,t,n){e.forEach(function(e){e.emit(t,n)})}const O={remote_player:void 0,controller:void 0,listener:void 0};function L(e){O.controller&&O.listener&&O.controller.removeEventListener(cast.framework.RemotePlayerEventType.ANY_CHANGE,O.listener),O.remote_player=new cast.framework.RemotePlayer,O.controller=new cast.framework.RemotePlayerController(O.remote_player),O.listener=P.bind(null,e),O.controller.addEventListener(cast.framework.RemotePlayerEventType.ANY_CHANGE,O.listener)}function P(e,t){var n;if((null===(n=b())||void 0===n?void 0:n.getCastState())!==cast.framework.CastState.NOT_CONNECTED)return"IDLE"===t.value?C(e,s):void A(u,t)}function I(e){return Array.from(e.textTracks).filter(e=>["subtitles","captions"].includes(e.kind))}function x(e){return I(e).flatMap((t,n)=>{try{const o=e.querySelector("#"+t.id);if(!(o instanceof HTMLTrackElement&&o.lang))return[];const r=new chrome.cast.media.Track(n+1e3,chrome.cast.media.TrackType.TEXT);return r.trackContentType="text/vtt",r.subtype=chrome.cast.media.TextTrackType.SUBTITLES,r.trackContentId=o.src,r.name=o.label,r.language=o.lang,r}catch(e){return[]}})}function N(e){var t;const n=new chrome.cast.media.EditTracksInfoRequest(e);null===(t=g())||void 0===t||t.editTracksInfo(n,console.debug,console.error)}var M=Object.freeze({__proto__:null,getCurrentSession:h,getMedia:S,setMediaSegmentFormat:y,getMediaSession:g,isSame:_,is_supported_media:w,injectDRMConfiguration:E,normalizeSrc:T,getCastContext:b,broadcast_to_active:A,broadcast_to_idle:C,broadcast:k,SINGLETONS:O,refresh_singletons:L,onremotechange:P,tracks:I,cast_tracks:x,editTracks:N});const D="940D4BE4";var j=Object.freeze({__proto__:null,STABLE:D,CANARY:"6F71FA7C",LOCAL:"5258CA32"});const F="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1";function R(e,t,n){if(document.querySelector("script[src='"+F+"']"))return q(n);!function(){const e=document.createElement("script");e.async=!0,e.src=F,document.head.appendChild(e)}(),window.__onGCastApiAvailable=function(){!function(e,t,n){var o;if(!G())return;const r=(null===(o=e.chromecast)||void 0===o?void 0:o.app)||D,a=b();if(!a)return;a.setOptions({receiverApplicationId:r,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}),a.addEventListener(cast.framework.CastContextEventType.CAST_STATE_CHANGED,function(e){k(n,c,e)}),a.addEventListener(cast.framework.CastContextEventType.SESSION_STATE_CHANGED,function(e){L(n),k(n,l,e)})}(e,0,n),q(n)}}function G(){return"object"==typeof window.cast&&"object"==typeof chrome.cast}function q(e){if(G())return k(e,r);k(e,a)}const H="timeupdate",V="remotesession:ended",U="is-cast-available",B="is-casting",z="has-casted",Y="is-chromecast-playing";function J(e,t){const n=e.seekable;if("object"!=typeof e.opts||0==n.length)return{head:0,tail:0};const o=function(e){var t;const n=e.seekable;return n.length?e.hasState(Y)||!(null===(t=e.hls)||void 0===t?void 0:t.liveSyncPosition)?n.end(n.length-1):e.hls.liveSyncPosition:0}(e),r=t||e.live_state.dvr_window;return{head:o,tail:"number"!=typeof r||o-r<0?n.start(0):o-r}}function X(e){const t=e.currentTime,n=J(e);return{progress:Math.min(100,Math.max(0,(t-n.tail)/(n.head-n.tail)*100)),is_live:t-n.head>=-10}}const $={player:void 0,listener:void 0};function Q(e,t,n,o){var r,a,i,c,l;const u=h();if(!u)return;const m=S(e);if(!m||!m.src)return;O.casting_player=e;const p=new chrome.cast.media.MediaInfo(m.src,m.type||"");p.metadata=new chrome.cast.media.GenericMediaMetadata,function(e){$.player&&$.listener&&$.player.off("playing",$.listener);const t={currentTime:e.currentSessionTime,liveState:e.live_state,progress:X(e).progress};$.player=e,$.listener=()=>{setTimeout(()=>{!function(e,t){const n=g();if(!n)return;if(-1!==n.media.duration)return e.currentTime=t.currentTime;const o=n.liveSeekableRange;if(!o||"number"!=typeof o.end||"number"!=typeof o.start)return;if(void 0===t.liveState.dvr_window||!t.liveState.dvr)return;e.currentTime=(o.end-o.start)*(t.progress/100)}(e,t)},1e3)},e.once("playing",$.listener)}(e);const f={health:e.health,text_tracks:x(e),active_tracks:{active_audio:(null===(a=null===(r=null==e?void 0:e.asel)||void 0===r?void 0:r.active_track)||void 0===a?void 0:a.name)||(null===(c=null===(i=null==e?void 0:e.asel)||void 0===i?void 0:i.active_track)||void 0===c?void 0:c.lang),active_text:null===(l=I(e).find(e=>e.is_active))||void 0===l?void 0:l.label}};m.drm&&(f.drm=m.drm),localStorage.__fpChromecastDebug&&(f.debug=!0),e.opt("ads")&&(f.ads=e.opt("ads")),p.customData=f,y(e,p);const v=new chrome.cast.media.LoadRequest(p);v.customData=e.opt("chromecast",{}),v.customData.metadata=e.opt("metadata"),e.emit(d,{request:v}),console.debug("cast:request(%o)",v),u.loadMedia(v).then(()=>{e.emit("remotesession:started"),e.setState(z,!0),e.setState(B,!0),L(t);const n=O.remote_player;n&&(e.volume=n.volumeLevel,e.muted=n.isMuted),C(t,s)},o)}function K(){return!!g()}function W(){return!!h()}function Z(){var e;return null===(e=h())||void 0===e?void 0:e.getCastDevice().friendlyName}function ee(){var e;return(null===(e=null==M?void 0:h())||void 0===e?void 0:e.getMediaSession()).getEstimatedLiveSeekableRange()}function te(){var e,t;return null===(t=null===(e=g())||void 0===e?void 0:e.media)||void 0===t?void 0:t.duration}function ne(){var e;return null===(e=g())||void 0===e?void 0:e.playerState}function oe(e){var t;return e?re(e):null===(t=g())||void 0===t?void 0:t.getEstimatedTime()}function re(e){const t=g();if(!t)return e;const n=new chrome.cast.media.SeekRequest;return n.currentTime=e,t.seek(n,console.debug,console.error),e}function ae(){var e;return null===(e=g())||void 0===e?void 0:e.play(new chrome.cast.media.PlayRequest,console.debug,console.error)}function ie(){var e;return null===(e=g())||void 0===e?void 0:e.pause(new chrome.cast.media.PauseRequest,console.debug,console.error)}var se=Object.freeze({__proto__:null,load:Q,has_media:K,exists:W,device_name:Z,seekable_ranges:ee,duration:te,state:ne,currentTime:oe,seek:re,play:ae,pause:ie});function ce(e,t){if(!e.root)return;const n=e.root.querySelector(".fp-chromecast p");if(!n)return;let o="";o=e.i18n("chromecast.message","{{state}} on {{device}}").replace("{{device}}",(null==t?void 0:t.device)||"chromecast"),o=o.replace("{{state}}",((null==t?void 0:t.state)||"").toLowerCase()),n.textContent=o}const le="is-playing",ue="is-paused",de="is-starting";const me="currentTime",pe="duration",fe="playerState",ve="videoInfo",he="volumeLevel",Se="isMuted",ye="liveSeekableRange",ge=(e,t)=>new(((e,t)=>{const n=e.get(t);if(!n)throw new Error(`no flowplayer component with the name ${t} exists`);const o=window.customElements.get(t);if(!o)throw new Error(`no default flowplayer component with the name ${t} exists`);const r=window.customElements.get(n);return"function"!=typeof r?o:r})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}class FlowplayerChromecastIcon extends FlowplayerComponent{constructor(e){super(e),this.classList.add("fp-cast-button"),this.setAttribute("tabindex","-1"),this.setAttribute("role","button"),this.setAttribute("aria-hidden","true"),this.cast_launcher=document.createElement("google-cast-launcher"),this.cast_launcher.setAttribute("inert","true"),this.append(this.cast_launcher),this.addEventListener("click",t=>{const n=h();if(n)return n.endSession(!0);e.emit(i),t.target===this&&this.cast_launcher.click()}),e.on(c,t=>{const n=t.detail.castState;n&&(this.setAttribute("tabindex",n===cast.framework.CastState.NO_DEVICES_AVAILABLE?"-1":"0"),this.setAttribute("aria-hidden",(n===cast.framework.CastState.NO_DEVICES_AVAILABLE)+""),this.setAttribute("aria-label",n===cast.framework.CastState.NOT_CONNECTED?e.i18n("chromecast.start","start casting"):e.i18n("chromecast.stop","stop casting")))})}}function _e(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}const we="flowplayer-chromecast-icon";class ChromecastPlugin{constructor(e){var t,n,o;this.flowplayer=e,t=e,n=we,o=FlowplayerChromecastIcon,window.customElements.get(n)||window.customElements.define(n,o),t.customElements.get(n)||t.customElements.set(n,n)}init(e,t,n){if("https:"!==location.protocol&&"localhost"!==location.hostname&&"127.0.0.1"!==location.hostname)return console.warn("Secure URL required to enable Chromecast");R(e,0,this.flowplayer.instances),n.on("mount",function(){const t=_e(n,"flowplayer-middle");t&&function(e,t){const n=document.createElement("div");n.className="fp-chromecast";const o=document.createElement("p");t.poster&&(n.style.backgroundImage=["url(",t.poster,")"].join("")),n.append(o),e.prepend(n)}(t,{poster:e.poster});const o=_e(n,"flowplayer-header-right-zone");o&&o.prepend(ge(n,we))}),n.on(r,()=>{n.setState(U,!0),function(e,t){const n={play:function(){return new Promise(n=>_(e)?n(ae()):K()?n(Q(e,t,console.debug,console.error)):(Q(e,t,console.debug,console.error),void n()))},pause:function(){return _(e)?ie():HTMLMediaElement.prototype.pause.call(e)}};n.currentTime={get:oe,set:oe},n.seekable={get:()=>{const e=ee();return{start:()=>(null==e?void 0:e.start)||0,end:()=>(null==e?void 0:e.end)||0,length:1}}},n.duration={get:te},n.paused={get:function(){return"PAUSED"===ne()}},n.playing={get:function(){return"PLAYING"===ne()}},Object.keys(n).forEach(function(t){if("object"==typeof n[t])return Object.defineProperty(e,t,{get:function(){var o,r;return _(e)?n[t].get():null===(r=null===(o=Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype,t))||void 0===o?void 0:o.get)||void 0===r?void 0:r.call(this)},set:function(o){var r,a;return _(e)?n[t].set(o):null===(a=null===(r=Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype,t))||void 0===r?void 0:r.set)||void 0===a?void 0:a.call(this,o)}});const o=e[t];e[t]=function(){const r=[].slice.apply(arguments);return W()?n[t].apply(e,r):o.apply(e,r)}})}(n,this.flowplayer.instances)}),n.on(a,function(){n.setState(U,!1)}),n.on(i,()=>{if(O.casting_player=n,this.flowplayer.instances.forEach(e=>{e.togglePlay(!1),e.currentSessionTime=e.hasState("is-ended")?0:e.currentTime}),K())return Q(n,this.flowplayer.instances,console.debug,console.error)}),n.on("volumechange",()=>{const e=O.remote_player,t=O.controller;if(!K()||!e||!t)return;const o=n.volume,r=n.muted;o!==e.volumeLevel&&(e.volumeLevel=o,t.setVolumeLevel()),r!==e.isMuted&&t.muteOrUnmute()}),n.on("tracks:text:updated",function(e){var t,o,r;if(K())return e.data?void N((null===(r=null===(o=null===(t=g())||void 0===t?void 0:t.media)||void 0===o?void 0:o.tracks)||void 0===r?void 0:r.filter(e=>"TEXT"===e.type).filter(e=>{var t;return e.name===(null===(t=I(n).find(e=>e.is_active))||void 0===t?void 0:t.label)}).map(e=>e.trackId))||[]):N([])}),n.on("audio:update",()=>{K()&&setTimeout(()=>{var e,t,o,r,a;const i=null===(e=null==n?void 0:n.asel)||void 0===e?void 0:e.active_track,s=null===(a=null===(r=null===(o=null===(t=g())||void 0===t?void 0:t.media)||void 0===o?void 0:o.tracks)||void 0===r?void 0:r.filter(e=>"AUDIO"===e.type).find(e=>void 0!==e.name?e.name===(null==i?void 0:i.name):e.language===(null==i?void 0:i.lang)))||void 0===a?void 0:a.trackId;"number"==typeof s&&N([s])},0)}),n.on(s,()=>{if(n.setState(de,!0),!n.hasState(B))return;const e=n.opt("duration");"number"==typeof e&&Math.abs(e-n.currentSessionTime)<=1&&(n.currentSessionTime=0,n.setState(ue,!1),n.emit("ended")),n.emit(V,{currentTime:n.currentSessionTime}),this.reset_state(n)}),n.on(u,function(e){if(!e.data)return;const{field:t,value:o}=e.data;switch(t){case pe:return void(-1!==o||n.opts.live||n.setOpts({live:!0}));case Se:return n.muted=o;case he:return n.volume=o;case ye:return n.emit("dvr/window",o.end-o.start);case me:return Math.abs(o-n.currentSessionTime)>=1.5&&n.emit("seeked"),n.currentSessionTime=o,n.emit(H,o);case fe:return"PLAYING"==o?n.emit("playing"):"PAUSED"==o?n.emit("pause"):void 0;case ve:var r=(o||{}).fake_session||se;return ce(n,{device:r.device_name(),state:r.state()}),r.hide_controls&&n.setState("no-chromecast-controls",!0),n.setState(de,!1),n.hasState("is-loaded")||-1===n.duration||n.setOpts({duration:n.duration}),n.setState(Y,!0)}}),n.on(l,e=>{if(e.data)switch(e.detail.sessionState){case cast.framework.SessionState.SESSION_ENDED:if(!n.hasState(B))return;return O.casting_player=void 0,n.emit(V,{currentTime:n.currentSessionTime}),this.reset_state(n);case cast.framework.SessionState.SESSION_RESUMED:if(!_(n))return;return O.casting_player=n,n.setState(n.paused?ue:le,!0),n.setState(B,!0),n.setState(z,!0),n.setState(Y,!0),n.emit(H),n.currentSessionTime=n.currentTime,ce(n,{device:Z(),state:ne()}),n.setState(de,!1);case cast.framework.SessionState.SESSION_STARTED:if(n!==O.casting_player)return;Q(n,this.flowplayer.instances,console.debug,console.error)}})}reset_state(e){e.setState(Y,!1),e.setState(B,!1),e.setState(le,!1),e.setState(ue,!0),e.setState(de,!0)}}ChromecastPlugin.pluginName="chromecast",ChromecastPlugin.apps=j,ChromecastPlugin.events=m,ChromecastPlugin.hlsSegmentFormat={audio:p,video: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 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,ChromecastPlugin)});
|
package/plugins/comscore.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { BitrateInfo } from 'dashjs';
|
|
2
1
|
import type { Get } from 'type-fest';
|
|
3
2
|
import type { Level } from 'hls.js';
|
|
3
|
+
import type { Representation } from 'dashjs';
|
|
4
4
|
import type { TupleToUnion } from 'type-fest';
|
|
5
5
|
|
|
6
6
|
/* Excluded from this release type: AnyLoader */
|
|
@@ -1472,7 +1472,7 @@ PROGRESS = "progress";
|
|
|
1472
1472
|
*/
|
|
1473
1473
|
declare type QselOption = (Level & {
|
|
1474
1474
|
level: number;
|
|
1475
|
-
}) |
|
|
1475
|
+
}) | Representation | {
|
|
1476
1476
|
name: string | number;
|
|
1477
1477
|
encodingId: string;
|
|
1478
1478
|
spatialLayerId: number;
|
|
@@ -1520,8 +1520,8 @@ QUALITY_CHANGE = "qualitychange";
|
|
|
1520
1520
|
* @public
|
|
1521
1521
|
*/
|
|
1522
1522
|
declare type QualityChangeEventDetail = {
|
|
1523
|
-
before?: Level |
|
|
1524
|
-
after?: Level |
|
|
1523
|
+
before?: Level | Representation;
|
|
1524
|
+
after?: Level | Representation;
|
|
1525
1525
|
plugin: string;
|
|
1526
1526
|
automatic: boolean;
|
|
1527
1527
|
/* Excluded from this release type: downscale */
|
package/plugins/comscore.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.comscore=e())}(this,
|
|
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.comscore=e())}(this,function(){"use strict";var t;function e(){return"undefined"!=typeof ns_}const s=((t=class ComscorePlugin{constructor(){this.started=!1,this.paused=!1,this.ad_playing=!1,this.title="",this.id="",this.account_id="",this.is_live=!1,this.content_duration=0}init(t,s,i){if("object"!=typeof t.comscore)return;if(i.hasState("consent-no-tracking"))return;if(this.video=i,this.config=t,e())return this.wireup();const n=document.createElement("script");n.src="https://sb.scorecardresearch.com/c2/libraries/js/v6/6.3.1.181004.js",n.onload=()=>this.wireup(),document.body.appendChild(n)}wireup(){if(e()&&this.video){if(document){document.addEventListener("unload",this.closed),document.addEventListener("pagehide",this.closed2);const t=this.getHiddenProp();if(t){const e=t.replace(/[H|h]idden/,"")+"visibilitychange";document.addEventListener(e,this.visChange)}}var t;this.video.on(["loadedmetadata","loadeddata","progress","loadstart","ended","seeked","seeking","pause","playing","load","config","ad-started","ad-completed","ad-break-completed"],(t=t=>{switch(t.type){case"playing":this.playing();break;case"pause":this.pause();break;case"seeking":this.seeking();break;case"seeked":this.seeked();break;case"ended":this.ended();break;case"config":this.configured(t);break;case"ad-started":this.ad_started(t);break;case"ad-completed":this.ad_completed();break;case"ad-break-completed":this.ad_break_completed()}},e=>{setTimeout(function(){if(!e.defaultPrevented&&!e.prevented)return t(e)},0)}))}}playing(){this.streamingAnalytics||(this.streamingAnalytics=this.setupStreamingAnalytics()),this.started?this.paused&&this.setContentClip():(this.started=!0,this.setContentClip()),this.paused=!1}pause(){this.streamingAnalytics&&!this.ad_playing&&(this.paused=!0,this.streamingAnalytics.stop())}ended(){this.ad_playing=!1,this.started=!1,this.paused=!1,this.content_duration=0,this.streamingAnalytics&&(this.streamingAnalytics.stop(),this.interval=setInterval(()=>this.killStreamingAnalytics,1e3))}killStreamingAnalytics(){this.interval&&clearInterval(this.interval),this.streamingAnalytics&&(this.streamingAnalytics=null)}seeking(){}seeked(){}closed2(){this.ended()}closed(){this.ended()}visChange(){this.streamingAnalytics&&(this.isHidden()?this.streamingAnalytics.stop():this.setContentClip())}getHiddenProp(){const t=["webkit","moz","ms","o"];return"hidden"in document?"hidden":(Array.from({length:t.length}).map((t,e)=>e).forEach(e=>{if(t[e]+"Hidden"in document)return t[e]+"Hidden"}),null)}isHidden(){const t=this.getHiddenProp();return!!t&&document[t]}configured(t){!this.comscore_object&&this.config&&(this.comscore_object=this.config.comscore,this.title=this.comscore_object.media_title||"*null",this.id=this.comscore_object.media_id||"*null",this.account_id=this.comscore_object.account_id,this.streamingAnalytics=this.setupStreamingAnalytics(),t.data&&(t.data.live&&(this.is_live=!0),t.data.title&&(this.title=t.data.title),t.data.metadata&&t.data.metadata.media_id&&(this.id=t.data.metadata.media_id),t.data.duration&&(this.content_duration=Math.round(1e3*t.data.duration))))}ad_started(t){this.setAdvertisementClip(t)}ad_completed(){this.streamingAnalytics&&this.streamingAnalytics.stop()}ad_break_completed(){this.setContentClip()}setAdvertisementClip(t){var e;if(this.ad_playing=!0,null==this.comscore_object&&(this.comscore_object=null===(e=this.config)||void 0===e?void 0:e.comscore),!this.comscore_object)return;const s={};t&&t.data&&t.data.ad?s.ns_st_cl=Math.round(1e3*t.data.ad.duration)||0:s.ns_st_cl=0,s.c3=this.comscore_object.c3||"*null",s.c4=this.comscore_object.c4||"*null",s.c6=this.comscore_object.c6||"*null",this.streamingAnalytics&&(this.is_live?this.streamingAnalytics.playVideoAdvertisement(s,ns_.ReducedRequirementsStreamingAnalytics.AdType.LinearLive):this.streamingAnalytics.playVideoAdvertisement(s,ns_.ReducedRequirementsStreamingAnalytics.AdType.LinearOnDemandPreRoll))}setContentClip(){var t;this.ad_playing=!1;const e={};null==this.comscore_object&&(this.comscore_object=null===(t=this.config)||void 0===t?void 0:t.comscore),this.comscore_object&&this.video&&(e.ns_st_ci=this.id,e.ns_st_pr=this.title,e.ns_st_ep=this.comscore_object.ns_st_ep||"*null",e.ns_st_ia=this.comscore_object.ns_st_ia||0,e.ns_st_ge=this.comscore_object.ns_st_ge||"News",e.ns_st_ce=this.comscore_object.ns_st_ce||0,e.ns_st_ddt=this.comscore_object.ns_st_ddt||(new Date).getFullYear()+"-01-01",e.ns_st_tdt=this.comscore_object.ns_st_tdt||(new Date).getFullYear()+"-01-01",e.c3=this.comscore_object.c3||"*null",e.c4=this.comscore_object.c4||"*null",e.c6=this.comscore_object.c6||"*null",this.content_duration<=0&&(this.content_duration=Math.round(1e3*this.video.duration)),e.ns_st_cl=this.content_duration,this.streamingAnalytics&&(this.is_live?(e.ns_st_cl=0,this.streamingAnalytics.playVideoContentPart(e,ns_.ReducedRequirementsStreamingAnalytics.ContentType.Live)):this.streamingAnalytics.playVideoContentPart(e,ns_.ReducedRequirementsStreamingAnalytics.ContentType.ShortFormOnDemand)))}setupStreamingAnalytics(){return new ns_.ReducedRequirementsStreamingAnalytics({publisherId:this.account_id})}}).pluginName="comscore",t);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 s=t.flowplayer;return"function"==typeof s?(s(e),e):(Array.isArray(s.extensions)||(s.extensions=[]),~s.extensions.indexOf(e)||s.extensions.push(e),e)}(window,s)});
|
package/plugins/consent.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { BitrateInfo } from 'dashjs';
|
|
2
1
|
import type { Get } from 'type-fest';
|
|
3
2
|
import type { Level } from 'hls.js';
|
|
3
|
+
import type { Representation } from 'dashjs';
|
|
4
4
|
import type { TupleToUnion } from 'type-fest';
|
|
5
5
|
|
|
6
6
|
/* Excluded from this release type: AnyLoader */
|
|
@@ -1498,7 +1498,7 @@ PROGRESS = "progress";
|
|
|
1498
1498
|
*/
|
|
1499
1499
|
declare type QselOption = (Level & {
|
|
1500
1500
|
level: number;
|
|
1501
|
-
}) |
|
|
1501
|
+
}) | Representation | {
|
|
1502
1502
|
name: string | number;
|
|
1503
1503
|
encodingId: string;
|
|
1504
1504
|
spatialLayerId: number;
|
|
@@ -1546,8 +1546,8 @@ QUALITY_CHANGE = "qualitychange";
|
|
|
1546
1546
|
* @public
|
|
1547
1547
|
*/
|
|
1548
1548
|
declare type QualityChangeEventDetail = {
|
|
1549
|
-
before?: Level |
|
|
1550
|
-
after?: Level |
|
|
1549
|
+
before?: Level | Representation;
|
|
1550
|
+
after?: Level | Representation;
|
|
1551
1551
|
plugin: string;
|
|
1552
1552
|
automatic: boolean;
|
|
1553
1553
|
/* Excluded from this release type: downscale */
|
package/plugins/consent.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.consent=e())}(this,
|
|
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.consent=e())}(this,function(){"use strict";class PlayerStorage{constructor(t,e){this.implementation=t,e&&e.keys().forEach(t=>{"string"==typeof e.implementation[t]&&this.implementation.setItem(t,e.implementation[t])})}keys(){var t;const e=[];for(var n=0;n<this.implementation.length;n++)(null===(t=this.implementation.key(n))||void 0===t?void 0:t.startsWith("flowplayer/"))&&e.push(this.implementation.key(n));return e}removeItem(t){try{this.implementation.removeItem(`flowplayer/${t}`)}catch(t){}}getItem(t){try{return this.implementation.getItem(`flowplayer/${t}`)}catch(t){return null}}setItem(t,e){try{this.implementation.setItem(`flowplayer/${t}`,e)}catch(t){}}clear(){try{this.keys().forEach(t=>this.implementation.removeItem(t))}catch(t){}}get length(){try{return this.keys().length}catch(t){return 0}}key(t){try{return this.implementation.key(t)}catch(t){return null}}}var t,e,n;!function(t){t[t.ALL=1]="ALL",t[t.NONE=2]="NONE"}(t||(t={})),function(t){t[t.ALL=8]="ALL",t[t.NONE=16]="NONE"}(e||(e={}));const s=((n=class ConsentPlugin{constructor(n,s){const o=s._storage.getItem("consent"),r=this.current_value=o&&!isNaN(Number(o))?Number(s._storage.getItem("consent")):t.NONE|e.NONE;this.player=s,this.adapt(Object.assign({consent:r},s.opts))}init(t,e,n){this.adapt(t),n.on("config",t=>{this.adapt(t.detail)});const s=t=>{n.setOpts({consent:t.detail})};document.addEventListener("flowplayer/consent",s),n.on("reap",()=>document.removeEventListener("flowplayer/consent",s))}adapt(n){const s=void 0===n.consent?this.current_value:n.consent;e.ALL&s?this.setStorage(e.ALL):e.NONE&s&&this.setStorage(e.NONE),t.ALL&s?this.setTracking(t.ALL):t.NONE&s&&this.setTracking(t.NONE),this.player._storage.setItem("consent",s.toString())}setStorage(t){try{const n=this.player._storage;switch(this.player.setState("consent-no-storage",t===e.NONE),t){case e.ALL:this.player._storage=new PlayerStorage(localStorage,this.player._storage);break;case e.NONE:this.player._storage=new PlayerStorage(sessionStorage,n),n.clear()}}catch(t){console.debug(t)}}setTracking(e){var n,s;switch(this.player.setState("consent-no-tracking",e===t.NONE),e){case t.ALL:null===(n=this.player.health)||void 0===n||n.toggle(!0);break;case t.NONE:null===(s=this.player.health)||void 0===s||s.toggle(!1)}}}).pluginName="consent",n.tracking=t,n.storage=e,n);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;return"function"==typeof n?(n(e),e):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(e)||n.extensions.push(e),e)}(window,s)});
|