@flowplayer/player 3.1.1 → 3.2.1

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.
@@ -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";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function t(e){var t={exports:{}};return e(t,t.exports),t.exports}var n,r=t((function(t,n){var r=e&&e.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};n.__esModule=!0,n.remove=n.downcase=n.pluck=n.merge=void 0,n.merge=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e.reduce((function(e,t){return r(r({},e),t)}),{})},n.pluck=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return Object.keys(e).filter((function(e){return~t.indexOf(e)})).reduce((function(t,r){var i;return n.merge(t,((i={})[r]=e[r],i))}),{})},n.downcase=function(e){return(e||"").toString().toLowerCase()},n.remove=function(e,t){var n=e.lastIndexOf(t);return~n&&e.splice(n,1),e}})),i=t((function(t,n){var i=e&&e.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=e&&e.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.hasOwnProperty.call(e,n)&&i(t,e,n);return o(t,e),t};n.__esModule=!0;var u=a(r),s=function(){function e(){this.pending=[],this.open=[],this.stats={failures:0,ttl:0}}return e.of=function(){return new e},e.is_empty=function(e){return 0==e.pending.length},e.is_high_water=function(t){return t.open.length==e.MAX_OPEN_REQUESTS},e.maybe_spawn_req=function(t){if(e.is_empty(t))return t;if(e.is_high_water(t))return t;try{var n=e.lpop(t);n&&e.request(t,n)}catch(e){}},e.increment_failures=function(t){return t.stats.failures++,t.stats.failures>e.MAX_FAILURE_COUNT&&(t.stats.ttl=Date.now()+e.REQUEST_TTL_MS),t},e.handle_error=function(t,n){e.rm(t,n),e.increment_failures(t)},e.request=function(t,n){var r=n[0],i=n[1],o=n[2];if(!(Date.now()<t.stats.ttl)){var a=new XMLHttpRequest;t.open.push(a),a.timeout=e.REQUEST_TIMEOUT_MS,a.ontimeout=function(){e.handle_error(t,a)},a.onerror=function(n){e.handle_error(t,a)},a.onreadystatechange=function(){a.readyState==XMLHttpRequest.DONE&&e.rm(t,a),Math.floor(a.status/100)},a.onload=function(){e.rm(t,a),t.stats.failures&&t.stats.failures--},a.open(i,r),a.setRequestHeader("Content-Type","text/plain;charset=UTF-8");try{a.send(JSON.stringify(o))}catch(e){}}},e.rpush=function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];return n.forEach((function(n){t.pending.length>=e.MAX_PENDING||(t.pending.push(n),e.maybe_spawn_req(t))})),t},e.lpop=function(e){return e.pending.shift()},e.rm=function(e,t){return u.remove(e.open,t),e},e.MAX_OPEN_REQUESTS=3,e.MAX_PENDING=5,e.REQUEST_TIMEOUT_MS=4e3,e.REQUEST_TTL_MS=5e3,e.MAX_FAILURE_COUNT=3,e}();n.default=s})),o=t((function(t,n){var r=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};n.__esModule=!0;var o=r(i);n.default=o.default.of()})),a=t((function(e,t){t.__esModule=!0,t.prepare_url=t.URL_PARAM=void 0,t.URL_PARAM=/:([a-zA-Z_]+)/g,t.prepare_url=function(e,n){return e.url.replace(t.URL_PARAM,(function(t){if((t=t.slice(1,t.length))in n)return n[t].toString();e.log.error(new Error("\n preparing url["+e.url+"] failed\n \n parameter["+t+"] not detected in params:\n \n "+JSON.stringify(n,null,2)+"\n "))}))}})),u=t((function(e,t){t.__esModule=!0,t.Log=void 0;var n=function(){function e(e){this.emitter=e}return e.prepare=function(e,t){var n=document.createEvent("Event");return n.initEvent(e,!1,!0),n.ns=e,n.data=t,n},e.of=function(t){return new e(t)},e.prototype.info=function(t){this.emitter.dispatchEvent(e.prepare(e.NAMESPACE.INFO,t))},e.prototype.error=function(t){this.emitter.dispatchEvent(e.prepare(e.NAMESPACE.ERROR,t))},e.prototype.warn=function(t){this.emitter.dispatchEvent(e.prepare(e.NAMESPACE.WARN,t))},e.NAMESPACE={INFO:"tracker:info",ERROR:"tracker:err",WARN:"tracker:warn"},e}();t.Log=n})),s=t((function(e,t){var n;t.__esModule=!0,t.Verb=void 0,(n=t.Verb||(t.Verb={})).POST="POST",n.PUT="PUT",n.GET="GET"})),d=t((function(t,n){var d=e&&e.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),c=e&&e.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),f=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.hasOwnProperty.call(e,n)&&d(t,e,n);return c(t,e),t},l=e&&e.__spreadArrays||function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),i=0;for(t=0;t<n;t++)for(var o=arguments[t],a=0,u=o.length;a<u;a++,i++)r[i]=o[a];return r},p=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};n.__esModule=!0;var _=p(o),v=p(i),m=f(a),h=f(r),y=function(){function e(t,n){var r=this;void 0===n&&(n={});var i=this;if(this.emitter=t,this.url=n.url,this.log=u.Log.of(this.emitter),this.verb=n.verb,this.metadata=h.merge({},n.metadata||{}),this.rq=n.rq||_.default,this.events=n.events||[],this.required_keys=n.required_keys||[],this.optional_keys=n.optional_keys||[],this.listeners=[],this.valid_keys=this.required_keys.slice(0).concat(this.optional_keys),e.assert_emitter_api(this.emitter),void 0===e.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");e.TRACKERS.push(this),i.events.forEach((function(t){e.create_listener(r,t,(function(n){void 0===n&&(n={});var o=h.merge(i.metadata,{event_type:t},n.data||n),a=m.prepare_url(i,o),u=e.pluck_valid_keys(i,o),s=e.ensure_required_keys(i,u);if(s.length)return i.log.error("Tracker.validate_metadata() failed for \n Event["+t+"]\n missing keys: "+s+"\n payload:\n "+JSON.stringify(u,null,2));v.default.rpush(r.rq,[a,r.verb,u])}))}))}return e.of=function(t,n){return new e(t,n)},e.ensure_required_keys=function(e,t){return e.required_keys.filter((function(e){return!(e in t)}))},e.pluck_valid_keys=function(e,t){return h.pluck.apply(h,l([t],e.valid_keys))},e.merge_metadata=function(t,n){return void 0===n&&(n={}),t.metadata=e.pluck_valid_keys(t,h.merge(t.metadata,n)),t},e.assert_emitter_api=function(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")},e.create_listener=function(e,t,n){e.listeners.push([t,n]),e.emitter.addEventListener(t,n)},e.prototype.destroy=function(){var t=this;this.listeners.forEach((function(e){var n=e[0],r=e[1];return t.emitter.removeEventListener(n,r)})),delete this.rq,delete this.emitter,h.remove(e.TRACKERS,this)},e.prototype.put=function(t){return void 0===t&&(t={}),e.merge_metadata(this,t),this},e.TRACKERS=[],e.QUEUE=_.default,e.verb=s.Verb,e}();n.default=y})),c=t((function(t,n){var r=e&&e.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=e&&e.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.hasOwnProperty.call(e,n)&&r(t,e,n);return i(t,e),t},u=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};n.__esModule=!0,n.API=n.Tracker=void 0;var s=u(d);n.Tracker=s.default;var c=o(a);n.API=c}));!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"}(n||(n={}));const f=["localhost","127.0.0.1","0.0.0.0","s.codepen.io","cdpn.io","try.flowplayer.com"];function l(e,t){return!!~f.indexOf(e)||e.indexOf(t)===e.length-t.length}l.check_whitelist=function(e){return!!~f.indexOf(e)};function p(e){this.message=e}p.prototype=new Error,p.prototype.name="InvalidCharacterError";var _="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new p("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,r,i=0,o=0,a="";r=t.charAt(o++);~r&&(n=i%4?64*n+r:r,i++%4)?a+=String.fromCharCode(255&n>>(-2*i&6)):0)r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(r);return a};var v=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(_(e).replace(/(.)/g,(function(e,t){var n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return _(t)}};function m(e){this.message=e}m.prototype=new Error,m.prototype.name="InvalidTokenError";var h=function(e,t){if("string"!=typeof e)throw new m("Invalid token specified");var n=!0===(t=t||{}).header?0:1;try{return JSON.parse(v(e.split(".")[n]))}catch(e){throw new m("Invalid token specified: "+e.message)}};h.InvalidTokenError=m;const y="production";function g(e,t){const n={valid_jwt:!1,raw:"",data:{acl:0},exp:0};let r={c:"{}",exp:0};t=t||{};try{r=h(e),n.valid_jwt=!0}catch(e){}return n.raw=e,n.data=JSON.parse(r.c),n.exp=r.exp,t.require_valid_token&&g.validate(n),n}function w(e){return{grant:e,is_granted:t=>(e&t)===t}}function k(e,t,n){const r=function(e){return Array.isArray(e)?e.slice(0):e.split(".")}(t);for(;r.length;){if(null==e)return n;const t=r.shift();if("string"!=typeof t)return n;e=e[t]}return null==e?n:e}g.validate=function(e){if("string"==typeof e&&(e=g(e)),!e||!e.raw){if(l.check_whitelist(window.location.hostname)||"dev"===y.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,n=l.bind(null,t);if("dev"!==y.toString()&&e.data.domain&&e.data.domain.length&&!e.data.domain.some(n))throw new Error("Domain not allowed");if("dev"!==y.toString()&&1e3*e.exp-Date.now()<0)throw new Error("Expired token");return!0},g.id=function(e){if(e)return"string"==typeof e&&(e=g(e)),e.data.id},w.of=w,w.from_token=function(e){const t=g(e,{require_valid_token:!0});return w.of(t.data.acl)},w.permissions=n;var E="ping",b="display",A="view";const O=["sitegroup_id","session_id","media_id","site_id","player_id","video_type"],T=["created","position"],S=["player_version","created","source","category","category_id","autoplay","muted","customer_user_id"];function M(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,n){return Math.floor(n*t*1e3)/1e3}))}}(e.duration))}function P(e,t,n){if(!t.segment_duration&&!M(e,t))return;const r=function(e,t,n){const r=t.last_idx,i=n?99:R(e,t);return t.last_idx=i,i<=r?[]:t.breakpoints.slice(r,99==i?100:i).map((function(e){return t.breakpoints.indexOf(e)}))}(e,t,n);0!=r.length&&e.emit(E,{position:r})}function R(e,t){return Math.min(Math.floor(e.currentTime/t.segment_duration),99)}const x="vod",N="live",I=[b,E,A];function L(e,t,n){switch(null==t?void 0:t.kind){case"live":return function(e,t){const n=Date.now();n-t.last_tracked_ts<6e4||(t.last_tracked_ts=n,++t.ticks,e.emit(E,{position:60*t.ticks}))}(e,t);case"vod":return P(e,t,"boolean"==typeof n&&n)}}function j(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))))}function q(){try{return window.location!==window.parent.location?document.referrer:document.location.href}catch(e){return!1}}class Analytics{init(e,t,n){if(!w.from_token(e.token||"").is_granted(w.permissions.ANALYTICS))return;if(n.hasState("consent-no-tracking"))return;if(n.analytics)return;const r=n.analytics={ticker:void 0,last_media_id:"",ended:!1},i={locked:!1,ttl:6e3,task:()=>{L(n,r.ticker)}};const o={session_id:n.deviceId(),autoplay:n.autoplay,muted:n.muted,player_id:e.player_id,customer_user_id:e.customer_user_id},a=c.Tracker.of(n,{verb:c.Tracker.verb.POST,url:"https://ptm.flowplayer.com/:video_type/:sitegroup_id/:event_type",events:I,required_keys:O,optional_keys:S.concat(T).slice(0),metadata:o});n.on("reap",(function(){a&&a.destroy()})),n.on("config",(function(t){if(!a)return;const i=k(t,"data.metadata",{});if(!i.media_id)return;const o=k(a,"metadata.media_id");if(o&&i.media_id==o)return;const u=k(e,"analytics",{});a.put(i),a.put(u);const s=k(e,"metadata.live_start_time",e.live)?N:x;a.put({video_type:s,source:e.source||q()||""}),r.ticker=e.live?{ticks:0,last_tracked_ts:Date.now(),kind:"live"}:{last_idx:0,segment_duration:0,breakpoints:[],kind:"vod"},r.ended=!1,n.emit(b)}));let u=0;n.on("playing",(function(){if(!a)return;if(u||function(e,t){return e.metadata.media_id&&e.metadata.media_id==t.last_media_id}(a,r))return;a.put({muted:n.muted});const e=j(n);if(e)return u=Promise.resolve(e).then((function(){r.last_media_id=a.metadata.media_id,n.emit(A),u=0})).catch((function(){u=0}));r.last_media_id=a.metadata.media_id,n.emit(A)})),n.on("timeupdate",(function(){var t;a&&(u||j(n)||r.ended||(!e.live&&n.currentTime+.25>=n.duration&&L(n,r.ticker,!0),(t=i).locked||(t.locked=setTimeout((function(){return t.task(),function(e){return e.locked=!1,e}(t)}),t.ttl))))})),n.on("seeked",(function(){a&&r.ticker&&"vod"==r.ticker.kind&&function(e,t){M(e,t),t.last_idx=R(e,t)}(n,r.ticker)})),n.on("ended",(function(){a&&function(e,t){t.ended||(t.ended=!0,L(e,t.ticker))}(n,r)}))}}return function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;"function"==typeof n?n(t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t))}("undefined"!=typeof window?window:"undefined"!=typeof global?global:{},Analytics),Analytics}));
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";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function t(e){var t={exports:{}};return e(t,t.exports),t.exports}var n,r=t((function(t,n){var r=e&&e.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};n.__esModule=!0,n.remove=n.downcase=n.pluck=n.merge=void 0,n.merge=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e.reduce((function(e,t){return r(r({},e),t)}),{})},n.pluck=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return Object.keys(e).filter((function(e){return~t.indexOf(e)})).reduce((function(t,r){var i;return n.merge(t,((i={})[r]=e[r],i))}),{})},n.downcase=function(e){return(e||"").toString().toLowerCase()},n.remove=function(e,t){var n=e.lastIndexOf(t);return~n&&e.splice(n,1),e}})),i=t((function(t,n){var i=e&&e.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=e&&e.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.hasOwnProperty.call(e,n)&&i(t,e,n);return o(t,e),t};n.__esModule=!0;var u=a(r),s=function(){function e(){this.pending=[],this.open=[],this.stats={failures:0,ttl:0}}return e.of=function(){return new e},e.is_empty=function(e){return 0==e.pending.length},e.is_high_water=function(t){return t.open.length==e.MAX_OPEN_REQUESTS},e.maybe_spawn_req=function(t){if(e.is_empty(t))return t;if(e.is_high_water(t))return t;try{var n=e.lpop(t);n&&e.request(t,n)}catch(e){}},e.increment_failures=function(t){return t.stats.failures++,t.stats.failures>e.MAX_FAILURE_COUNT&&(t.stats.ttl=Date.now()+e.REQUEST_TTL_MS),t},e.handle_error=function(t,n){e.rm(t,n),e.increment_failures(t)},e.request=function(t,n){var r=n[0],i=n[1],o=n[2];if(!(Date.now()<t.stats.ttl)){var a=new XMLHttpRequest;t.open.push(a),a.timeout=e.REQUEST_TIMEOUT_MS,a.ontimeout=function(){e.handle_error(t,a)},a.onerror=function(n){e.handle_error(t,a)},a.onreadystatechange=function(){a.readyState==XMLHttpRequest.DONE&&e.rm(t,a),Math.floor(a.status/100)},a.onload=function(){e.rm(t,a),t.stats.failures&&t.stats.failures--},a.open(i,r),a.setRequestHeader("Content-Type","text/plain;charset=UTF-8");try{a.send(JSON.stringify(o))}catch(e){}}},e.rpush=function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];return n.forEach((function(n){t.pending.length>=e.MAX_PENDING||(t.pending.push(n),e.maybe_spawn_req(t))})),t},e.lpop=function(e){return e.pending.shift()},e.rm=function(e,t){return u.remove(e.open,t),e},e.MAX_OPEN_REQUESTS=3,e.MAX_PENDING=5,e.REQUEST_TIMEOUT_MS=4e3,e.REQUEST_TTL_MS=5e3,e.MAX_FAILURE_COUNT=3,e}();n.default=s})),o=t((function(t,n){var r=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};n.__esModule=!0;var o=r(i);n.default=o.default.of()})),a=t((function(e,t){t.__esModule=!0,t.prepare_url=t.URL_PARAM=void 0,t.URL_PARAM=/:([a-zA-Z_]+)/g,t.prepare_url=function(e,n){return e.url.replace(t.URL_PARAM,(function(t){if((t=t.slice(1,t.length))in n)return n[t].toString();e.log.error(new Error("\n preparing url["+e.url+"] failed\n \n parameter["+t+"] not detected in params:\n \n "+JSON.stringify(n,null,2)+"\n "))}))}})),u=t((function(e,t){t.__esModule=!0,t.Log=void 0;var n=function(){function e(e){this.emitter=e}return e.prepare=function(e,t){var n=document.createEvent("Event");return n.initEvent(e,!1,!0),n.ns=e,n.data=t,n},e.of=function(t){return new e(t)},e.prototype.info=function(t){this.emitter.dispatchEvent(e.prepare(e.NAMESPACE.INFO,t))},e.prototype.error=function(t){this.emitter.dispatchEvent(e.prepare(e.NAMESPACE.ERROR,t))},e.prototype.warn=function(t){this.emitter.dispatchEvent(e.prepare(e.NAMESPACE.WARN,t))},e.NAMESPACE={INFO:"tracker:info",ERROR:"tracker:err",WARN:"tracker:warn"},e}();t.Log=n})),s=t((function(e,t){var n;t.__esModule=!0,t.Verb=void 0,(n=t.Verb||(t.Verb={})).POST="POST",n.PUT="PUT",n.GET="GET"})),d=t((function(t,n){var d=e&&e.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),c=e&&e.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),f=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.hasOwnProperty.call(e,n)&&d(t,e,n);return c(t,e),t},l=e&&e.__spreadArrays||function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),i=0;for(t=0;t<n;t++)for(var o=arguments[t],a=0,u=o.length;a<u;a++,i++)r[i]=o[a];return r},p=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};n.__esModule=!0;var _=p(o),v=p(i),m=f(a),h=f(r),y=function(){function e(t,n){var r=this;void 0===n&&(n={});var i=this;if(this.emitter=t,this.url=n.url,this.log=u.Log.of(this.emitter),this.verb=n.verb,this.metadata=h.merge({},n.metadata||{}),this.rq=n.rq||_.default,this.events=n.events||[],this.required_keys=n.required_keys||[],this.optional_keys=n.optional_keys||[],this.listeners=[],this.valid_keys=this.required_keys.slice(0).concat(this.optional_keys),e.assert_emitter_api(this.emitter),void 0===e.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");e.TRACKERS.push(this),i.events.forEach((function(t){e.create_listener(r,t,(function(n){void 0===n&&(n={});var o=h.merge(i.metadata,{event_type:t},n.data||n),a=m.prepare_url(i,o),u=e.pluck_valid_keys(i,o),s=e.ensure_required_keys(i,u);if(s.length)return i.log.error("Tracker.validate_metadata() failed for \n Event["+t+"]\n missing keys: "+s+"\n payload:\n "+JSON.stringify(u,null,2));v.default.rpush(r.rq,[a,r.verb,u])}))}))}return e.of=function(t,n){return new e(t,n)},e.ensure_required_keys=function(e,t){return e.required_keys.filter((function(e){return!(e in t)}))},e.pluck_valid_keys=function(e,t){return h.pluck.apply(h,l([t],e.valid_keys))},e.merge_metadata=function(t,n){return void 0===n&&(n={}),t.metadata=e.pluck_valid_keys(t,h.merge(t.metadata,n)),t},e.assert_emitter_api=function(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")},e.create_listener=function(e,t,n){e.listeners.push([t,n]),e.emitter.addEventListener(t,n)},e.prototype.destroy=function(){var t=this;this.listeners.forEach((function(e){var n=e[0],r=e[1];return t.emitter.removeEventListener(n,r)})),delete this.rq,delete this.emitter,h.remove(e.TRACKERS,this)},e.prototype.put=function(t){return void 0===t&&(t={}),e.merge_metadata(this,t),this},e.TRACKERS=[],e.QUEUE=_.default,e.verb=s.Verb,e}();n.default=y})),c=t((function(t,n){var r=e&&e.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=e&&e.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.hasOwnProperty.call(e,n)&&r(t,e,n);return i(t,e),t},u=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};n.__esModule=!0,n.API=n.Tracker=void 0;var s=u(d);n.Tracker=s.default;var c=o(a);n.API=c}));!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"}(n||(n={}));const f=["localhost","127.0.0.1","0.0.0.0","s.codepen.io","cdpn.io","try.flowplayer.com"];function l(e,t){return!!~f.indexOf(e)||e.indexOf(t)===e.length-t.length}l.check_whitelist=function(e){return!!~f.indexOf(e)};function p(e){this.message=e}p.prototype=new Error,p.prototype.name="InvalidCharacterError";var _="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new p("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,r,i=0,o=0,a="";r=t.charAt(o++);~r&&(n=i%4?64*n+r:r,i++%4)?a+=String.fromCharCode(255&n>>(-2*i&6)):0)r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(r);return a};var v=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(_(e).replace(/(.)/g,(function(e,t){var n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return _(t)}};function m(e){this.message=e}m.prototype=new Error,m.prototype.name="InvalidTokenError";var h=function(e,t){if("string"!=typeof e)throw new m("Invalid token specified");var n=!0===(t=t||{}).header?0:1;try{return JSON.parse(v(e.split(".")[n]))}catch(e){throw new m("Invalid token specified: "+e.message)}};h.InvalidTokenError=m;const y="production";function g(e,t){const n={valid_jwt:!1,raw:"",data:{acl:0},exp:0};let r={c:"{}",exp:0};t=t||{};try{r=h(e),n.valid_jwt=!0}catch(e){}return n.raw=e,n.data=JSON.parse(r.c),n.exp=r.exp,t.require_valid_token&&g.validate(n),n}function w(e){return{grant:e,is_granted:t=>(e&t)===t}}function k(e,t,n){const r=function(e){return Array.isArray(e)?e.slice(0):e.split(".")}(t);for(;r.length;){if(null==e)return n;const t=r.shift();if("string"!=typeof t)return n;e=e[t]}return null==e?n:e}g.validate=function(e){if("string"==typeof e&&(e=g(e)),!e||!e.raw){if(l.check_whitelist(window.location.hostname)||"dev"===y.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,n=l.bind(null,t);if("dev"!==y.toString()&&e.data.domain&&e.data.domain.length&&!e.data.domain.some(n))throw new Error("Domain not allowed");if("dev"!==y.toString()&&1e3*e.exp-Date.now()<0)throw new Error("Expired token");return!0},g.id=function(e){if(e)return"string"==typeof e&&(e=g(e)),e.data.id},w.of=w,w.from_token=function(e){const t=g(e,{require_valid_token:!0});return w.of(t.data.acl)},w.permissions=n;var E="ping",b="display",A="view";const O=["sitegroup_id","session_id","media_id","site_id","player_id","video_type"],T=["created","position"],S=["player_version","created","source","category","category_id","autoplay","muted","customer_user_id"];function M(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,n){return Math.floor(n*t*1e3)/1e3}))}}(e.duration))}function P(e,t,n){if(!t.segment_duration&&!M(e,t))return;const r=function(e,t,n){const r=t.last_idx,i=n?99:R(e,t);return t.last_idx=i,i<=r?[]:t.breakpoints.slice(r,99==i?100:i).map((function(e){return t.breakpoints.indexOf(e)}))}(e,t,n);0!=r.length&&e.emit(E,{position:r})}function R(e,t){return Math.min(Math.floor(e.currentTime/t.segment_duration),99)}const x="vod",N="live",I=[b,E,A];function L(e,t,n){switch(null==t?void 0:t.kind){case"live":return function(e,t){const n=Date.now();n-t.last_tracked_ts<6e4||(t.last_tracked_ts=n,++t.ticks,e.emit(E,{position:60*t.ticks}))}(e,t);case"vod":return P(e,t,"boolean"==typeof n&&n)}}function j(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))))}function q(){try{return window.location!==window.parent.location?document.referrer:document.location.href}catch(e){return!1}}class Analytics{init(e,t,n){if(!w.from_token(e.token||"").is_granted(w.permissions.ANALYTICS))return;if(n.hasState("consent-no-tracking"))return;if(n.analytics)return;const r=n.analytics={ticker:void 0,last_media_id:"",ended:!1},i={locked:!1,ttl:6e3,task:()=>{L(n,r.ticker)}};const o={session_id:n.deviceId(),autoplay:n.autoplay,muted:n.muted,player_id:e.player_id,customer_user_id:e.customer_user_id,player_version:"3.2.1"},a=c.Tracker.of(n,{verb:c.Tracker.verb.POST,url:"https://ptm.flowplayer.com/:video_type/:sitegroup_id/:event_type",events:I,required_keys:O,optional_keys:S.concat(T).slice(0),metadata:o});n.on("reap",(function(){a&&a.destroy()})),n.on("config",(function(t){if(!a)return;const i=k(t,"data.metadata",{});if(!i.media_id)return;const o=k(a,"metadata.media_id");if(o&&i.media_id==o)return;const u=k(e,"analytics",{});a.put(i),a.put(u);const s=k(e,"metadata.live_start_time",e.live)?N:x;a.put({video_type:s,source:e.source||q()||""}),r.ticker=e.live?{ticks:0,last_tracked_ts:Date.now(),kind:"live"}:{last_idx:0,segment_duration:0,breakpoints:[],kind:"vod"},r.ended=!1,n.emit(b)}));let u=0;n.on("playing",(function(){if(!a)return;if(u||function(e,t){return e.metadata.media_id&&e.metadata.media_id==t.last_media_id}(a,r))return;a.put({muted:n.muted});const e=j(n);if(e)return u=Promise.resolve(e).then((function(){r.last_media_id=a.metadata.media_id,n.emit(A),u=0})).catch((function(){u=0}));r.last_media_id=a.metadata.media_id,n.emit(A)})),n.on("timeupdate",(function(){var t;a&&(u||j(n)||r.ended||(!e.live&&n.currentTime+.25>=n.duration&&L(n,r.ticker,!0),(t=i).locked||(t.locked=setTimeout((function(){return t.task(),function(e){return e.locked=!1,e}(t)}),t.ttl))))})),n.on("seeked",(function(){a&&r.ticker&&"vod"==r.ticker.kind&&function(e,t){M(e,t),t.last_idx=R(e,t)}(n,r.ticker)})),n.on("ended",(function(){a&&function(e,t){t.ended||(t.ended=!0,L(e,t.ticker))}(n,r)}))}}return function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;"function"==typeof n?n(t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t))}("undefined"!=typeof window?window:"undefined"!=typeof global?global:{},Analytics),Analytics}));
package/plugins/asel.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.asel=t())}(this,(function(){"use strict";var e={SET:"audio:set",SWITCH:"audio:update",TRACKS:"audio:tracks"};function t(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 n=navigator.languages||[navigator.language];function s(t,n){t.emit(e.SET,n),n.autoselect&&t._storage.setItem("@flowplayer/audio/track",n.lang)}function o(e){return e.toLowerCase()}function i(e,s,i){s=s.slice(0);const a={},r=e.getItem("@flowplayer/audio/track");let l=function(){try{return n.reduce((e,t)=>~t.indexOf("-")?e.concat(t,t.split("-")[0]):e.concat(t),[])}catch(e){return[]}}().map(o),c=-1;if("number"==typeof i)return i;for("string"==typeof i&&(i=i.toLowerCase(),~l.indexOf(i)&&l.splice(l.indexOf(i),1),l.unshift(o(i))),Array.isArray(i)&&(l=i.map(o));s.length;){++c;const e=s.shift();if(null==e?void 0:e.autoselect){if(r==e.lang)return console.debug("restoring lang from previous session: ",r),c;if(e.default&&(a.fallback=[c,e]),e.lang&&~l.indexOf(e.lang.toLowerCase())){const n=l.indexOf(e.lang);if(n<t(a,"by_lang.2",1/0)&&(a.by_lang=[c,e,n]),0===n)break}}}return t(a,"by_lang.0",t(a,"fallback.0",void 0))}const a=(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 o=window.customElements.get(n);return"function"!=typeof o?s:o})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}const r="fp-on",l="fp-invis";class FlowplayerMenu extends FlowplayerComponent{constructor(e){super(e),this.player=e,this.menuContainer=document.createElement("details"),this.summaryEle=document.createElement("summary"),this.olEle=document.createElement("ol"),this.menu=document.createElement("div"),this.closeEle=document.createElement("span"),this.menu.classList.add("fp-menu"),this.menu.append(this.closeEle,this.olEle),this.closeEle.classList.add("fp-close"),this.closeEle.textContent="×",this.menuContainer.append(this.summaryEle,this.menu),this.menuContainer.addEventListener("click",(function(t){t.preventDefault();const n=this.open;n||(c(),document.active_menu=this),this.open=!n,e.root.classList.toggle("has-menu-opened",!n)})),this.append(this.menuContainer)}get options(){return this.olEle.querySelectorAll("li")}setMenuAttrs(e){if(this.className=`${e.class} ${l}`,this.menuContainer.classList.add("fp-menu-container"),this.menuContainer.setAttribute("aria-controls",e.id||Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)),this.menuContainer.setAttribute("aria-label",e.menuTitle||""),e.summaryTitle&&(this.summaryEle.textContent=e.summaryTitle),e.summaryIcon){const t=a(this.player,e.summaryIcon);t.setAttribute("tabindex",""),this.summaryEle.append(t)}if(e.menuTitle){const t=document.createElement("h3");t.textContent=e.menuTitle,this.menu.prepend(t)}this.menu.classList.toggle("fp-icons",!!e.icons),this.addEventListener(e.options_event,e=>{this.render(e.data)}),e.item_selected_event&&this.addEventListener(e.item_selected_event,e=>{void 0!==e.data&&this.select_item(e.data.selected_index)})}render(e){this.olEle&&(this.olEle.innerHTML="",e&&e.forEach(this.menuOption,this),this.classList.toggle(l,!(null==e?void 0:e.length)))}menuOption(e,t){const n=document.createElement("li");n.setAttribute("tabindex","0"),n.setAttribute("role","menuitem"),e.icon&&n.append(e.icon);const s=document.createElement("span");s.textContent=e.text,n.append(s),n.addEventListener("click",()=>{this.select_item(t),"function"==typeof e.onclick&&e.onclick()}),this.olEle.appendChild(n)}select_item(e){this.options.forEach((t,n)=>{t.classList.toggle(r,n===e&&("flowplayer-subtitles-menu"!==this.localName||!t.classList.contains(r)))})}unselect_item(){this.options.forEach(e=>{e.classList.remove(r)})}}function c(){Array.from(document.querySelectorAll(".fp-engine")).forEach(e=>{const t=e.root.querySelector("details[open].fp-menu-container");t&&(t.open=!1,e.root.classList.toggle("has-menu-opened",!1))})}function u(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("click",(function(e){this.active_menu&&!e.composedPath().includes(this.active_menu)&&(c(),this.active_menu=void 0)})),function(){let e=!1;try{const t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("testPassive",null,t),window.removeEventListener("testPassive",null,t)}catch(e){}}();class 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,"flowplayer-audio-menu",FlowplayerMenu)}init(n,o,r){if(!1===n.asel)return;let c=[];const m=a(r,"flowplayer-audio-menu");m instanceof FlowplayerMenu&&m.setMenuAttrs({summaryTitle:r.i18n("audio.button_txt"),menuTitle:r.i18n("audio.menu_title"),class:"fp-asel",options_event:Asel.events.TRACKS,item_selected_event:Asel.events.SWITCH});const f=function(t){const n={tracks:[],events:e};return Object.assign(n,{set:function(s){if(!("number"!=typeof s||s<0||s>n.tracks.length-1))return t.emit(e.SET,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,"flowplayer-control"))||void 0===e||e.append(m)})),r.on(e.TRACKS,(function(e){if(!Array.isArray(e.data)||e.data.length===c.length&&e.data.every((e,t)=>e===c[t]))return;c=e.data,f.tracks=c.slice();const o=t(n,"asel.sort");"function"==typeof o&&f.tracks.sort(o),u(m,Asel.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:s.bind(0,r,n)}}));const a=f.tracks.filter((function(e){return e.enabled}))[0];a&&u(m,Asel.events.SWITCH,{selected_index:f.tracks.indexOf(a)});const d=i(r._storage,f.tracks,t(n,"asel.default_lang",!1));return m instanceof FlowplayerMenu&&m.classList.toggle(l,e.data.length<2),void 0!==d?f.set(d):void 0})),r.on(e.SWITCH,(function(e){const n=t(e,"data.id",-1),s=f.tracks.filter((function(e){return e.id===n}))[0];s&&u(m,Asel.events.SWITCH,{selected_index:f.tracks.indexOf(s)})})),r.audioTracks&&(r.audioTracks.addEventListener("addtrack",(function(){if(r.hls)return;const t=Array.from(r.audioTracks).slice().map(d);r.emit(e.TRACKS,t)})),r.on(e.SET,(function(e){r.hls||Array.from(r.audioTracks).forEach(t=>{var n;t.enabled=(null===(n=e.data)||void 0===n?void 0:n.id)===t.id})})))}}function d(e){return Object.assign({},[{}].concat(["id","kind","enabled","label","language"].map((function(t){const n={};return n["language"===t?"lang":t]=e[t],n}))))}return Asel.events={TRACKS:e.TRACKS,SWITCH:e.SWITCH},function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;"function"==typeof n?n(t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t))}(window,Asel),Asel}));
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";var e={SET:"audio:set",SWITCH:"audio:update",TRACKS:"audio:tracks"};function t(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 n=navigator.languages||[navigator.language];function s(t,n){t.emit(e.SET,n),n.autoselect&&t._storage.setItem("@flowplayer/audio/track",n.lang)}function o(e){return e.toLowerCase()}function i(e,s,i){s=s.slice(0);const a={},r=e.getItem("@flowplayer/audio/track");let l=function(){try{return n.reduce((e,t)=>~t.indexOf("-")?e.concat(t,t.split("-")[0]):e.concat(t),[])}catch(e){return[]}}().map(o),c=-1;if("number"==typeof i)return i;for("string"==typeof i&&(i=i.toLowerCase(),~l.indexOf(i)&&l.splice(l.indexOf(i),1),l.unshift(o(i))),Array.isArray(i)&&(l=i.map(o));s.length;){++c;const e=s.shift();if(null==e?void 0:e.autoselect){if(r==e.lang)return console.debug("restoring lang from previous session: ",r),c;if(e.default&&(a.fallback=[c,e]),e.lang&&~l.indexOf(e.lang.toLowerCase())){const n=l.indexOf(e.lang);if(n<t(a,"by_lang.2",1/0)&&(a.by_lang=[c,e,n]),0===n)break}}}return t(a,"by_lang.0",t(a,"fallback.0",void 0))}const a=(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 o=window.customElements.get(n);return"function"!=typeof o?s:o})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}const r="fp-on",l="fp-invis";class FlowplayerMenu extends FlowplayerComponent{constructor(e){super(e),this.player=e,this.menuContainer=document.createElement("details"),this.summaryEle=document.createElement("summary"),this.olEle=document.createElement("ol"),this.menu=document.createElement("div"),this.closeEle=document.createElement("span"),this.menu.classList.add("fp-menu"),this.menu.append(this.closeEle,this.olEle),this.closeEle.classList.add("fp-close"),this.closeEle.textContent="×",this.menuContainer.append(this.summaryEle,this.menu),this.menuContainer.addEventListener("click",(function(t){t.preventDefault();const n=this.open;n||(c(),document.active_menu=this),this.open=!n,e.root.classList.toggle("has-menu-opened",!n)})),this.append(this.menuContainer)}get options(){return this.olEle.querySelectorAll("li")}setMenuAttrs(e){if(this.className=`${e.class} ${l}`,this.menuContainer.classList.add("fp-menu-container"),this.menuContainer.setAttribute("aria-controls",e.id||Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)),this.menuContainer.setAttribute("aria-label",e.menuTitle||""),e.summaryTitle&&(this.summaryEle.textContent=e.summaryTitle),e.summaryIcon){const t=a(this.player,e.summaryIcon);t.setAttribute("tabindex",""),this.summaryEle.append(t)}if(e.menuTitle){const t=document.createElement("h3");t.textContent=e.menuTitle,this.menu.prepend(t)}this.menu.classList.toggle("fp-icons",!!e.icons),this.addEventListener(e.options_event,e=>{this.render(e.data)}),e.item_selected_event&&this.addEventListener(e.item_selected_event,e=>{void 0!==e.data&&this.select_item(e.data.selected_index)})}render(e){this.olEle&&(this.olEle.innerHTML="",e&&e.forEach(this.menuOption,this),this.classList.toggle(l,!(null==e?void 0:e.length)))}menuOption(e,t){const n=document.createElement("li");n.setAttribute("tabindex","0"),n.setAttribute("role","menuitem"),e.icon&&n.append(e.icon);const s=document.createElement("span");s.textContent=e.text,n.append(s),n.addEventListener("click",()=>{this.select_item(t),"function"==typeof e.onclick&&e.onclick()}),this.olEle.appendChild(n)}select_item(e){this.options.forEach((t,n)=>{t.classList.toggle(r,n===e&&("flowplayer-subtitles-menu"!==this.localName||!t.classList.contains(r)))})}unselect_item(){this.options.forEach(e=>{e.classList.remove(r)})}}function c(){Array.from(document.querySelectorAll(".fp-engine")).forEach(e=>{const t=e.root.querySelector("details[open].fp-menu-container");t&&(t.open=!1,e.root.classList.toggle("has-menu-opened",!1))})}function u(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("click",(function(e){this.active_menu&&!e.composedPath().includes(this.active_menu)&&(c(),this.active_menu=void 0)})),function(){let e=!1;try{const t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("testPassive",null,t),window.removeEventListener("testPassive",null,t)}catch(e){}}();class 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,"flowplayer-audio-menu",FlowplayerMenu)}init(n,o,r){if(!1===n.asel)return;let c=[];const d=a(r,"flowplayer-audio-menu");d instanceof FlowplayerMenu&&d.setMenuAttrs({summaryTitle:r.i18n("audio.button_txt"),menuTitle:r.i18n("audio.menu_title"),class:"fp-asel",options_event:Asel.events.TRACKS,item_selected_event:Asel.events.SWITCH});const m=function(t){const n={tracks:[],events:e};return Object.assign(n,{set:function(s){if(!("number"!=typeof s||s<0||s>n.tracks.length-1))return t.emit(e.SET,n.tracks[s]),n},get:function(e){if("number"==typeof e)return n.tracks[e]}}),n}(r);r.asel=m,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,"flowplayer-control"))||void 0===e||e.append(d)})),r.on(e.TRACKS,(function(e){if(!Array.isArray(e.data)||e.data.length===c.length&&e.data.every((e,t)=>e===c[t]))return;c=e.data,m.tracks=c.slice();const o=t(n,"asel.sort");"function"==typeof o&&m.tracks.sort(o),u(d,Asel.events.TRACKS,Array.from({length:m.tracks.length}).map((e,t)=>{const n=m.tracks[t];return{text:n.name||n.label||n.lang,onclick:s.bind(0,r,n)}}));const a=m.tracks.filter((function(e){return e.enabled}))[0];a&&u(d,Asel.events.SWITCH,{selected_index:m.tracks.indexOf(a)});const f=i(r._storage,m.tracks,t(n,"asel.default_lang",!1));return d instanceof FlowplayerMenu&&d.classList.toggle(l,e.data.length<2),void 0!==f?m.set(f):void 0})),r.on(e.SWITCH,(function(e){const n=t(e,"data.id",-1),s=m.tracks.filter((function(e){return e.id===n}))[0];s&&u(d,Asel.events.SWITCH,{selected_index:m.tracks.indexOf(s)})})),r.audioTracks&&(r.audioTracks.addEventListener("addtrack",(function(){r.hls||r.emit(e.TRACKS,Array.from(r.audioTracks))})),r.on(e.SET,(function(e){r.hls||Array.from(r.audioTracks).forEach((t,n)=>{var s;t.enabled=(null===(s=e.data)||void 0===s?void 0:s.id)===t.id,t.enabled&&u(d,Asel.events.SWITCH,{selected_index:n})})})))}}return Asel.events={TRACKS:e.TRACKS,SWITCH:e.SWITCH},function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;"function"==typeof n?n(t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t))}(window,Asel),Asel}));
@@ -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.endscreen=t())}(this,(function(){"use strict";var e="playlist:ended";class Pipe{constructor(e){this.data=e}static of(e){return new Pipe(e)}static maybe(e,t,...n){return null==e?e:t.apply(e,[e,...n])}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}}function t(e,t){if(!t)throw new Error(e)}function n(e){return"invalid recommendations configuration\ndetails: "+e+"\n\tmust match Object of shape:\n"+["\t\t{ playlist: PlaylistId|Array(MediaId|PlayerConfig)"].join("\n\t\t, ")+"\n\t\t}"}function o(e,o){Pipe.of(e).fmap(n).fmap(t,o)}function i(e){return void 0!==e}function r(e){return"string"==typeof e}function s(e){return"object"==typeof e}function a(e){var t;o("Config must be an Object",i(e)&&s(e)),o("property `playlist` is required",i(null==e?void 0:e.playlist)),o("property `playlist` was not an array nor playlist id",(t=null==e?void 0:e.playlist,o("playlist property was not of type PlaylistId|Array(MediaId|PlayerConfig)",Array.isArray(t)),!(null==t?void 0:t.forEach((function(e,t){o("item at playlist["+t+"] was not valid",r(e)||s(e))})))))}function c(e,t,n){const o=function(e){return Array.isArray(e)?e.slice(0):e.split(".")}(t);for(;o.length;){if(null==e)return n;const t=o.shift();if("string"!=typeof t)return n;e=e[t]}return null==e?n:e}function l(e,t){const n=function(e,t){const n=document.createElement("div");n.classList.add("fp-endscreen-cell-thumbnail"),n.addEventListener("click",d.bind(null,e,t)),e.poster&&(n.style.backgroundImage=["url(",e.poster,")"].join(""));return n}(e,t);return n.append(function(e){const t=document.createElement("div");return t.classList.add("fp-endscreen-cell-title"),t.textContent=e.title||"",t}(e)),n}function d(e,t){"object"==typeof e&&t.setOpts(e),function(e,t,n){if(e.setSrc(r(t)?t:t.src),c(n,"should_play",!1))e.play()}(t,e,{should_play:!0})}function u(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}function p(e,t){const n=e.style;return Object.keys(t).forEach(e=>n[e]=t[e]),e}function f(...e){const t=document.createElement("div");return 0==e.length||t.classList.add(...e),t}function m(e){return t=>{setTimeout((function(){if(!t.defaultPrevented)return e(t)}),0)}}var y;!function(e){e[e.SHUFFLE=1]="SHUFFLE",e[e.FIFO=2]="FIFO",e[e.LOOP=4]="LOOP"}(y||(y={}));const v=(e,t)=>new(((e,t)=>{const n=e.get(t);if(!n)throw new Error(`no flowplayer component with the name ${t} exists`);const o=window.customElements.get(t);if(!o)throw new Error(`no default flowplayer component with the name ${t} exists`);const i=window.customElements.get(n);return"function"!=typeof i?o:i})(e._customElements,t))(e);function h(e,t){if(!t[e])return;const n=document.createElement("span");n.innerText=t[e];const o=f(e);return o.append(n),o}function w(e){return Math.min(100*e,100)+"%"}class Endscreen{init(t,n,o){var i;const r=document.createElement("div");r.classList.add((null===(i=t.endscreen)||void 0===i?void 0:i.interstitial)?"fp-interstitial":"fp-endscreen"),0!=o.reaper&&o.reaper.set("endscreen",r),o.on("mount",(function(){var e;null===(e=u(o,"flowplayer-middle"))||void 0===e||e.append(r)})),o.on("recommendationsready",(function(e){const n=e.data;a(n),r.recommendations=n,!o.ended||o.playlist||t.loop||o.emit("recommendations:render")})),o.on(["ended",e],m((function(e){"ended"==e.type&&o.playlist||r.recommendations&&(t.loop||o.emit("recommendations:render"))}))),o.on(["loadstart","playing"],(function(e){var n;"loadstart"===e.type&&(null===(n=t.endscreen)||void 0===n?void 0:n.interstitial)||o.emit("recommendations:hide")})),o.on("recommendations:hide",m((function(){o.setState("is-endscreen",!1),o.setState("is-interstitial",!1)}))),o.on("recommendations:render",m((function(){var e;(null===(e=t.endscreen)||void 0===e?void 0:e.interstitial)?function(e,t,n){var o,i;if(!(null===(o=t.recommendations)||void 0===o?void 0:o.playlist.length))return;if(n.hasState("is-interstitial"))return;const r=(e,o=!1)=>{var i;const r=null===(i=t.recommendations)||void 0===i?void 0:i.playlist[e];if(!r)return;const{src:s,title:a}=r;n.setSrc(s),n.setOpts({title:a}),o&&n.on("canplay",()=>n.togglePlay(!0))};r(0);const s={config:{advance:!0,delay:2e9},timer:setTimeout(()=>{n.togglePlay(!0)},2e9)},a=u(n,"flowplayer-middle");n.setState("is-interstitial",!0);const{poster:c,src:l,title:d}=null===(i=t.recommendations)||void 0===i?void 0:i.playlist[0];if(s&&a){const e=function(e,t,n,o){const i=f("left");i.append(v(e,"flowplayer-play-icon")),t.poster&&(i.style.backgroundImage=["url(",t.poster,")"].join(""));const r=f("right"),s=f("up-next"),a=document.createElement("span");a.innerText=e.i18n("playlist.up_next");const c=f("fp-color","countdown");s.append(a,c),r.append(s);const l=h("title",t);l&&r.append(l);const d=h("description",t);if(d&&r.append(d),o.timer){const t=f("cancel");t.onclick=function(e){return o.timer&&clearTimeout(o.timer),o.timer=void 0,e.target.remove(),e.preventDefault(),!1};const n=document.createElement("span");n.innerText=e.i18n("playlist.cancel"),t.append(n),r.append(t)}return[i,r]}(n,{poster:c,src:l,title:d},0,s),o=function(e,t){const n=document.createElement("div");return n.classList.add("bottom"),e.length<2||n.append(...e.slice(1).map((e,n)=>{const o=document.createElement("div");o.style.setProperty("background-image",`url('${e.poster}')`),o.addEventListener("click",e=>{e.stopPropagation(),t(n+1)});const i=document.createElement("p");return i.textContent=e.title||"",o.append(i),o})),n}(t.recommendations.playlist,e=>r(e,!0));t.append(...e.concat(o))}n.once("play",e=>{t.innerHTML="",t.recommendations={playlist:[]}}),s.config.advance&&function(e,t,n){var o;if(!n)throw new Error("no element to animate was passed");const i=null!==(o=t.config.delay)&&void 0!==o?o:0,r=Date.now()+i;let s=Date.now();const a=Math.ceil(1e3/60);!function o(){const c=Date.now();if(c>r||!e.paused)return;if(!t.timer)return p(n,{width:w(0)});requestAnimationFrame(o),c-s<a||(s=c,p(n,{width:w(1-(r-c)/i)}))}()}(n,s,t.querySelector(".countdown"))}(0,r,o):function(e,t,n){t.innerHTML="";const o=t.recommendations;if(!o||0===o.playlist.length)return;const i=e.classList.contains("is-small")||e.classList.contains("is-tiny")?6:12,r=[];if(o.playlist.forEach((function(e){if(r.length!==i&&e.poster&&e.title){const t=document.createElement("div");t.classList.add("fp-endscreen-cell"),t.append(l(e,n)),r.push(t)}})),0===r.length)return;const s=document.createElement("div");s.classList.add("fp-endscreen-cells"),s.append(...r),t.append(s)}(n,r,o),o.setState("is-endscreen",!0)})))}}return Endscreen.events={RECOMMENDATIONS_RENDER:"recommendations:render",RECOMMENDATIONS_READY:"recommendationsready",RECOMMENDATIONS_HIDE:"recommendations:hide"},function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;return"function"==typeof n?(n(t),t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t),t)}(window,Endscreen)}));
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.endscreen=t())}(this,(function(){"use strict";var e="playlist:ended",t="interstitial/end",n="interstitial/cancel",s="interstitial/next_item";function i(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}const r=(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),o=(e,t,n)=>{window.customElements.get(t)||window.customElements.define(t,n),e.customElements.get(t)||e.customElements.set(t,t)};class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}const l=(e,t)=>{const n=document.createElement("span");return n.classList.add(e),n.textContent=t,n};class InterstitialGrid extends FlowplayerComponent{constructor(e){super(e),this.classList.add("interstitial-grid"),this.addEventListener(InterstitialGrid.events.RENDER,t=>{this.prepare_endscreen(t.detail,e)}),e.on("resize",()=>{e.root.classList.contains("is-grid")&&this.items&&this.prepare_endscreen(this.items,e)}),this.previousButton=document.createElement("div"),this.previousButton.classList.add("fp-previous"),this.nextButton=document.createElement("div"),this.nextButton.classList.add("fp-next"),this.previousButton.addEventListener("click",this.navigation_buttons_listener.bind(this,!0)),this.nextButton.addEventListener("click",this.navigation_buttons_listener.bind(this,!1))}calculate_max_cells_number(e,t){const n=this.parentElement;if(!n)return;const s=window.getComputedStyle(n).padding,i=t.clientWidth-2*parseFloat(s),r=t.clientHeight-2*parseFloat(s);let o=e,l=0,d=0,a=0,c=0;e:for(;o>0;o-=1){if(1===o){l=i,d=Math.min(r,Math.max(l/1.5,l/1.8)),a=c=1;break}let e=1;for(;e<=o;e++){const t=Number.isInteger(o/e)?o/e:parseInt((o/e).toString())+1,n=i/e;let s=1.5;for(;s<=1.8;s+=.1){const i=n/s;if(i>=64&&i*t<=r&&n>=115){l=n,d=i,a=e,c=t;break e}}}}return this.style.setProperty("grid-template-columns",`repeat(${a}, ${l}px)`),this.style.setProperty("grid-template-rows",`repeat(${c}, ${d}px)`),o}prepare_endscreen(e,t){this.items=e,this.rendered_items=this.items.slice(0,this.calculate_max_cells_number(this.items.length,t)),this.populate_cells(this.rendered_items),this.hide_navigation_buttons(this.items.every((e,t)=>{var n;return e===(null===(n=this.rendered_items)||void 0===n?void 0:n[t])}))}populate_cells(e){this.innerHTML="",e.forEach(e=>{var t,n;const s=document.createElement("div");s.classList.add("grid-item"),e.poster&&(s.style.backgroundImage=`url(${e.poster})`);const i=document.createElement("div");i.classList.add("overlay");const r=l("title",null!==(t=e.title)&&void 0!==t?t:""),o=l("description",null!==(n=e.description)&&void 0!==n?n:"");i.append(r,o),s.append(i),s.addEventListener("click",()=>{const t=new CustomEvent(InterstitialGrid.events.SELECTION,{detail:e});this.dispatchEvent(t)}),this.append(s)})}hide_navigation_buttons(e){[this.previousButton,this.nextButton].forEach(t=>t.style.setProperty("display",e?"none":"block"))}connectedCallback(){var e;this.isConnected&&(null===(e=this.parentElement)||void 0===e||e.append(this.previousButton,this.nextButton))}navigation_buttons_listener(e){if(!this.rendered_items)return;const t=[];this.rendered_items.forEach(n=>{if(!this.items)return;const s=this.items.indexOf(n);if(void 0===s||-1===s)return;const i=this.calculate_index(e,s);void 0!==i&&t.push(this.items[i])}),this.rendered_items=t,this.populate_cells(this.rendered_items)}calculate_index(e,t){if(!this.items||!this.rendered_items)return;const n=this.items.length,s=this.rendered_items.length;let i=e?t-s:t+s;return i<0&&e&&(i=n+i),i>n-1&&!e&&(i-=n),i}}InterstitialGrid.events={SELECTION:"interstitial/grid/selection",RENDER:"interstitial/grid/render"};const d=["title","delay","description","poster","src"];class UpNext extends FlowplayerComponent{static get observedAttributes(){return d}constructor(e){super(e),this.classList.add("up-next"),this.addEventListener("animationend",()=>{this.dispatchEvent(new CustomEvent(t))}),this.addEventListener("animationcancel",()=>{this.classList.add("cancelled"),this.dispatchEvent(new CustomEvent(n))}),this.addEventListener(s,this._setUpNext.bind(this))}getTitle(){return this.getAttribute("title")||""}getDescription(){return this.getAttribute("description")||""}getPoster(){return this.getAttribute("poster")||""}getDelay(){return this.getAttribute("delay")||""}connectedCallback(){this.isConnected&&this._render()}attributeChangedCallback(){this._render()}_render(){var e,n;this.innerHTML="",this.classList.remove("cancelled");const s=document.createDocumentFragment(),i=document.createElement("div");i.classList.add("pane","left");const r=document.createElement("div");r.classList.add("pane","right"),s.append(i,r);const o=document.createElement("div");o.classList.add("poster"),o.style.backgroundImage="url("+this.getPoster()+")",i.append(o),o.addEventListener("click",()=>this.dispatchEvent(new CustomEvent(t)));const l=document.createElement("span");l.classList.add("fp-icon","fp-play"),o.append(l);const d=document.createElement("span");d.classList.add("title"),d.textContent=this.getTitle();const a=document.createElement("span");a.classList.add("description"),a.textContent=this.getDescription();const c=document.createElement("span");c.classList.add("countdown"),this.getDelay()&&(c.style.setProperty("--up-next-delay",this.getDelay()+"s"),c.classList.add("go"));const p=document.createElement("span");p.classList.add("cancel"),p.textContent=null!==(n=null===(e=this.player)||void 0===e?void 0:e.i18n("playlist.cancel"))&&void 0!==n?n:"cancel",p.addEventListener("click",()=>c.classList.remove("go")),r.append(d,a,p,c),this.append(s)}_setUpNext(e){var t,n,s;const i=e.detail.next,r=this.player.opt("playlist.delay",void 0)||10;this.setAttribute("title",null!==(t=i.title)&&void 0!==t?t:""),this.setAttribute("description",null!==(n=i.description)&&void 0!==n?n:""),this.setAttribute("poster",null!==(s=i.poster)&&void 0!==s?s:""),this.setAttribute("delay",r+"")}}function a(e,t){const n=function(){try{return localStorage.getItem("flowplayer/debug")}catch(e){return""}}(),s=(s,...i)=>{const r=(null==t?void 0:t.debug)||n;r&&e.match(r)&&console.log(`${e} -- ${s}`,...i)};return s.log=s,s}function c(e,t,n){const s=function(e,t){const n=new CustomEvent(e,{detail:t,cancelable:!0});return t&&Object.defineProperty(n,"data",{get:()=>t}),n}(t,n);return e.dispatchEvent(s),e}!function(){let e=!1;try{const t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("testPassive",null,t),window.removeEventListener("testPassive",null,t)}catch(e){}}();class EndscreenInterstitial extends FlowplayerComponent{constructor(e){super(e),this.className="fp-endscreen",this.upNextEle=r(e,"flowplayer-endscreen-up-next"),this.gridEle=r(e,"flowplayer-endscreen-grid"),this.append(this.upNextEle,this.gridEle),this.addEventListener("recommendations:render",this.on_recommendations_render.bind(this)),this.upNextEle.addEventListener(n,this.on_next_cancel.bind(this)),this.upNextEle.addEventListener(t,this.on_next_end.bind(this)),this.gridEle.addEventListener(InterstitialGrid.events.SELECTION,this.on_grid_selection.bind(this))}on_recommendations_render(e){const t=e.detail;if(this.playlist=t.playlist,this.on_item_selected=t.on_item_selected,this.player.playlist)return this.gridEle.dispatchEvent(new CustomEvent(InterstitialGrid.events.RENDER,{detail:this.playlist})),this.player.root.classList.add("is-grid");this.player.root.classList.add("is-up-next"),c(this.upNextEle,s,{next:this._nextVideo(this.playlist)})}on_next_cancel(){this.player.root.classList.contains("is-endscreen")&&this.playlist&&(this.gridEle.dispatchEvent(new CustomEvent(InterstitialGrid.events.RENDER,{detail:this.playlist})),this.player.root.classList.remove("is-up-next"),this.player.root.classList.add("is-grid"))}on_next_end(){if(!this.playlist||!this.on_item_selected)return;const e=this.current_video=this._nextVideo(this.playlist);this.on_item_selected(e)}on_grid_selection(e){this.on_item_selected&&this.on_item_selected(e.detail),this.current_video=e.detail,this.gridEle.hide_navigation_buttons(!0)}_nextVideo(e){if(!this.current_video)return e[0];const t=e.indexOf(this.current_video);return[-1,e.length-1].includes(t)?e[0]:e[t+1]}}class Endscreen{constructor(e,t){this.logger=a("flowplayer/endscreen"),o(e,"flowplayer-endscreen-interstitial",EndscreenInterstitial),o(e,"flowplayer-endscreen-up-next",class extends UpNext{}),o(e,"flowplayer-endscreen-grid",class extends InterstitialGrid{})}init(t,n,s){const o=r(s,"flowplayer-endscreen-interstitial");var l;s.on("mount",()=>{var e;return null===(e=i(s,"flowplayer-ui"))||void 0===e?void 0:e.prepend(o)}),s.on("recommendationsready",e=>{const t=e.detail;this.recommendations=t,this.logger.log(`loaded ${t.playlist.length} recommendations`)}),s.on(["ended",e],(l=e=>{var i;this.recommendations&&(e.prevented_from_ads||t.loop||(null===(i=null==t?void 0:t.playlist)||void 0===i?void 0:i.loop)||"ended"==e.type&&s.playlist||(c(o,"recommendations:render",{playlist:this.recommendations.playlist.slice(0,12),on_item_selected:this._setSrc.bind(this,s)}),n.classList.add("is-endscreen")))},e=>{setTimeout((function(){if(!e.defaultPrevented)return l(e)}),0)})),s.on(["seeking","loadstart","playing"],()=>{s.root.classList.contains("is-endscreen")&&this.hide_recommendations(s)})}_setSrc(e,t){var n;if(this.hide_recommendations(e),e.playlist)return e.playlist.push(t),null===(n=e.playlist)||void 0===n?void 0:n.next();e.setSrc(t.src),e.setOpts({title:t.title}),e.once("canplay",()=>e.togglePlay(!0))}hide_recommendations(e){e.root.classList.remove("is-endscreen","is-grid","is-up-next");const t=i(e,"flowplayer-endscreen-interstitial");t&&c(t,"recommendations:hide")}}return Endscreen.events={RECOMMENDATIONS_RENDER:"recommendations:render",RECOMMENDATIONS_READY:"recommendationsready",RECOMMENDATIONS_HIDE:"recommendations:hide"},function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;return"function"==typeof n?(n(t),t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t),t)}(window,Endscreen)}));
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.float_on_scroll=t())}(this,(function(){"use strict";const e="float:pop:in";var t=Object.freeze({__proto__:null,POP_IN:e,POP_OUT:"float:pop:out"});const o=(e,t)=>new(((e,t)=>{const o=e.get(t);if(!o)throw new Error(`no flowplayer component with the name ${t} exists`);const n=window.customElements.get(t);if(!n)throw new Error(`no default flowplayer component with the name ${t} exists`);const l=window.customElements.get(o);return"function"!=typeof l?n:l})(e._customElements,t))(e),n=(e,t,o)=>{window.customElements.get(t)||window.customElements.define(t,o),e.customElements.get(t)||e.customElements.set(t,t)};function l(e){return function(e){const t=e.getBoundingClientRect(),o=window.innerHeight,n=t.y;return n>o||n+t.height<0?0:t.y<0?(t.height+n)/t.height:o-t.y>t.height?1:Math.abs((o-t.y)/t.height)}(e)>.8}function s(t,o,n){0!=n.reaper&&n.floating&&r(n,o,e)}function r(t,o,n){n&&t.emit(n),setTimeout((function(){const l=o.querySelector(".fp-float-wrapper"),s=o.querySelector(".fp-ratio");if(!l||!s)return;l.style.height=n===e?"auto":l.clientWidth*parseFloat(s.style.paddingTop)/100+"px";const r=l.querySelector(".fp-ad-container > div");r&&(r.style.position=n==e?"absolute":"static"),t.emit("resize")}))}class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}class FlowplayerIcon extends FlowplayerComponent{constructor(e,t){super(e),this.classList.add("fp-icon",t.name),t.title&&this.setAttribute("title",t.title),t.title&&this.setAttribute("aria-label",t.title),this.setAttribute("tabindex","0"),this.setAttribute("focusable","true")}}const i={translation_key:"core.mute",name:"fp-mute"},a={translation_key:"core.mute",name:"fp-unmute"},c={translation_key:"core.close",name:"fp-close"};class FloatOnScroll{constructor(e){this.flowplayer=e,n(this.flowplayer,"flowplayer-mute-icon",class extends FlowplayerIcon{constructor(e){super(e,i)}}),n(this.flowplayer,"flowplayer-unmute-icon",class extends FlowplayerIcon{constructor(e){super(e,a)}}),n(this.flowplayer,"flowplayer-close-icon",class extends FlowplayerIcon{constructor(e){super(e,c)}})}init(t,n,i){var a;if(t.multiplay||!1===t.float_on_scroll)return;if(function(){try{return window.self!==window.top}catch(e){return!0}}())return console.warn("iframe detected - floating player not supported in iframe");t.float_on_scroll="object"!=typeof t.float_on_scroll?{}:t.float_on_scroll,t.autopause&&i.setOpts({autopause:!1});const c={pop_out_container:(null===(a=t.float_on_scroll)||void 0===a?void 0:a.container)||function(e,t){const o=document.createElement("div");return o.classList.add("fp-float-wrapper"),e.appendChild(o),Array.from(e.childNodes).forEach((function(e){e instanceof Element&&(e===o||e.classList.contains("fp-ratio"))||o.appendChild(e)})),setTimeout(()=>{const t=e.querySelector("flowplayer-ad-ui");t&&o.appendChild(t)},0),t.getFullsceenTarget=()=>o,o}(n,i),was_user_toggled:!1};i.on("renderplugin",(function(e){e.preventDefault(),e.detail&&c.pop_out_container.append(e.detail)}));const u=function(e,t){const o=e._customElements.get(t);return o&&e.root.querySelector(o)||void 0}(i,"flowplayer-header");u&&function(e,t,n,l){const r=document.createElement("div");r.classList.add("fp-exit-float"),r.append(Object.assign(o(l,"flowplayer-close-icon"),{role:"button"}));const i=()=>{t.was_user_toggled=!0,l.togglePlay(!1),s(0,n,l)};r.addEventListener("click",i),e.append(r),setTimeout(()=>{const e=n.querySelector(".fp-ad-controls");if(!e)return;const t=r.cloneNode(!0);e.append(t),t.addEventListener("click",i)},0);const a=document.createElement("div");a.classList.add("fp-mute-float"),a.append(...Object.assign([o(l,"flowplayer-mute-icon"),o(l,"flowplayer-unmute-icon")],{role:"button"})),a.addEventListener("click",(function(){l.toggleMute()})),e.append(a)}(u,c,n,i);const p=function(e,t){const o=e||60,n=Math.ceil(1e3/o);let l=Date.now(),s=-1;return function(...e){return s>-1||Date.now()<l||(s=requestAnimationFrame((function(){s=-1,t(),l=Date.now()+n}))),s}}(0,(function(){if(l(n)){if(i.hasState("is-fullscreen"))return;s(0,n,i)}})),f=function(){r(i,n)};i.on("viewleave",()=>{(function(e){return!e.paused||!(!e.ads||!e.ads.adPlaying)})(i)&&!c.was_user_toggled&&function(e,t,o){0==o.reaper||o.floating||r(o,t,"float:pop:out")}(0,n,i)}),i.on("viewenter",(function(){c.was_user_toggled=!1})),i.on("float:pop:out",(function(){window.addEventListener("scroll",p),i.floating=!0,i.setState("is-popped-out",!0),window.addEventListener("resize",f)})),i.on(e,(function(){window.removeEventListener("scroll",p),i.floating=!1,i.setState("is-popped-out",!1),window.removeEventListener("resize",f)}))}}return FloatOnScroll.events=t,function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const o=e.flowplayer;return"function"==typeof o?(o(t),t):(Array.isArray(o.extensions)||(o.extensions=[]),~o.extensions.indexOf(t)||o.extensions.push(t),t)}(window,FloatOnScroll)}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.float_on_scroll=t())}(this,(function(){"use strict";const e="float:pop:in";var t=Object.freeze({__proto__:null,POP_IN:e,POP_OUT:"float:pop:out"});const o=(e,t)=>new(((e,t)=>{const o=e.get(t);if(!o)throw new Error(`no flowplayer component with the name ${t} exists`);const n=window.customElements.get(t);if(!n)throw new Error(`no default flowplayer component with the name ${t} exists`);const l=window.customElements.get(o);return"function"!=typeof l?n:l})(e._customElements,t))(e),n=(e,t,o)=>{window.customElements.get(t)||window.customElements.define(t,o),e.customElements.get(t)||e.customElements.set(t,t)};function l(e){return function(e){const t=e.getBoundingClientRect(),o=window.innerHeight,n=t.y;return n>o||n+t.height<0?0:t.y<0?(t.height+n)/t.height:o-t.y>t.height?1:Math.abs((o-t.y)/t.height)}(e)>.8}function s(t,o,n){0!=n.reaper&&n.floating&&i(n,o,e)}function i(t,o,n){n&&t.emit(n),setTimeout((function(){const l=o.querySelector(".fp-float-wrapper"),s=o.clientWidth/o.clientHeight;if(!l)return;l.style.height=n===e?"auto":l.clientWidth/s+"px";const i=l.querySelector(".fp-ad-container > div");i&&(i.style.position=n==e?"absolute":"static"),t.emit("resize")}))}class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}class FlowplayerIcon extends FlowplayerComponent{constructor(e,t){super(e),this.classList.add("fp-icon",t.name),t.title&&this.setAttribute("title",t.title),t.title&&this.setAttribute("aria-label",t.title),this.setAttribute("tabindex","0"),this.setAttribute("focusable","true")}}const r={translation_key:"core.mute",name:"fp-mute"},a={translation_key:"core.mute",name:"fp-unmute"},c={translation_key:"core.close",name:"fp-close"};class FloatOnScroll{constructor(e){this.flowplayer=e,n(this.flowplayer,"flowplayer-mute-icon",class extends FlowplayerIcon{constructor(e){super(e,r)}}),n(this.flowplayer,"flowplayer-unmute-icon",class extends FlowplayerIcon{constructor(e){super(e,a)}}),n(this.flowplayer,"flowplayer-close-icon",class extends FlowplayerIcon{constructor(e){super(e,c)}})}init(t,n,r){var a;if(t.multiplay||!1===t.float_on_scroll)return;if(function(){try{return window.self!==window.top}catch(e){return!0}}())return console.warn("iframe detected - floating player not supported in iframe");t.float_on_scroll="object"!=typeof t.float_on_scroll?{}:t.float_on_scroll,t.autopause&&r.setOpts({autopause:!1});const c={pop_out_container:(null===(a=t.float_on_scroll)||void 0===a?void 0:a.container)||function(e,t){const o=document.createElement("div");return o.classList.add("fp-float-wrapper"),e.appendChild(o),Array.from(e.childNodes).forEach((function(e){e instanceof Element&&(e===o||e.classList.contains("fp-ratio"))||o.appendChild(e)})),setTimeout(()=>{const t=e.querySelector("flowplayer-ad-ui");t&&o.appendChild(t)},0),t.getFullsceenTarget=()=>o,o}(n,r),was_user_toggled:!1};r.on("renderplugin",(function(e){e.preventDefault(),e.detail&&c.pop_out_container.append(e.detail)}));const u=function(e,t){const o=e._customElements.get(t);return o&&e.root.querySelector(o)||void 0}(r,"flowplayer-header");u&&function(e,t,n,l){const i=document.createElement("div");i.classList.add("fp-exit-float"),i.append(Object.assign(o(l,"flowplayer-close-icon"),{role:"button"}));const r=()=>{t.was_user_toggled=!0,l.togglePlay(!1),s(0,n,l)};i.addEventListener("click",r),e.append(i),setTimeout(()=>{const e=n.querySelector(".fp-ad-controls");if(!e)return;const t=i.cloneNode(!0);e.append(t),t.addEventListener("click",r)},0);const a=document.createElement("div");a.classList.add("fp-mute-float"),a.append(...Object.assign([o(l,"flowplayer-mute-icon"),o(l,"flowplayer-unmute-icon")],{role:"button"})),a.addEventListener("click",(function(){l.toggleMute()})),e.append(a)}(u,c,n,r);const f=function(e,t){const o=e||60,n=Math.ceil(1e3/o);let l=Date.now(),s=-1;return function(...e){return s>-1||Date.now()<l||(s=requestAnimationFrame((function(){s=-1,t(),l=Date.now()+n}))),s}}(0,(function(){if(l(n)){if(r.hasState("is-fullscreen"))return;s(0,n,r)}})),p=function(){i(r,n)};r.on("viewleave",()=>{(function(e){return!e.paused||!(!e.ads||!e.ads.adPlaying)})(r)&&!c.was_user_toggled&&function(e,t,o){0==o.reaper||o.floating||i(o,t,"float:pop:out")}(0,n,r)}),r.on("viewenter",(function(){c.was_user_toggled=!1})),r.on("float:pop:out",(function(){window.addEventListener("scroll",f),r.floating=!0,r.setState("is-popped-out",!0),window.addEventListener("resize",p)})),r.on(e,(function(){window.removeEventListener("scroll",f),r.floating=!1,r.setState("is-popped-out",!1),window.removeEventListener("resize",p)}))}}return FloatOnScroll.events=t,function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const o=e.flowplayer;return"function"==typeof o?(o(t),t):(Array.isArray(o.extensions)||(o.extensions=[]),~o.extensions.indexOf(t)||o.extensions.push(t),t)}(window,FloatOnScroll)}));
package/plugins/gemius.js CHANGED
@@ -1 +1 @@
1
- !function(i,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((i="undefined"!=typeof globalThis?globalThis:i||self).flowplayer=i.flowplayer||{},i.flowplayer.gemius=e())}(this,(function(){"use strict";function i(i,e,t){const r=function(i){return Array.isArray(i)?i.slice(0):i.split(".")}(e);for(;r.length;){if(null==i)return t;const e=r.shift();if("string"!=typeof e)return t;i=i[e]}return null==i?t:i}const e=["playerID","gemiusID"],t=["programID","additionalParameters.programName","additionalParameters.programType","additionalParameters.programDuration"],r=["adName","adDuration","adType","campaignClassification","quality","resolution","volume"];function s(e,t){const r=[];return t.forEach((function(t){void 0===i(e,t)&&r.push(t)})),r.length&&console.warn("Missing Gemius configuration: ",r.join(", ")),0===r.length}function a(i){return i<.5||isNaN(i)?0:Math.round(i)}function n(i,e){return-1===i||e?-1:Math.max(0,Math.min(100,Math.round(100*i)))}return function(i,e){if("object"==typeof exports&&"undefined"!=typeof module)return e;"flowplayer"in i||(i.flowplayer={extensions:[]});const t=i.flowplayer;return"function"==typeof t?(t(e),e):(Array.isArray(t.extensions)||(t.extensions=[]),~t.extensions.indexOf(e)||t.extensions.push(e),e)}(window,class GemiusPlugin{constructor(i){this.started=!1,this.starting=!1,this.paused=!1,this.seeking=!1,this.buffering=!1,this.currentTime=0,this.flowplayer=i}init(i,e,t){if("function"!=typeof GemiusPlayer)return console.warn("Gemius SDK needs to be loaded prior loading gemius plugin");if(!i.gemius)return console.warn("Gemius plugin loaded but not configured");if(!t.hasState("consent-no-tracking")&&(this.gemius=i.gemius,t.on("reap",()=>{this.gemiusPlayer&&this.gemius&&this.gemius.programID&&this.gemiusPlayer.programEvent(this.gemius.programID,a(t.currentTime),"stop"),this.gemiusPlayer=void 0,this.resetParams(),window.removeEventListener("beforeunload",this.handle_window_unload.bind(this,t))}),window.addEventListener("beforeunload",this.handle_window_unload.bind(this,t)),t.on(["config","loadedmetadata","src","loadstart"],e=>{var r,s;(null===(r=e.data)||void 0===r?void 0:r.gemius)&&(this.gemius=Object.assign(Object.assign({},this.gemius),null===(s=e.data)||void 0===s?void 0:s.gemius)),e.type===this.getInitEventType(i)&&this.initGemius(i,t)}),t.on("volumechange",()=>{var i;this.gemiusPlayer&&(null===(i=this.gemius)||void 0===i?void 0:i.programID)&&this.gemiusPlayer.programEvent(this.gemius.programID,a(t.currentTime),"chngVol",{volume:n(t.volume,t.muted)})}),t.on("resize",()=>{var i;this.gemiusPlayer&&(null===(i=this.gemius)||void 0===i?void 0:i.programID)&&(this.sendPlayWithRequiremets(t),this.gemiusPlayer.programEvent(this.gemius.programID,a(t.currentTime),"chngRes",{resolution:t.clientWidth+"x"+t.clientHeight}))}),t.on("play",()=>{this.buffering=!1,this.starting=!0,this.started?this.sendPlay(t):this.sendPlayWithRequiremets(t),this.paused=!1}),t.on("ended",()=>{var i;this.started&&(this.resetParams(),this.gemiusPlayer&&(null===(i=this.gemius)||void 0===i?void 0:i.programID)&&this.gemiusPlayer.programEvent(this.gemius.programID,a(t.currentTime),"complete"))}),t.on("seeking",()=>{var i;this.started&&!this.seeking&&(this.seeking=!0,this.gemiusPlayer&&(null===(i=this.gemius)||void 0===i?void 0:i.programID)&&this.gemiusPlayer.programEvent(this.gemius.programID,this.currentTime,"seek"))}),t.on("seeked",()=>{var i;this.started&&!this.paused&&(this.seeking=!1,this.gemiusPlayer&&(null===(i=this.gemius)||void 0===i?void 0:i.programID)&&this.gemiusPlayer.programEvent(this.gemius.programID,a(t.currentTime),"play",{autoPlay:this.gemius.additionalParameters.autoPlay,volume:n(this.gemius.additionalParameters.volume||0)||0}))}),t.on("pause",()=>{var e;this.started&&t.currentTime>.25&&(i.live||i.duration&&i.duration-t.currentTime>.25)&&(this.paused=!0,this.gemiusPlayer&&(null===(e=this.gemius)||void 0===e?void 0:e.programID)&&this.gemiusPlayer.programEvent(this.gemius.programID,a(t.currentTime),"pause"))}),t.on("waiting",()=>{var i;!this.buffering&&t.currentTime>.5&&(this.buffering=!0,this.gemiusPlayer&&(null===(i=this.gemius)||void 0===i?void 0:i.programID)&&this.gemiusPlayer.programEvent(this.gemius.programID,a(t.currentTime),"buffer"))}),t.on("timeupdate",()=>{this.currentTime=Math.round(t.currentTime)}),t.ads)){const i=this.flowplayer.AdEvents;t.ads.on(i.AD_STARTED,i=>{var e,t,s;(this.paused=!1,this.currentAd={id:i.vast_ad_id||"unknown id",duration:(null===(e=i.ad)||void 0===e?void 0:e.duration)||-1,currentTime:0},this.gemiusPlayer&&(null===(t=this.gemius)||void 0===t?void 0:t.programID))&&(this.gemiusPlayer.newAd(i.vast_ad_id,(s=Object.assign({},this.gemius.additionalParameters,function(i){var e,t,r;return{adDuration:null===(e=i.ad)||void 0===e?void 0:e.duration,adType:i.ad_type,resolution:(null===(t=i.ad)||void 0===t?void 0:t.width)+"x"+(null===(r=i.ad)||void 0===r?void 0:r.height),volume:n(i.volume)}}(i)),r.reduce((function(i,e){return s&&s.hasOwnProperty(e)&&(i[e]=s[e]),i}),{}))),this.gemiusPlayer.adEvent(this.gemius.programID,this.currentAd.id,0,"play",{autoPlay:this.gemius.additionalParameters.autoPlay,volume:n(i.volume)}))}),t.ads.on(i.AD_PAUSED,()=>{var i;this.paused=!0,this.currentAd&&this.gemiusPlayer&&(null===(i=this.gemius)||void 0===i?void 0:i.programID)&&this.gemiusPlayer.adEvent(this.gemius.programID,this.currentAd.id,this.currentAd.currentTime,"pause")}),t.ads.on(i.AD_RESUMED,i=>{var e;if(this.currentAd&&this.paused){if(this.paused=!1,!this.gemiusPlayer||!(null===(e=this.gemius)||void 0===e?void 0:e.programID))return;this.gemiusPlayer.adEvent(this.gemius.programID,this.currentAd.id,this.currentAd.currentTime,"play",{autoPlay:this.gemius.additionalParameters.autoPlay,volume:n(i.volume)})}}),t.ads.on(i.AD_COMPLETED,()=>{var i;if(this.currentAd){if(!this.gemiusPlayer||!(null===(i=this.gemius)||void 0===i?void 0:i.programID))return;this.gemiusPlayer.adEvent(this.gemius.programID,this.currentAd.id,this.currentAd.duration,"complete"),this.currentAd=void 0}}),t.ads.on(i.AD_PROGRESS,i=>{this.currentAd&&(this.currentAd.currentTime=Math.round(i.duration-i.remaining)||0)}),t.ads.on(i.AD_VOLUME_CHANGED,i=>{var e;if(this.currentAd){const t=i||-1;if(!this.gemiusPlayer||!(null===(e=this.gemius)||void 0===e?void 0:e.programID))return;this.gemiusPlayer.adEvent(this.gemius.programID,this.currentAd.id,this.currentAd.duration,"chngVol",{volume:n(t)})}})}}resetParams(){this.seeking=!1,this.starting=!1,this.started=!1,this.paused=!1,this.buffering=!1,this.currentAd=void 0,this.currentTime=0}sendPlay(i){var e;this.gemiusPlayer&&(null===(e=this.gemius)||void 0===e?void 0:e.programID)&&(this.started=!0,this.gemiusPlayer.programEvent(this.gemius.programID,a(i.currentTime),"play",{autoPlay:this.gemius.additionalParameters.autoPlay,volume:n(this.gemius.additionalParameters.volume||0)}))}sendPlayWithRequiremets(i){this.starting&&!this.started&&i.videoWidth>0&&this.sendPlay(i)}getInitEventType(i){return!i.ima&&i.autoplay?"src":"loadstart"}initGemius(r,a){if(!s(i(r,"gemius",{}),e))return;if(!this.gemius)return;const u={currentDomain:this.gemius.additionalParameters.currentDomain,volume:n(this.gemius.additionalParameters.volume||0)};if(this.gemiusPlayer&&(this.gemiusPlayer=void 0),this.gemiusPlayer=new GemiusPlayer(this.gemius.playerID,this.gemius.gemiusID,u),this.gemiusPlayer.setVideoObject(a),!s(this.gemius,t))return;const o={programName:this.gemius.additionalParameters.programName,programDuration:this.gemius.additionalParameters.programDuration,programType:this.gemius.additionalParameters.programType,volume:n(this.gemius.additionalParameters.volume||0)};this.gemiusPlayer.newProgram(this.gemius.programID,o),this.sendPlayWithRequiremets(a)}handle_window_unload(i){var e;this.gemiusPlayer&&(null===(e=this.gemius)||void 0===e?void 0:e.programID)&&this.gemiusPlayer.programEvent(this.gemius.programID,a(i.currentTime),"close"),this.resetParams()}})}));
1
+ !function(i,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((i="undefined"!=typeof globalThis?globalThis:i||self).flowplayer=i.flowplayer||{},i.flowplayer.gemius=e())}(this,(function(){"use strict";function i(i,e,t){const r=function(i){return Array.isArray(i)?i.slice(0):i.split(".")}(e);for(;r.length;){if(null==i)return t;const e=r.shift();if("string"!=typeof e)return t;i=i[e]}return null==i?t:i}const e=["playerID","gemiusID"],t=["programID","additionalParameters.programName","additionalParameters.programType","additionalParameters.programDuration"],r=["adName","adDuration","adType","campaignClassification","quality","resolution","volume"];function s(e,t){const r=[];return t.forEach((function(t){void 0===i(e,t)&&r.push(t)})),r.length&&console.warn("Missing Gemius configuration: ",r.join(", ")),0===r.length}function a(i){return i<.5||isNaN(i)?0:Math.round(i)}function n(i,e){return-1===i||e?-1:Math.max(0,Math.min(100,Math.round(100*i)))}return function(i,e){if("object"==typeof exports&&"undefined"!=typeof module)return e;"flowplayer"in i||(i.flowplayer={extensions:[]});const t=i.flowplayer;return"function"==typeof t?(t(e),e):(Array.isArray(t.extensions)||(t.extensions=[]),~t.extensions.indexOf(e)||t.extensions.push(e),e)}(window,class GemiusPlugin{constructor(i){this.started=!1,this.starting=!1,this.paused=!1,this.seeking=!1,this.buffering=!1,this.currentTime=0,this.flowplayer=i}init(i,e,t){if("function"!=typeof GemiusPlayer)return console.warn("Gemius SDK needs to be loaded prior loading gemius plugin");if(!i.gemius)return console.warn("Gemius plugin loaded but not configured");if(!t.hasState("consent-no-tracking")&&(this.gemius=i.gemius,t.on("reap",()=>{this.gemiusPlayer&&this.gemius&&this.gemius.programID&&this.gemiusPlayer.programEvent(this.gemius.programID,a(t.currentTime),"stop"),this.gemiusPlayer=void 0,this.resetParams(),window.removeEventListener("beforeunload",this.handle_window_unload.bind(this,t))}),window.addEventListener("beforeunload",this.handle_window_unload.bind(this,t)),t.on(["config","loadedmetadata","src","loadstart"],e=>{var r,s;(null===(r=e.data)||void 0===r?void 0:r.gemius)&&(this.gemius=Object.assign(Object.assign({},this.gemius),null===(s=e.data)||void 0===s?void 0:s.gemius)),e.type===this.getInitEventType(i)&&this.initGemius(i,t)}),t.on("volumechange",()=>{var i;this.gemiusPlayer&&(null===(i=this.gemius)||void 0===i?void 0:i.programID)&&this.gemiusPlayer.programEvent(this.gemius.programID,a(t.currentTime),"chngVol",{volume:n(t.volume,t.muted)})}),t.on("resize",()=>{var i;this.gemiusPlayer&&(null===(i=this.gemius)||void 0===i?void 0:i.programID)&&(this.sendPlayWithRequiremets(t),this.gemiusPlayer.programEvent(this.gemius.programID,a(t.currentTime),"chngRes",{resolution:t.clientWidth+"x"+t.clientHeight}))}),t.on("play",()=>{this.buffering=!1,this.starting=!0,this.started?this.sendPlay(t):this.sendPlayWithRequiremets(t),this.paused=!1}),t.on("ended",()=>{var i;this.started&&(this.resetParams(),this.gemiusPlayer&&(null===(i=this.gemius)||void 0===i?void 0:i.programID)&&this.gemiusPlayer.programEvent(this.gemius.programID,a(t.currentTime),"complete"))}),t.on("seeking",()=>{var i;this.started&&!this.seeking&&(this.seeking=!0,this.gemiusPlayer&&(null===(i=this.gemius)||void 0===i?void 0:i.programID)&&this.gemiusPlayer.programEvent(this.gemius.programID,this.currentTime,"seek"))}),t.on("seeked",()=>{var i;this.started&&!this.paused&&(this.seeking=!1,this.gemiusPlayer&&(null===(i=this.gemius)||void 0===i?void 0:i.programID)&&this.gemiusPlayer.programEvent(this.gemius.programID,a(t.currentTime),"play",{autoPlay:this.gemius.additionalParameters.autoPlay,volume:n(this.gemius.additionalParameters.volume||0)||0}))}),t.on("pause",()=>{var e;this.started&&t.currentTime>.25&&(i.live||i.duration&&i.duration-t.currentTime>.25)&&(this.paused=!0,this.gemiusPlayer&&(null===(e=this.gemius)||void 0===e?void 0:e.programID)&&this.gemiusPlayer.programEvent(this.gemius.programID,a(t.currentTime),"pause"))}),t.on("waiting",()=>{var i;!this.buffering&&t.currentTime>.5&&(this.buffering=!0,this.gemiusPlayer&&(null===(i=this.gemius)||void 0===i?void 0:i.programID)&&this.gemiusPlayer.programEvent(this.gemius.programID,a(t.currentTime),"buffer"))}),t.on("timeupdate",()=>{this.currentTime=Math.round(t.currentTime)}),this.flowplayer.ads)){const i=this.flowplayer.ads.events;t.ads.on(i.AD_STARTED,i=>{var e,t,s;(this.paused=!1,this.currentAd={id:i.vast_ad_id||"unknown id",duration:(null===(e=i.ad)||void 0===e?void 0:e.duration)||-1,currentTime:0},this.gemiusPlayer&&(null===(t=this.gemius)||void 0===t?void 0:t.programID))&&(this.gemiusPlayer.newAd(i.vast_ad_id,(s=Object.assign({},this.gemius.additionalParameters,function(i){var e,t,r;return{adDuration:null===(e=i.ad)||void 0===e?void 0:e.duration,adType:i.ad_type,resolution:(null===(t=i.ad)||void 0===t?void 0:t.width)+"x"+(null===(r=i.ad)||void 0===r?void 0:r.height),volume:n(i.volume)}}(i)),r.reduce((function(i,e){return s&&s.hasOwnProperty(e)&&(i[e]=s[e]),i}),{}))),this.gemiusPlayer.adEvent(this.gemius.programID,this.currentAd.id,0,"play",{autoPlay:this.gemius.additionalParameters.autoPlay,volume:n(i.volume)}))}),t.ads.on(i.AD_PAUSED,()=>{var i;this.paused=!0,this.currentAd&&this.gemiusPlayer&&(null===(i=this.gemius)||void 0===i?void 0:i.programID)&&this.gemiusPlayer.adEvent(this.gemius.programID,this.currentAd.id,this.currentAd.currentTime,"pause")}),t.ads.on(i.AD_RESUMED,i=>{var e;if(this.currentAd&&this.paused){if(this.paused=!1,!this.gemiusPlayer||!(null===(e=this.gemius)||void 0===e?void 0:e.programID))return;this.gemiusPlayer.adEvent(this.gemius.programID,this.currentAd.id,this.currentAd.currentTime,"play",{autoPlay:this.gemius.additionalParameters.autoPlay,volume:n(i.volume)})}}),t.ads.on(i.AD_COMPLETED,()=>{var i;if(this.currentAd){if(!this.gemiusPlayer||!(null===(i=this.gemius)||void 0===i?void 0:i.programID))return;this.gemiusPlayer.adEvent(this.gemius.programID,this.currentAd.id,this.currentAd.duration,"complete"),this.currentAd=void 0}}),t.ads.on(i.AD_PROGRESS,i=>{this.currentAd&&(this.currentAd.currentTime=Math.round(i.duration-i.remaining)||0)}),t.ads.on(i.AD_VOLUME_CHANGED,i=>{var e;if(this.currentAd){const t=i||-1;if(!this.gemiusPlayer||!(null===(e=this.gemius)||void 0===e?void 0:e.programID))return;this.gemiusPlayer.adEvent(this.gemius.programID,this.currentAd.id,this.currentAd.duration,"chngVol",{volume:n(t)})}})}}resetParams(){this.seeking=!1,this.starting=!1,this.started=!1,this.paused=!1,this.buffering=!1,this.currentAd=void 0,this.currentTime=0}sendPlay(i){var e;this.gemiusPlayer&&(null===(e=this.gemius)||void 0===e?void 0:e.programID)&&(this.started=!0,this.gemiusPlayer.programEvent(this.gemius.programID,a(i.currentTime),"play",{autoPlay:this.gemius.additionalParameters.autoPlay,volume:n(this.gemius.additionalParameters.volume||0)}))}sendPlayWithRequiremets(i){this.starting&&!this.started&&i.videoWidth>0&&this.sendPlay(i)}getInitEventType(i){return!i.ima&&i.autoplay?"src":"loadstart"}initGemius(r,a){if(!s(i(r,"gemius",{}),e))return;if(!this.gemius)return;const u={currentDomain:this.gemius.additionalParameters.currentDomain,volume:n(this.gemius.additionalParameters.volume||0)};if(this.gemiusPlayer&&(this.gemiusPlayer=void 0),this.gemiusPlayer=new GemiusPlayer(this.gemius.playerID,this.gemius.gemiusID,u),this.gemiusPlayer.setVideoObject(a),!s(this.gemius,t))return;const o={programName:this.gemius.additionalParameters.programName,programDuration:this.gemius.additionalParameters.programDuration,programType:this.gemius.additionalParameters.programType,volume:n(this.gemius.additionalParameters.volume||0)};this.gemiusPlayer.newProgram(this.gemius.programID,o),this.sendPlayWithRequiremets(a)}handle_window_unload(i){var e;this.gemiusPlayer&&(null===(e=this.gemius)||void 0===e?void 0:e.programID)&&this.gemiusPlayer.programEvent(this.gemius.programID,a(i.currentTime),"close"),this.resetParams()}})}));
@@ -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.google_analytics=t())}(this,(function(){"use strict";return function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const i=e.flowplayer;return"function"==typeof i?(i(t),t):(Array.isArray(i.extensions)||(i.extensions=[]),~i.extensions.indexOf(t)||i.extensions.push(t),t)}(window,class GoogleAnalyticsPlugin{constructor(e){this.started=!1,this.paused=!1,this.muted=!1,this.once=!0,this.liveflag=!1,this.ga_instances=[],this.ga_extensions=[],this.quartiles=[0,0,0],this.ad_type="preroll",this.preroll_counter=0,this.midroll_counter=0,this.postroll_counter=0,this.event_categories={live:"Live",videos:"Videos"},this.event_actions={fullscreen_enter:"fullscreen_enter",fullscreen_exit:"fullscreen_exit",video_player_load:"video_player_load",video_start:"video_start",video_click_play:"video_click_play",video_pause:"video_pause",video_resume:"video_resume",video_mute:"video_mute",video_unmute:"video_unmute",video_25_percent:"video_25_percent",video_50_percent:"video_50_percent",video_75_percent:"video_75_percent",video_complete:"video_complete",live_start:"live_start",live_click_play:"live_click_play",live_pause:"live_pause",live_resume:"live_resume",live_mute:"live_mute",live_unmute:"live_unmute",live_complete:"live_complete",ad_start_preroll:"ad_start_preroll",ad_start_midroll:"ad_start_midroll",ad_start_postroll:"ad_start_postroll",ad_completed_preroll:"ad_completed_preroll",ad_completed_midroll:"ad_completed_midroll",ad_completed_postroll:"ad_completed_postroll",ad_skipped_preroll:"ad_skipped_preroll",ad_skipped_midroll:"ad_skipped_midroll",ad_skipped_postroll:"ad_skipped_postroll",ad_break_completed:"ad_break_completed"},this.flowplayer=e}init(e,t,i){if(this.config=e,this.video=i,"object"!=typeof e.ga)return;if(i.hasState("consent-no-tracking"))return;const s=this.flowplayer.AdEvents||{AD_STARTED:"ad-started",AD_COMPLETED:"ad-completed",AD_SKIPPED:"ad-skipped",AD_BREAK_COMPLETED:"ad-break-completed"};this.muted=i.muted||!1,this.media_title=e.ga.media_title||"unknown video title",this.ga_instances=e.ga.ga_instances,e.ga.event_actions&&(this.event_actions=e.ga.event_actions),e.ga.event_categories&&(this.event_categories=e.ga.event_categories),i.on(["mount","timeupdate","loadstart","ended","seeked","seeking","pause","playing","volumechange",s.AD_STARTED,s.AD_COMPLETED,s.AD_SKIPPED,s.AD_BREAK_COMPLETED,"config","click","touchend","fullscreenenter","fullscreenexit"],e=>{switch(e.type){case"playing":this.playing(e.type);break;case"pause":this.pause();break;case"mount":this.loaded();break;case"timeupdate":this.progress();break;case"ended":this.ended();break;case"volumechange":this.volumechange();break;case"ad-started":this.adstarted(e);break;case"ad-completed":this.adcompleted(e);break;case"ad-break-completed":this.adbreakcompleted(e.type);break;case"config":this.configured(e);break;case"click":this.click();break;case"fullscreenenter":this.fullscreenenter();break;case"fullscreenexit":this.fullscreenexit();break;case"ad-skipped":this.adskipped()}})}setup_ga(){window.ga&&0===this.ga_extensions.length&&this.ga_instances.forEach((e,t)=>{var i;window.ga("create",e,"auto","ext"+(t+1)),(null===(i=this.config)||void 0===i?void 0:i.ga.custom_data)&&window.ga("ext"+(t+1)+".set",this.config.ga.custom_data),this.ga_extensions.push("ext"+(t+1))})}set_started(e){var t;(null===(t=this.config)||void 0===t?void 0:t.ga.start_on)===e&&(this.liveflag?this.track(this.event_actions.live_start):this.track(this.event_actions.video_start),this.started=!0)}click(){!this.paused&&this.started||(this.liveflag?this.track(this.event_actions.live_click_play):this.track(this.event_actions.video_click_play))}playing(e){this.started?this.paused&&(this.paused=!1,this.liveflag?this.track(this.event_actions.live_resume):this.track(this.event_actions.video_resume)):this.set_started(e)}pause(){this.video&&(Math.abs(this.video.duration-this.video.currentTime)<1||!this.started||(this.paused=!0,this.liveflag?this.track(this.event_actions.live_pause):this.track(this.event_actions.video_pause)))}loaded(){}progress(){!this.liveflag&&this.video&&(this.video.currentTime/this.video.duration>.25&&0===this.quartiles[0]?(this.quartiles[0]=1,this.track(this.event_actions.video_25_percent)):this.video.currentTime/this.video.duration>.5&&0===this.quartiles[1]?(this.quartiles[1]=1,this.track(this.event_actions.video_50_percent)):this.video.currentTime/this.video.duration>.75&&0===this.quartiles[2]&&(this.quartiles[2]=1,this.track(this.event_actions.video_75_percent)))}volumechange(){this.video&&(this.video.muted&&!this.muted?(this.muted=!0,this.liveflag?this.track(this.event_actions.live_mute):this.track(this.event_actions.video_mute)):!this.video.muted&&this.muted&&(this.muted=!1,this.liveflag?this.track(this.event_actions.live_unmute):this.track(this.event_actions.video_unmute)))}ended(){this.started&&(this.liveflag?this.track(this.event_actions.live_complete):this.track(this.event_actions.video_complete)),this.reset()}reset(){this.started=!1,this.quartiles=[0,0,0],this.once=!0,this.config&&(this.config.ga.start_on="playing"),this.preroll_counter=0,this.midroll_counter=0,this.postroll_counter=0}configured(e){this.config&&this.video&&(e.data&&(e.data.live&&(this.liveflag=!0),e.data.title?this.media_title=e.data.title:e.data.metadata&&e.data.metadata.title&&(this.media_title=e.data.metadata.title)),this.config.ga.start_on||(this.config.ga.start_on="playing"),this.video.ads||(this.config.ga.start_on="playing"),this.once&&(this.once=!1,this.track(this.event_actions.video_player_load)))}fullscreenenter(){this.track(this.event_actions.fullscreen_enter)}fullscreenexit(){this.track(this.event_actions.fullscreen_exit)}checkForAdCounter(e,t){return e.replace("[x]",t+"")}adstarted(e){var t;switch((null===(t=e.data)||void 0===t?void 0:t.ad_type)||"preroll"){case"midroll":this.ad_type="midroll",this.midroll_counter++,this.track(this.checkForAdCounter(this.event_actions.ad_start_midroll,this.midroll_counter));break;case"postroll":this.ad_type="postroll",this.postroll_counter++,this.track(this.checkForAdCounter(this.event_actions.ad_start_postroll,this.postroll_counter));break;default:this.ad_type="preroll",this.preroll_counter++,this.track(this.checkForAdCounter(this.event_actions.ad_start_preroll,this.preroll_counter))}}adcompleted(e){var t;switch((null===(t=e.data)||void 0===t?void 0:t.ad_type)||"preroll"){case"midroll":this.track(this.event_actions.ad_completed_midroll);break;case"postroll":this.track(this.event_actions.ad_completed_postroll);break;default:this.track(this.event_actions.ad_completed_preroll)}}adskipped(){if(this.ad_type)switch(this.ad_type){case"midroll":this.track(this.event_actions.ad_skipped_midroll);break;case"postroll":this.track(this.event_actions.ad_skipped_postroll);break;default:this.track(this.event_actions.ad_skipped_preroll)}else this.track(this.event_actions.ad_skipped_preroll)}adbreakcompleted(e){this.set_started(e),this.track(this.event_actions.ad_break_completed)}track(e){let t=this.event_categories.videos;this.liveflag&&(t=this.event_categories.live),e&&t&&(this.setup_ga(),this.ga_extensions.length&&void 0!==window.ga&&null!==window.ga?this.ga_extensions.forEach(i=>{window.ga(i+".send","event",t,e,this.media_title)}):console.debug("ga console.send","event",t,e,this.media_title))}})}));
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.google_analytics=t())}(this,(function(){"use strict";return function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const i=e.flowplayer;return"function"==typeof i?(i(t),t):(Array.isArray(i.extensions)||(i.extensions=[]),~i.extensions.indexOf(t)||i.extensions.push(t),t)}(window,class GoogleAnalyticsPlugin{constructor(e){this.started=!1,this.paused=!1,this.muted=!1,this.once=!0,this.liveflag=!1,this.ga_instances=[],this.ga_extensions=[],this.quartiles=[0,0,0],this.ad_type="preroll",this.preroll_counter=0,this.midroll_counter=0,this.postroll_counter=0,this.event_categories={live:"Live",videos:"Videos"},this.event_actions={fullscreen_enter:"fullscreen_enter",fullscreen_exit:"fullscreen_exit",video_player_load:"video_player_load",video_start:"video_start",video_click_play:"video_click_play",video_pause:"video_pause",video_resume:"video_resume",video_mute:"video_mute",video_unmute:"video_unmute",video_25_percent:"video_25_percent",video_50_percent:"video_50_percent",video_75_percent:"video_75_percent",video_complete:"video_complete",live_start:"live_start",live_click_play:"live_click_play",live_pause:"live_pause",live_resume:"live_resume",live_mute:"live_mute",live_unmute:"live_unmute",live_complete:"live_complete",ad_start_preroll:"ad_start_preroll",ad_start_midroll:"ad_start_midroll",ad_start_postroll:"ad_start_postroll",ad_completed_preroll:"ad_completed_preroll",ad_completed_midroll:"ad_completed_midroll",ad_completed_postroll:"ad_completed_postroll",ad_skipped_preroll:"ad_skipped_preroll",ad_skipped_midroll:"ad_skipped_midroll",ad_skipped_postroll:"ad_skipped_postroll",ad_break_completed:"ad_break_completed"},this.flowplayer=e}init(e,t,i){var s;if(this.config=e,this.video=i,"object"!=typeof e.ga)return;if(i.hasState("consent-no-tracking"))return;const a=(null===(s=this.flowplayer.ads)||void 0===s?void 0:s.events)||{AD_STARTED:"ad-started",AD_COMPLETED:"ad-completed",AD_SKIPPED:"ad-skipped",AD_BREAK_COMPLETED:"ad-break-completed"};this.muted=i.muted||!1,this.media_title=e.ga.media_title||"unknown video title",this.ga_instances=e.ga.ga_instances,e.ga.event_actions&&(this.event_actions=e.ga.event_actions),e.ga.event_categories&&(this.event_categories=e.ga.event_categories),i.on(["mount","timeupdate","loadstart","ended","seeked","seeking","pause","playing","volumechange",a.AD_STARTED,a.AD_COMPLETED,a.AD_SKIPPED,a.AD_BREAK_COMPLETED,"config","click","touchend","fullscreenenter","fullscreenexit"],e=>{switch(e.type){case"playing":this.playing(e.type);break;case"pause":this.pause();break;case"mount":this.loaded();break;case"timeupdate":this.progress();break;case"ended":this.ended();break;case"volumechange":this.volumechange();break;case"ad-started":this.adstarted(e);break;case"ad-completed":this.adcompleted(e);break;case"ad-break-completed":this.adbreakcompleted(e.type);break;case"config":this.configured(e);break;case"click":this.click();break;case"fullscreenenter":this.fullscreenenter();break;case"fullscreenexit":this.fullscreenexit();break;case"ad-skipped":this.adskipped()}})}setup_ga(){window.ga&&0===this.ga_extensions.length&&this.ga_instances.forEach((e,t)=>{var i;window.ga("create",e,"auto","ext"+(t+1)),(null===(i=this.config)||void 0===i?void 0:i.ga.custom_data)&&window.ga("ext"+(t+1)+".set",this.config.ga.custom_data),this.ga_extensions.push("ext"+(t+1))})}set_started(e){var t;(null===(t=this.config)||void 0===t?void 0:t.ga.start_on)===e&&(this.liveflag?this.track(this.event_actions.live_start):this.track(this.event_actions.video_start),this.started=!0)}click(){!this.paused&&this.started||(this.liveflag?this.track(this.event_actions.live_click_play):this.track(this.event_actions.video_click_play))}playing(e){this.started?this.paused&&(this.paused=!1,this.liveflag?this.track(this.event_actions.live_resume):this.track(this.event_actions.video_resume)):this.set_started(e)}pause(){this.video&&(Math.abs(this.video.duration-this.video.currentTime)<1||!this.started||(this.paused=!0,this.liveflag?this.track(this.event_actions.live_pause):this.track(this.event_actions.video_pause)))}loaded(){}progress(){!this.liveflag&&this.video&&(this.video.currentTime/this.video.duration>.25&&0===this.quartiles[0]?(this.quartiles[0]=1,this.track(this.event_actions.video_25_percent)):this.video.currentTime/this.video.duration>.5&&0===this.quartiles[1]?(this.quartiles[1]=1,this.track(this.event_actions.video_50_percent)):this.video.currentTime/this.video.duration>.75&&0===this.quartiles[2]&&(this.quartiles[2]=1,this.track(this.event_actions.video_75_percent)))}volumechange(){this.video&&(this.video.muted&&!this.muted?(this.muted=!0,this.liveflag?this.track(this.event_actions.live_mute):this.track(this.event_actions.video_mute)):!this.video.muted&&this.muted&&(this.muted=!1,this.liveflag?this.track(this.event_actions.live_unmute):this.track(this.event_actions.video_unmute)))}ended(){this.started&&(this.liveflag?this.track(this.event_actions.live_complete):this.track(this.event_actions.video_complete)),this.reset()}reset(){this.started=!1,this.quartiles=[0,0,0],this.once=!0,this.config&&(this.config.ga.start_on="playing"),this.preroll_counter=0,this.midroll_counter=0,this.postroll_counter=0}configured(e){this.config&&this.video&&(e.data&&(e.data.live&&(this.liveflag=!0),e.data.title?this.media_title=e.data.title:e.data.metadata&&e.data.metadata.title&&(this.media_title=e.data.metadata.title)),this.config.ga.start_on||(this.config.ga.start_on="playing"),this.video.ads||(this.config.ga.start_on="playing"),this.once&&(this.once=!1,this.track(this.event_actions.video_player_load)))}fullscreenenter(){this.track(this.event_actions.fullscreen_enter)}fullscreenexit(){this.track(this.event_actions.fullscreen_exit)}checkForAdCounter(e,t){return e.replace("[x]",t+"")}adstarted(e){var t;switch((null===(t=e.data)||void 0===t?void 0:t.ad_type)||"preroll"){case"midroll":this.ad_type="midroll",this.midroll_counter++,this.track(this.checkForAdCounter(this.event_actions.ad_start_midroll,this.midroll_counter));break;case"postroll":this.ad_type="postroll",this.postroll_counter++,this.track(this.checkForAdCounter(this.event_actions.ad_start_postroll,this.postroll_counter));break;default:this.ad_type="preroll",this.preroll_counter++,this.track(this.checkForAdCounter(this.event_actions.ad_start_preroll,this.preroll_counter))}}adcompleted(e){var t;switch((null===(t=e.data)||void 0===t?void 0:t.ad_type)||"preroll"){case"midroll":this.track(this.event_actions.ad_completed_midroll);break;case"postroll":this.track(this.event_actions.ad_completed_postroll);break;default:this.track(this.event_actions.ad_completed_preroll)}}adskipped(){if(this.ad_type)switch(this.ad_type){case"midroll":this.track(this.event_actions.ad_skipped_midroll);break;case"postroll":this.track(this.event_actions.ad_skipped_postroll);break;default:this.track(this.event_actions.ad_skipped_preroll)}else this.track(this.event_actions.ad_skipped_preroll)}adbreakcompleted(e){this.set_started(e),this.track(this.event_actions.ad_break_completed)}track(e){let t=this.event_categories.videos;this.liveflag&&(t=this.event_categories.live),e&&t&&(this.setup_ga(),this.ga_extensions.length&&void 0!==window.ga&&null!==window.ga?this.ga_extensions.forEach(i=>{window.ga(i+".send","event",t,e,this.media_title)}):console.debug("ga console.send","event",t,e,this.media_title))}})}));
package/plugins/health.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.health=t())}(this,(function(){"use strict";const e="rebuffer";var t=Object.freeze({__proto__:null,RECORD:"health:record",REBUFFER:e});const n="load",i="fullscreenenter",o="fullscreenexit",s="loadedmetadata",r="loadeddata",a="progress",d="loadstart",c="pause",l="playing",u="waiting",_="canplay",h="ended",p="seeked",f="seeking";function m(e){try{return!!new URL(e)}catch(e){return!1}}function v(e,t){const n=function(){try{return localStorage.getItem("flowplayer/debug")}catch(e){return""}}(),i=(...i)=>{const o=(null==t?void 0:t.debug)||n;o&&e.match(o)&&console.log(e,...i)};return i.log=i,i}const E=navigator;function g(e){var t,n;const i=null===(t=e.hls)||void 0===t?void 0:t.bandwidthEstimate;return i?1e-6*i:(null===(n=E.connection)||void 0===n?void 0:n.downlink)||-1}function y(e,t){return function(e,t){return"function"==typeof navigator.sendBeacon&&navigator.sendBeacon(e,t)}(e,JSON.stringify({events:t}))}const R="https://ljsp.lwcdn.com".concat("/web/public/countdown/time.json"),O=window,I=O._flowplayerTimekeeper||(O._flowplayerTimekeeper={});var w;!function(e){e[e.OFF=0]="OFF",e[e.ON=1]="ON",e[e.AUDIO_REQUIRED=2]="AUDIO_REQUIRED"}(w||(w={}));const D=e=>{switch(e){case!0:return w.ON;case!1:return w.OFF;default:return e}},N=[];function T(e){if(e.suspended)return;const t=N.slice(0);N.length=0,0!=t.length&&(e.logger.log(`:dispatch events={${t.length}}`),y("https://health.flowplayer.com/v1/health/events",t))}async function b(e,t,n){const i=await S();N.push(Object.assign(t,i)),e.logger.log(":enqueue",t.event,t),N.length<10&&!n||T(e)}const A=()=>{var e,t;try{const n=window;return null===(t=null===(e=null==n?void 0:n.google)||void 0===e?void 0:e.ima)||void 0===t?void 0:t.VERSION}catch(e){return}},S=async()=>{try{const e=await async function(){const e=I.cachedServerOffset;if(e)return e;const t=I.pendingRequest||(I.pendingRequest=fetch(R)),n=await t,i=parseInt(n.headers.get("age")||"0"),o=await n.json(),s=Date.now()-o.millisUtc-1e3*i;return I.cachedServerOffset=s,I.cachedServerOffset}();return{timestamp:Date.now()-e,adjustedTimestamp:!0}}catch(e){return{timestamp:Date.now(),adjustedTimestamp:!1}}},U=(e,t)=>Object.assign(e,{detail:t}),k=(e,{event:t,media_session_id:n,session_id:i})=>({event:t,media_session_id:n,session_id:i,device_id:e.deviceId(),version:"3.1.1",commit:"6e72aaabb83c9f53f9b0b6788acb0cbadb4fc77c",ima_sdk_version:A(),preload:e.opt("preload"),autoplay:D(e.opt("autoplay")),live:e.opt("live"),dvr:e.opt("dvr"),source:e.original_src,downlink_mbs:g(e),player_id:e.opt("metadata.player_id"),media_id:e.opt("metadata.media_id"),site_id:e.opt("metadata.site_id"),category_id:e.opt("metadata.category_id"),sitegroup_id:e.opt("metadata.sitegroup_id"),token:e.token,plugins:e.plugins.map(e=>e.constructor.name).sort((e,t)=>e.localeCompare(t)),current_time:e.currentTime,external_media_id:e.opt("external_media_id")}),C=e=>({bitrate:null==e?void 0:e.bitrate,resolution:null==e?void 0:e.attrs.RESOLUTION,frame_rate:null==e?void 0:e.attrs["FRAME-RATE"]});function L(e,t,n,i){const o=k(t,e.eventInfo(n)),{before:s,after:r}=i;b(e,((e,t,n)=>Object.assign(e,{state:{before:t,after:n}}))(o,C(s),C(r)))}const M=[1e7]+""+-1e3+-4e3+-8e3+-1e11,B=()=>"undefined"==typeof crypto?"":M.replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16));var x;function j(e){switch(e){case x.MEDIA_PLAYBACK_ABORTED:return"media playback was aborted";case x.MEDIA_ERR_NETWORK:return"a network error occurred";case x.MEDIA_ERR_DECODE:return"unable to decode media content";case x.MEDIA_ERR_SRC_NOT_SUPPORTED:return"unsupported media type";case x.NO_INTERNET:return"no internet connection detected";case x.MIXED_CONTENT:return"cannot load insecure content in a secure context";default:return"an unknown error occurred"}}!function(e){e[e.UNKNOWN=-1]="UNKNOWN",e[e.MEDIA_PLAYBACK_ABORTED=1]="MEDIA_PLAYBACK_ABORTED",e[e.MEDIA_ERR_NETWORK=2]="MEDIA_ERR_NETWORK",e[e.MEDIA_ERR_DECODE=3]="MEDIA_ERR_DECODE",e[e.MEDIA_ERR_SRC_NOT_SUPPORTED=4]="MEDIA_ERR_SRC_NOT_SUPPORTED",e[e.MIXED_CONTENT=1001]="MIXED_CONTENT",e[e.NO_INTERNET=1002]="NO_INTERNET"}(x||(x={}));const F=(e,t)=>{let n=null;return(...i)=>{null!==n&&(clearTimeout(n),n=null),n=setTimeout(()=>t(...i),e)}},H=B();class Health{constructor(e,t){this.session_id=H,this.suspended=!1,this.logger=v("health",t.opts),this.media_session_id=B(),this.analyticsLoop=setInterval(()=>T(this),2e3),t.on("reap",()=>clearInterval(this.analyticsLoop));const n=this;if(t.health={get media_session_id(){return n.media_session_id},set media_session_id(e){n.media_session_id=e},get session_id(){return n.session_id},set session_id(e){n.session_id=e},toggle(e){e?n.resume():n.suspend()}},!Health._UNLOAD_SUBSCRIBED){Health._UNLOAD_SUBSCRIBED=!0;const t=t=>e.instances.forEach(e=>e.emit(t.type));document.addEventListener("visibilitychange",e=>{"hidden"==document.visibilityState&&t(e)}),window.addEventListener("pagehide",t)}}eventInfo(e){return{event:e,media_session_id:this.media_session_id,session_id:this.session_id}}suspend(){this.suspended=!0,clearInterval(this.analyticsLoop)}resume(){this.suspended=!1,this.analyticsLoop=setInterval(()=>T(this),2e3)}init(t,v,E){!function(t){t.on(u,(function(n){t.seeking||t.networkState===t.NETWORK_LOADING&&t.readyState!==t.HAVE_NOTHING&&t.emit(e)}))}(E),E.on("health:record",({detail:e})=>{const t=k(E,this.eventInfo(e.event));Object.assign(t,e.detail||{}),b(this,t)}),[_,d,n,s,r,a,u,e].forEach(e=>{E.on(e,e=>{b(this,k(E,this.eventInfo(e.type)))})}),[l,c,f,p,h,i,o].forEach(e=>{E.on(e,e=>{b(this,k(E,this.eventInfo(e.type)))})}),E.on("volumechange",F(800,e=>{const t=k(E,this.eventInfo(e.type));b(this,U(t,{volume:parseFloat(E.volume.toFixed(2)),muted:E.muted}))})),E.on("resize",F(800,e=>{const t=k(E,this.eventInfo(e.type));b(this,U(t,{height:v.clientHeight,width:v.clientWidth}))})),E.on("qualitychange",({type:e,detail:t})=>{switch(t.kind){case"hls":return L(this,E,e,t)}});let g=Date.now()+5e3;E.on("timeupdate",e=>{if(Date.now()<g)return;g=Date.now()+5e3;const t=k(E,this.eventInfo(e.type));var n;b(this,U(t,{duration:(n=E.duration,Number.isFinite(n)?n:n===1/0?-1:void 0)}))}),E.addEventListener("error",e=>{const t=k(E,this.eventInfo(e.type)),n=e.error||E.error;if(!n)return b(this,t,!0);const i=n.code,o={error_message:n.message||j(i),error_code:i,error_stack:n.stack||""};return b(this,U(t,o),!0)}),E.on("src",e=>{var t;const n=null===(t=e.detail)||void 0===t?void 0:t.src;if("string"!=typeof n)return;if(!m(E.original_src))return;if(!m(n))return;if(n==E.original_src)return;this.media_session_id=B();b(this,k(E,this.eventInfo(e.type))),T(this)}),E.on("visibilitychange",e=>{b(this,k(E,this.eventInfo(e.type))),T(this)})}}return Health.events=t,Health._UNLOAD_SUBSCRIBED=!1,function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;"function"==typeof n?n(t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t))}(window,Health),Health}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.health=t())}(this,(function(){"use strict";const e="rebuffer";var t=Object.freeze({__proto__:null,RECORD:"health:record",REBUFFER:e});const n="load",i="fullscreenenter",o="fullscreenexit",s="loadedmetadata",r="loadeddata",a="progress",d="loadstart",c="pause",l="playing",u="waiting",_="canplay",h="ended",p="seeked",f="seeking";function m(e){try{return!!new URL(e)}catch(e){return!1}}function v(e,t){const n=function(){try{return localStorage.getItem("flowplayer/debug")}catch(e){return""}}(),i=(i,...o)=>{const s=(null==t?void 0:t.debug)||n;s&&e.match(s)&&console.log(`${e} -- ${i}`,...o)};return i.log=i,i}const E=navigator;function g(e){var t,n;const i=null===(t=e.hls)||void 0===t?void 0:t.bandwidthEstimate;return i?1e-6*i:(null===(n=E.connection)||void 0===n?void 0:n.downlink)||-1}function y(e,t){return function(e,t){return"function"==typeof navigator.sendBeacon&&navigator.sendBeacon(e,t)}(e,JSON.stringify({events:t}))}const R="https://ljsp.lwcdn.com".concat("/web/public/countdown/time.json"),O=window,I=O._flowplayerTimekeeper||(O._flowplayerTimekeeper={});var w;!function(e){e[e.OFF=0]="OFF",e[e.ON=1]="ON",e[e.AUDIO_REQUIRED=2]="AUDIO_REQUIRED"}(w||(w={}));const D=e=>{switch(e){case!0:return w.ON;case!1:return w.OFF;default:return e}},N=[];function T(e){if(e.suspended)return;const t=N.slice(0);N.length=0,0!=t.length&&(e.logger.log(`:dispatch events={${t.length}}`),y("https://ihi.flowplayer.com/v1/health/events",t))}async function A(e,t,n){const i=await S();N.push(Object.assign(t,i)),e.logger.log(":enqueue",t.event,t),N.length<10&&!n||T(e)}const b=()=>{var e,t;try{const n=window;return null===(t=null===(e=null==n?void 0:n.google)||void 0===e?void 0:e.ima)||void 0===t?void 0:t.VERSION}catch(e){return}},S=async()=>{try{const e=await async function(){const e=I.cachedServerOffset;if(e)return e;const t=I.pendingRequest||(I.pendingRequest=fetch(R)),n=await t,i=parseInt(n.headers.get("age")||"0"),o=await n.json(),s=Date.now()-o.millisUtc-1e3*i;return I.cachedServerOffset=s,I.cachedServerOffset}();return{timestamp:Date.now()-e,adjustedTimestamp:!0}}catch(e){return{timestamp:Date.now(),adjustedTimestamp:!1}}},U=(e,t)=>Object.assign(e,{detail:t}),k=(e,{event:t,media_session_id:n,session_id:i})=>({event:t,media_session_id:n,session_id:i,device_id:e.deviceId(),version:"3.2.1",commit:"1d1cc7d121030da16a4aab14894402944fc1e96f",ima_sdk_version:b(),preload:e.opt("preload"),autoplay:D(e.opt("autoplay")),live:e.opt("live"),dvr:e.opt("dvr"),source:e.original_src,downlink_mbs:g(e),player_id:e.opt("metadata.player_id"),media_id:e.opt("metadata.media_id"),site_id:e.opt("metadata.site_id"),category_id:e.opt("metadata.category_id"),sitegroup_id:e.opt("metadata.sitegroup_id"),token:e.token,plugins:e.plugins.map(e=>e.constructor.name).sort((e,t)=>e.localeCompare(t)),current_time:e.currentTime,external_media_id:e.opt("external_media_id")}),C=e=>({bitrate:null==e?void 0:e.bitrate,resolution:null==e?void 0:e.attrs.RESOLUTION,frame_rate:null==e?void 0:e.attrs["FRAME-RATE"]});function L(e,t,n,i){const o=k(t,e.eventInfo(n)),{before:s,after:r}=i;A(e,((e,t,n)=>Object.assign(e,{state:{before:t,after:n}}))(o,C(s),C(r)))}const M=[1e7]+""+-1e3+-4e3+-8e3+-1e11,B=()=>"undefined"==typeof crypto?"":M.replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16));var x;function j(e){switch(e){case x.MEDIA_PLAYBACK_ABORTED:return"media playback was aborted";case x.MEDIA_ERR_NETWORK:return"a network error occurred";case x.MEDIA_ERR_DECODE:return"unable to decode media content";case x.MEDIA_ERR_SRC_NOT_SUPPORTED:return"unsupported media type";case x.NO_INTERNET:return"no internet connection detected";case x.MIXED_CONTENT:return"cannot load insecure content in a secure context";default:return"an unknown error occurred"}}!function(e){e[e.UNKNOWN=-1]="UNKNOWN",e[e.MEDIA_PLAYBACK_ABORTED=1]="MEDIA_PLAYBACK_ABORTED",e[e.MEDIA_ERR_NETWORK=2]="MEDIA_ERR_NETWORK",e[e.MEDIA_ERR_DECODE=3]="MEDIA_ERR_DECODE",e[e.MEDIA_ERR_SRC_NOT_SUPPORTED=4]="MEDIA_ERR_SRC_NOT_SUPPORTED",e[e.MIXED_CONTENT=1001]="MIXED_CONTENT",e[e.NO_INTERNET=1002]="NO_INTERNET"}(x||(x={}));const F=(e,t)=>{let n=null;return(...i)=>{null!==n&&(clearTimeout(n),n=null),n=setTimeout(()=>t(...i),e)}},H=B();class Health{constructor(e,t){this.session_id=H,this.suspended=!1,this.logger=v("health",t.opts),this.media_session_id=B(),this.analyticsLoop=setInterval(()=>T(this),2e3),t.on("reap",()=>clearInterval(this.analyticsLoop));const n=this;if(t.health={get media_session_id(){return n.media_session_id},set media_session_id(e){n.media_session_id=e},get session_id(){return n.session_id},set session_id(e){n.session_id=e},toggle(e){e?n.resume():n.suspend()}},!Health._UNLOAD_SUBSCRIBED){Health._UNLOAD_SUBSCRIBED=!0;const t=t=>e.instances.forEach(e=>e.emit(t.type));document.addEventListener("visibilitychange",e=>{"hidden"==document.visibilityState&&t(e)}),window.addEventListener("pagehide",t)}}eventInfo(e){return{event:e,media_session_id:this.media_session_id,session_id:this.session_id}}suspend(){this.suspended=!0,clearInterval(this.analyticsLoop)}resume(){this.suspended=!1,this.analyticsLoop=setInterval(()=>T(this),2e3)}init(t,v,E){!function(t){t.on(u,(function(n){t.seeking||t.networkState===t.NETWORK_LOADING&&t.readyState!==t.HAVE_NOTHING&&t.emit(e)}))}(E),E.on("health:record",({detail:e})=>{const t=k(E,this.eventInfo(e.event));Object.assign(t,e.detail||{}),A(this,t)}),[_,d,n,s,r,a,u,e].forEach(e=>{E.on(e,e=>{A(this,k(E,this.eventInfo(e.type)))})}),[l,c,f,p,h,i,o].forEach(e=>{E.on(e,e=>{A(this,k(E,this.eventInfo(e.type)))})}),E.on("volumechange",F(800,e=>{const t=k(E,this.eventInfo(e.type));A(this,U(t,{volume:parseFloat(E.volume.toFixed(2)),muted:E.muted}))})),E.on("resize",F(800,e=>{const t=k(E,this.eventInfo(e.type));A(this,U(t,{height:v.clientHeight,width:v.clientWidth}))})),E.on("qualitychange",({type:e,detail:t})=>{switch(t.kind){case"hls":return L(this,E,e,t)}});let g=Date.now()+5e3;E.on("timeupdate",e=>{if(Date.now()<g)return;g=Date.now()+5e3;const t=k(E,this.eventInfo(e.type));var n;A(this,U(t,{duration:(n=E.duration,Number.isFinite(n)?n:n===1/0?-1:void 0)}))}),E.addEventListener("error",e=>{const t=k(E,this.eventInfo(e.type)),n=e.error||E.error;if(!n)return A(this,t,!0);const i=n.code,o={error_message:n.message||j(i),error_code:i,error_stack:n.stack||""};return A(this,U(t,o),!0)}),E.on("src",e=>{var t;const n=null===(t=e.detail)||void 0===t?void 0:t.src;if("string"!=typeof n)return;if(!m(E.original_src))return;if(!m(n))return;if(n==E.original_src)return;this.media_session_id=B();A(this,k(E,this.eventInfo(e.type))),T(this)}),E.on("visibilitychange",e=>{A(this,k(E,this.eventInfo(e.type))),T(this)})}}return Health.events=t,Health._UNLOAD_SUBSCRIBED=!1,function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;"function"==typeof n?n(t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t))}(window,Health),Health}));
package/plugins/hls.js CHANGED
@@ -354,4 +354,4 @@
354
354
  /*!*********************************!*\
355
355
  !*** ./src/utils/xhr-loader.ts ***!
356
356
  \*********************************/
357
- /*! exports provided: default */function(t,e,r){r.r(e);var i=r(/*! ../utils/logger */"./src/utils/logger.ts"),n=r(/*! ../loader/load-stats */"./src/loader/load-stats.ts"),s=/^age:\s*[\d.]+\s*$/m,a=function(){function t(t){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=t?t.xhrSetup:null,this.stats=new n.LoadStats,this.retryDelay=0}var e=t.prototype;return e.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},e.abortInternal=function(){var t=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),t&&(t.onreadystatechange=null,t.onprogress=null,4!==t.readyState&&(this.stats.aborted=!0,t.abort()))},e.abort=function(){var t;this.abortInternal(),null!==(t=this.callbacks)&&void 0!==t&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},e.load=function(t,e,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=t,this.config=e,this.callbacks=r,this.retryDelay=e.retryDelay,this.loadInternal()},e.loadInternal=function(){var t=this.config,e=this.context;if(t){var r=this.loader=new self.XMLHttpRequest,i=this.stats;i.loading.first=0,i.loaded=0;var n=this.xhrSetup;try{if(n)try{n(r,e.url)}catch(t){r.open("GET",e.url,!0),n(r,e.url)}r.readyState||r.open("GET",e.url,!0)}catch(t){return void this.callbacks.onError({code:r.status,text:t.message},e,r)}e.rangeEnd&&r.setRequestHeader("Range","bytes="+e.rangeStart+"-"+(e.rangeEnd-1)),r.onreadystatechange=this.readystatechange.bind(this),r.onprogress=this.loadprogress.bind(this),r.responseType=e.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),t.timeout),r.send()}},e.readystatechange=function(){var t=this.context,e=this.loader,r=this.stats;if(t&&e){var n=e.readyState,s=this.config;if(!r.aborted&&n>=2)if(self.clearTimeout(this.requestTimeout),0===r.loading.first&&(r.loading.first=Math.max(self.performance.now(),r.loading.start)),4===n){e.onreadystatechange=null,e.onprogress=null;var a=e.status;if(a>=200&&a<300){var o,l;if(r.loading.end=Math.max(self.performance.now(),r.loading.first),l="arraybuffer"===t.responseType?(o=e.response).byteLength:(o=e.responseText).length,r.loaded=r.total=l,!this.callbacks)return;var u=this.callbacks.onProgress;if(u&&u(r,t,o,e),!this.callbacks)return;var d={url:e.responseURL,data:o};this.callbacks.onSuccess(d,r,t,e)}else r.retry>=s.maxRetry||a>=400&&a<499?(i.logger.error(a+" while loading "+t.url),this.callbacks.onError({code:a,text:e.statusText},t,e)):(i.logger.warn(a+" while loading "+t.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,s.maxRetryDelay),r.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),s.timeout)}},e.loadtimeout=function(){i.logger.warn("timeout while loading "+this.context.url);var t=this.callbacks;t&&(this.abortInternal(),t.onTimeout(this.stats,this.context,this.loader))},e.loadprogress=function(t){var e=this.stats;e.loaded=t.loaded,t.lengthComputable&&(e.total=t.total)},e.getCacheAge=function(){var t=null;if(this.loader&&s.test(this.loader.getAllResponseHeaders())){var e=this.loader.getResponseHeader("age");t=e?parseFloat(e):null}return t},t}();e.default=a}}).default},t.exports=r())})));var r=Object.freeze({__proto__:null,ATTACHED:"hls:attached"});const i="com.widevine.alpha";const n="application/vnd.apple.mpegURL",s=[n,"application/x-mpegurl"],a=document.createElement("video").canPlayType(n);function o(t){const{pathname:e}=function(t){const e=document.createElement("a");return e.href=t,e}(t);return e.endsWith(".m3u8")}function l({src:t="",type:e="",drm:r},n){const l=(null==n?void 0:n.hls)||{},u="native"in l&&l.native;return(!a||!u)&&(!(r&&!Object.keys(r).find(t=>{return e=t,[i].filter((function(t){return t===e})).length;var e}))&&(!(!e||!s.includes(e))||o(t)))}var u="audio:set",d="audio:update",c="audio:tracks";const h=[e.Events.SUBTITLE_TRACKS_UPDATED,e.Events.SUBTITLE_TRACK_SWITCH,e.Events.LEVEL_SWITCHED];function f(t,e){h.forEach((function(r){t.on(r,(function(){!function(t,e){var r;const i=t.levels[t.currentLevel];if(!i||!t.subtitleTracks.length||i.attrs.SUB)return;const n=null===(r=null==i?void 0:i.attrs)||void 0===r?void 0:r.SUBTITLES;if(!n)return e.emit("tracks:text:all",[]);const s=t.subtitleTracks.filter((function(t){return t.groupId==n})).map((function(t){return e.textTracks[t.id]}));e.emit("tracks:text:all",s)}(t,e)}))}))}var g=Object.assign(Object.assign({},{404:"the video was not found",403:"access to this video was denied",410:"the video no longer exists",0:"no internet connection detected"}),{keySystemNoKeys:"no keys",keySystemNoAccess:"no access to key system",keySystemNoSession:"no session for key system",keySystemLicenseRequestFailed:"license request failed",keyLoadError:"decrypt key load failed",keyLoadTimeOut:"decrypt key load timed outs"});var v;function p(t,r,i){if(!t.reaper||!i.src)return;t.hls&&(t.emit("recover",{type:"hls"}),t.hls.destroy());const n="live"in r==0,s={is_audio_only:!1,fragDuration:-1};if(i.drm&&"https:"!==location.protocol&&"localhost"!==location.hostname&&"127.0.0.1"!==location.hostname)return t.emit("error",{message:"Secure page required for DRM"});const a=t.hls=new e(function(t){return Object.assign(Object.assign({autoStartLoad:!1},t.hls),{startPosition:t.start_time||-1})}(r)),o={retry_count:0,previous_url:"",previous_content:""};a.subtitleDisplay=!1,a.attachMedia(t),a.loadSource(i.src),t.emit("hls:attached",{hls:a}),function(t,r){t.on(e.Events.AUDIO_TRACKS_UPDATED,(function(t,e){r.emit(c,e.audioTracks)})),t.on(e.Events.AUDIO_TRACK_SWITCHING,(function(t,e){r.emit(d,e)})),t.on(e.Events.MANIFEST_PARSED,(function(t,e){e.audioTracks&&r.emit(c,e.audioTracks)})),t.on(e.Events.LEVEL_SWITCHED,(function(e,i){const n=t.levels[i.level];n&&r.emit(c,t.audioTracks.filter((function(t){return t.groupId&&~(n.audioGroupIds||[]).indexOf(t.groupId)})))}))}(a,t),f(a,t);const l=function(t){var e;const r=null===(e=t.data)||void 0===e?void 0:e.level;"number"==typeof r&&(a.levels[r]||-1===r?a.nextLevel=r:console.error(new Error("skipping invalid quality: "+t.data)))},h=function(t){var e;const r=null===(e=t.data)||void 0===e?void 0:e.id;"number"==typeof r&&r!=a.audioTrack&&setTimeout((function(){a.audioTrack=r}),0)};t.on("quality:set",l),t.on(u,h),t.on("src",(function(){t.hls&&t.hls.destroy(),t.off("quality:set",l),t.off(u,h)})),t.on("audioonlysource",(function(){s.is_audio_only=!0})),t.on("reap",(function(){a&&a.destroy()})),t.on("remotesession:started",()=>{t.hls&&t.hls.stopLoad()}),t.on("remotesession:ended",()=>{t.hls&&m(t)}),n&&a.on(e.Events.LEVEL_LOADED,(function(e,r){t.setOpts({live:r.details.live})})),a.on(e.Events.MANIFEST_PARSED,(function(e,i){const n=i.levels.slice(0).reduce((t,e,r)=>[...t,{level:r,text:e.name||e.width+"",width:e.width,height:e.height,videoCodec:e.videoCodec||""}],[{text:"AUTO",level:-1,width:0,height:0,videoCodec:""}]).sort((t,e)=>e.width-t.width);t.emit("qualities",n),function(t,e,r){if(!t.hls)return;void 0!==e.start_quality&&(v.HIGH&e.start_quality&&(t.hls.startLevel=r[0].level),v.LOW&e.start_quality&&(t.hls.startLevel=r[r.length-1].level),v.MEDIUM&e.start_quality&&(t.hls.startLevel=r[Math.ceil(r.length/2)-1].level));if("none"===e.preload&&!e.autoplay)return;m(t,e.start_time||-1)}(t,r,n.slice(0,-1));const s=n.find(t=>!!t.videoCodec);s||t.emit("audioonlysource"),!t.opt("ratio")&&s&&0!=s.width&&0!=s.height&&t.setOpts({ratio:s.width+":"+s.height})})),a.on(e.Events.INIT_PTS_FOUND,(function(t,e){s.fragDuration=e.frag.duration})),a.on(e.Events.ERROR,(function(r,i){!function(t,r,i,n){if(0==t.reaper)return;if(0==r.fatal)return;switch(r.type){case e.ErrorTypes.MEDIA_ERROR:return function(t,e){var r;t.emit("error",{fatal:!0,message:"Unrecoverable error occurred while playing media"}),null===(r=t.hls)||void 0===r||r.destroy()}(t);case e.ErrorTypes.NETWORK_ERROR:return function(t,e){var r;const i=(null===(r=e.networkDetails)||void 0===r?void 0:r.status)||"";t.emit("error",{fatal:!0,code:"http:"+i.toString(),message:g[i]||"an error occurred while loading this video"})}(t,r);case e.ErrorTypes.KEY_SYSTEM_ERROR:(function(t,e){var r;t.emit("error",{fatal:!0,message:g[e.details]||"an error occurred while accessing this video"}),null===(r=t.hls)||void 0===r||r.destroy()})(t,r)}}(t,i,t.original_src,a.config)})),a.on(e.Events.LEVEL_PTS_UPDATED,(function(e,r){var i;if("video"!==r.type&&(!s.is_audio_only||"audio"!==r.type))return;const n=null===(i=null==r?void 0:r.details)||void 0===i?void 0:i.fragments;if(!n)return;const a=n[0].start||0,o=n[n.length-1].start+n[n.length-1].duration;t.emit("dvr/window",o-a)})),a.on(e.Events.LEVEL_SWITCHING,(e,r)=>{const i=a.levels[a.currentLevel],n=a.levels[r.level];t.emit("qualitychange",{before:i,after:n,kind:"hls"})}),a.on(e.Events.LEVEL_UPDATED,(t,e)=>{e.details.url!==o.previous_url&&(o.retry_count=0),o.previous_url=e.details.url;const r=o.previous_content;if(o.previous_content=e.details.m3u8,r===e.details.m3u8){if(o.retry_count++,o.retry_count<3)return;if(a.levels[e.level].url.length<2)return;a.levelController.redundantFailover(a.currentLevel)}});const p=t.opt("start_time");p&&t.once("loadedmetadata",(function(){t.currentTime=p})),"none"!==r.preload||r.autoplay||t.once("beforeplay",()=>{m(t,r.start_time||-1)})}function m(t,e){var r;t.setState("is-loading",!0),null===(r=t.hls)||void 0===r||r.startLoad(e)}!function(t){t[t.LOW=1]="LOW",t[t.MEDIUM=2]="MEDIUM",t[t.HIGH=4]="HIGH"}(v||(v={}));class HLS{init(){}onload(t,e,r,i){p(r,t,i)}wants(t,r,i){return e.isSupported()&&l(r,i)}}return HLS.events=r,HLS.version=e.version,function(t,e){if("object"==typeof exports&&"undefined"!=typeof module)return e;"flowplayer"in t||(t.flowplayer={extensions:[]});const r=t.flowplayer;"function"==typeof r?r(e):(Array.isArray(r.extensions)||(r.extensions=[]),~r.extensions.indexOf(e)||r.extensions.push(e))}(window,HLS),HLS}));
357
+ /*! exports provided: default */function(t,e,r){r.r(e);var i=r(/*! ../utils/logger */"./src/utils/logger.ts"),n=r(/*! ../loader/load-stats */"./src/loader/load-stats.ts"),s=/^age:\s*[\d.]+\s*$/m,a=function(){function t(t){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=t?t.xhrSetup:null,this.stats=new n.LoadStats,this.retryDelay=0}var e=t.prototype;return e.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},e.abortInternal=function(){var t=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),t&&(t.onreadystatechange=null,t.onprogress=null,4!==t.readyState&&(this.stats.aborted=!0,t.abort()))},e.abort=function(){var t;this.abortInternal(),null!==(t=this.callbacks)&&void 0!==t&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},e.load=function(t,e,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=t,this.config=e,this.callbacks=r,this.retryDelay=e.retryDelay,this.loadInternal()},e.loadInternal=function(){var t=this.config,e=this.context;if(t){var r=this.loader=new self.XMLHttpRequest,i=this.stats;i.loading.first=0,i.loaded=0;var n=this.xhrSetup;try{if(n)try{n(r,e.url)}catch(t){r.open("GET",e.url,!0),n(r,e.url)}r.readyState||r.open("GET",e.url,!0)}catch(t){return void this.callbacks.onError({code:r.status,text:t.message},e,r)}e.rangeEnd&&r.setRequestHeader("Range","bytes="+e.rangeStart+"-"+(e.rangeEnd-1)),r.onreadystatechange=this.readystatechange.bind(this),r.onprogress=this.loadprogress.bind(this),r.responseType=e.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),t.timeout),r.send()}},e.readystatechange=function(){var t=this.context,e=this.loader,r=this.stats;if(t&&e){var n=e.readyState,s=this.config;if(!r.aborted&&n>=2)if(self.clearTimeout(this.requestTimeout),0===r.loading.first&&(r.loading.first=Math.max(self.performance.now(),r.loading.start)),4===n){e.onreadystatechange=null,e.onprogress=null;var a=e.status;if(a>=200&&a<300){var o,l;if(r.loading.end=Math.max(self.performance.now(),r.loading.first),l="arraybuffer"===t.responseType?(o=e.response).byteLength:(o=e.responseText).length,r.loaded=r.total=l,!this.callbacks)return;var u=this.callbacks.onProgress;if(u&&u(r,t,o,e),!this.callbacks)return;var d={url:e.responseURL,data:o};this.callbacks.onSuccess(d,r,t,e)}else r.retry>=s.maxRetry||a>=400&&a<499?(i.logger.error(a+" while loading "+t.url),this.callbacks.onError({code:a,text:e.statusText},t,e)):(i.logger.warn(a+" while loading "+t.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,s.maxRetryDelay),r.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),s.timeout)}},e.loadtimeout=function(){i.logger.warn("timeout while loading "+this.context.url);var t=this.callbacks;t&&(this.abortInternal(),t.onTimeout(this.stats,this.context,this.loader))},e.loadprogress=function(t){var e=this.stats;e.loaded=t.loaded,t.lengthComputable&&(e.total=t.total)},e.getCacheAge=function(){var t=null;if(this.loader&&s.test(this.loader.getAllResponseHeaders())){var e=this.loader.getResponseHeader("age");t=e?parseFloat(e):null}return t},t}();e.default=a}}).default},t.exports=r())})));var r=Object.freeze({__proto__:null,ATTACHED:"hls:attached"});const i="com.widevine.alpha";const n="application/vnd.apple.mpegURL",s=[n,"application/x-mpegurl"],a=document.createElement("video").canPlayType(n);function o(t){const{pathname:e}=function(t){const e=document.createElement("a");return e.href=t,e}(t);return e.endsWith(".m3u8")}function l({src:t="",type:e="",drm:r},n){const l=(null==n?void 0:n.hls)||{},u="native"in l&&l.native;return(!a||!u)&&(!(r&&!Object.keys(r).find(t=>{return e=t,[i].filter((function(t){return t===e})).length;var e}))&&(!(!e||!s.includes(e))||o(t)))}var u="audio:set",d="audio:update",c="audio:tracks";const h=[e.Events.SUBTITLE_TRACKS_UPDATED,e.Events.SUBTITLE_TRACK_SWITCH,e.Events.LEVEL_SWITCHED];function f(t,e){h.forEach((function(r){t.on(r,(function(){!function(t,e){var r;const i=t.levels[t.currentLevel];if(!i||!t.subtitleTracks.length||i.attrs.SUB)return;const n=null===(r=null==i?void 0:i.attrs)||void 0===r?void 0:r.SUBTITLES;if(!n)return e.emit("tracks:text:all",[]);const s=t.subtitleTracks.filter((function(t){return t.groupId==n})).map((function(t){return e.textTracks[t.id]}));e.emit("tracks:text:all",s)}(t,e)}))}))}var g=Object.assign(Object.assign({},{404:"the video was not found",403:"access to this video was denied",410:"the video no longer exists",0:"no internet connection detected"}),{keySystemNoKeys:"no keys",keySystemNoAccess:"no access to key system",keySystemNoSession:"no session for key system",keySystemLicenseRequestFailed:"license request failed",keyLoadError:"decrypt key load failed",keyLoadTimeOut:"decrypt key load timed outs"});var v;!function(t){t[t.LOW=1]="LOW",t[t.MEDIUM=2]="MEDIUM",t[t.HIGH=4]="HIGH"}(v||(v={}));const p=function(t,e){const r=function(){try{return localStorage.getItem("flowplayer/debug")}catch(t){return""}}(),i=(i,...n)=>{const s=(null==e?void 0:e.debug)||r;s&&t.match(s)&&console.log(`${t} -- ${i}`,...n)};return i.log=i,i}("hls");function m(t,r,i){if(!t.reaper||!i.src)return;t.hls&&(t.emit("recover",{type:"hls"}),t.hls.destroy());const n="live"in r==0,s={is_audio_only:!1,fragDuration:-1};if(i.drm&&"https:"!==location.protocol&&"localhost"!==location.hostname&&"127.0.0.1"!==location.hostname)return t.emit("error",{message:"Secure page required for DRM"});const a=t.hls=new e(function(t){return Object.assign(Object.assign({autoStartLoad:!1},t.hls),{startPosition:t.start_time||-1})}(r)),o={retry_count:0,previous_url:"",previous_content:""};a.subtitleDisplay=!1,a.attachMedia(t),a.loadSource(i.src),t.emit("hls:attached",{hls:a}),function(t,r){t.on(e.Events.AUDIO_TRACKS_UPDATED,(function(t,e){r.emit(c,e.audioTracks)})),t.on(e.Events.AUDIO_TRACK_SWITCHING,(function(t,e){r.emit(d,e)})),t.on(e.Events.MANIFEST_PARSED,(function(t,e){e.audioTracks&&r.emit(c,e.audioTracks)})),t.on(e.Events.LEVEL_SWITCHED,(function(e,i){const n=t.levels[i.level];n&&r.emit(c,t.audioTracks.filter((function(t){return t.groupId&&~(n.audioGroupIds||[]).indexOf(t.groupId)})))}))}(a,t),f(a,t);const l=function(t){var e;const r=null===(e=t.data)||void 0===e?void 0:e.level;"number"==typeof r&&(a.levels[r]||-1===r?a.nextLevel=r:console.error(new Error("skipping invalid quality: "+t.data)))},h=function(t){var e;const r=null===(e=t.data)||void 0===e?void 0:e.id;"number"==typeof r&&r!=a.audioTrack&&setTimeout((function(){a.audioTrack=r}),0)};t.on("quality:set",l),t.on(u,h),t.on("src",(function(){t.hls&&t.hls.destroy(),t.off("quality:set",l),t.off(u,h)})),t.on("audioonlysource",(function(){s.is_audio_only=!0})),t.on("reap",(function(){a&&a.destroy()})),t.on("remotesession:started",()=>{t.hls&&t.hls.stopLoad()}),t.on("remotesession:ended",()=>{t.hls&&y(t)}),n&&a.on(e.Events.LEVEL_LOADED,(function(e,r){t.setOpts({live:r.details.live})})),a.on(e.Events.MANIFEST_PARSED,(function(e,i){const n=i.levels.slice(0).reduce((t,e,r)=>[...t,{level:r,text:e.name||e.width+"",width:e.width,height:e.height,videoCodec:e.videoCodec||""}],[{text:"AUTO",level:-1,width:0,height:0,videoCodec:""}]).sort((t,e)=>e.width-t.width);t.emit("qualities",n),function(t,e,r){var i,n;if(!t.hls)return;p("Initializer::maybe_start_load_with_quality (start_quality, preload): (%d, %s)",e.start_quality,e.preload),void 0!==e.start_quality&&(v.HIGH&e.start_quality&&(t.hls.startLevel=r[0].level),v.LOW&e.start_quality&&(t.hls.startLevel=r[r.length-1].level),v.MEDIUM&e.start_quality&&(t.hls.startLevel=r[Math.ceil(r.length/2)-1].level));const s=(null===(i=e.hls)||void 0===i?void 0:i.maxBufferSize)||1024,a=(null===(n=e.hls)||void 0===n?void 0:n.maxBufferLength)||30;p("Setting maxBufferSize to %d",s),t.hls.config.maxBufferSize=s,"metadata"===e.preload&&p("preload === metadata, setting maxBufferLength to 1sec");if(t.hls.config.maxBufferLength="metadata"===e.preload?1:a,t.once("playing",()=>{p("Playback started, set maxBufferLenght to %d",a),t.hls&&(t.hls.config.maxBufferLength=a)}),"none"===e.preload&&!e.autoplay)return;y(t,e.start_time||-1)}(t,r,n.slice(0,-1));const s=n.find(t=>!!t.videoCodec);s||t.emit("audioonlysource"),!t.opt("ratio")&&s&&0!=s.width&&0!=s.height&&t.setOpts({ratio:s.width+":"+s.height})})),a.on(e.Events.INIT_PTS_FOUND,(function(t,e){s.fragDuration=e.frag.duration})),a.on(e.Events.ERROR,(function(r,i){!function(t,r,i,n){if(0==t.reaper)return;if(0==r.fatal)return;switch(r.type){case e.ErrorTypes.MEDIA_ERROR:return function(t,e){var r;t.emit("error",{fatal:!0,message:"Unrecoverable error occurred while playing media"}),null===(r=t.hls)||void 0===r||r.destroy()}(t);case e.ErrorTypes.NETWORK_ERROR:return function(t,e){var r;const i=(null===(r=e.networkDetails)||void 0===r?void 0:r.status)||"";t.emit("error",{fatal:!0,code:"http:"+i.toString(),message:g[i]||"an error occurred while loading this video"})}(t,r);case e.ErrorTypes.KEY_SYSTEM_ERROR:(function(t,e){var r;t.emit("error",{fatal:!0,message:g[e.details]||"an error occurred while accessing this video"}),null===(r=t.hls)||void 0===r||r.destroy()})(t,r)}}(t,i,t.original_src,a.config)})),a.on(e.Events.LEVEL_PTS_UPDATED,(function(e,r){var i;if("video"!==r.type&&(!s.is_audio_only||"audio"!==r.type))return;const n=null===(i=null==r?void 0:r.details)||void 0===i?void 0:i.fragments;if(!n)return;const a=n[0].start||0,o=n[n.length-1].start+n[n.length-1].duration;t.emit("dvr/window",o-a)})),a.on(e.Events.LEVEL_SWITCHING,(e,r)=>{const i=a.levels[a.currentLevel],n=a.levels[r.level];t.emit("qualitychange",{before:i,after:n,kind:"hls"})}),a.on(e.Events.LEVEL_UPDATED,(t,e)=>{e.details.url!==o.previous_url&&(o.retry_count=0),o.previous_url=e.details.url;const r=o.previous_content;if(o.previous_content=e.details.m3u8,r===e.details.m3u8){if(o.retry_count++,o.retry_count<3)return;if(a.levels[e.level].url.length<2)return;a.levelController.redundantFailover(a.currentLevel)}});const m=t.opt("start_time");m&&t.once("loadedmetadata",(function(){t.currentTime=m})),"none"!==r.preload||r.autoplay||t.once("beforeplay",()=>{y(t,r.start_time||-1)})}function y(t,e){var r;t.setState("is-loading",!0),null===(r=t.hls)||void 0===r||r.startLoad(e)}class HLS{init(){}onload(t,e,r,i){m(r,t,i)}wants(t,r,i){return e.isSupported()&&l(r,i)}}return HLS.events=r,HLS.version=e.version,function(t,e){if("object"==typeof exports&&"undefined"!=typeof module)return e;"flowplayer"in t||(t.flowplayer={extensions:[]});const r=t.flowplayer;"function"==typeof r?r(e):(Array.isArray(r.extensions)||(r.extensions=[]),~r.extensions.indexOf(e)||r.extensions.push(e))}(window,HLS),HLS}));
package/plugins/iframe.js CHANGED
@@ -1 +1 @@
1
- !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.iframe=n())}(this,(function(){"use strict";class Iframe{constructor(e){Iframe.ATTACHED||(Iframe.ATTACHED=!0,window.addEventListener("message",(function(n){if(!Iframe.is_flowplayer_message(n.data))return;const t=e.instances||[],r=t[0];if(!r)return;t.length>1&&console.warn("Multiple player instances in iframe. Messaging supported with first instance only.");switch(Iframe.message_body(n.data)){case"pause":return r.togglePlay(!1);case"play":return r.togglePlay(!0)}})))}init(e,n,t){t.on("fullscreenenter",(function(){document.fullscreenEnabled||"function"==typeof t.webkitEnterFullscreen&&(t.webkitEnterFullscreen(),t.once("webkitendfullscreen",(function(){t.emit("fullscreenexit")})),t.on("ended",(function(){t.webkitExitFullscreen()})))}))}}return Iframe.FLOWPLAYER_RPC_PROTOCOL="flowplayer://",Iframe.ATTACHED=!1,Iframe.is_flowplayer_message=function(e){return"string"==typeof e&&e.startsWith(Iframe.FLOWPLAYER_RPC_PROTOCOL)},Iframe.message_body=function(e){return e.slice(Iframe.FLOWPLAYER_RPC_PROTOCOL.length)},function(){try{return window.self!==window.top}catch(e){return!0}}()&&function(e,n){if("object"==typeof exports&&"undefined"!=typeof module)return n;"flowplayer"in e||(e.flowplayer={extensions:[]});const t=e.flowplayer;"function"==typeof t?t(n):(Array.isArray(t.extensions)||(t.extensions=[]),~t.extensions.indexOf(n)||t.extensions.push(n))}(window,Iframe),Iframe}));
1
+ !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.iframe=n())}(this,(function(){"use strict";class Iframe{constructor(e,n){Iframe.ATTACHED||(n.setState("is-iframe",!0),Iframe.ATTACHED=!0,window.addEventListener("message",(function(n){if(!Iframe.is_flowplayer_message(n.data))return;const t=e.instances||[],r=t[0];if(!r)return;t.length>1&&console.warn("Multiple player instances in iframe. Messaging supported with first instance only.");switch(Iframe.message_body(n.data)){case"pause":return r.togglePlay(!1);case"play":return r.togglePlay(!0)}})))}init(e,n,t){t.on("fullscreenenter",(function(){document.fullscreenEnabled||"function"==typeof t.webkitEnterFullscreen&&(t.webkitEnterFullscreen(),t.once("webkitendfullscreen",(function(){t.emit("fullscreenexit")})),t.on("ended",(function(){t.webkitExitFullscreen()})))}))}}return Iframe.FLOWPLAYER_RPC_PROTOCOL="flowplayer://",Iframe.ATTACHED=!1,Iframe.is_flowplayer_message=function(e){return"string"==typeof e&&e.startsWith(Iframe.FLOWPLAYER_RPC_PROTOCOL)},Iframe.message_body=function(e){return e.slice(Iframe.FLOWPLAYER_RPC_PROTOCOL.length)},function(){try{return window.self!==window.top}catch(e){return!0}}()&&function(e,n){if("object"==typeof exports&&"undefined"!=typeof module)return n;"flowplayer"in e||(e.flowplayer={extensions:[]});const t=e.flowplayer;"function"==typeof t?t(n):(Array.isArray(t.extensions)||(t.extensions=[]),~t.extensions.indexOf(n)||t.extensions.push(n))}(window,Iframe),Iframe}));
package/plugins/ovp.js CHANGED
@@ -12,4 +12,4 @@
12
12
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13
13
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
14
  PERFORMANCE OF THIS SOFTWARE.
15
- ***************************************************************************** */const t=t=>"object"==typeof t&&null!==t&&!Array.isArray(t),e=(...n)=>n.reduce((n,o)=>t(o)?(Object.keys(o).forEach(i=>{if(t(n[i])&&t(o[i]))return n[i]=e(n[i],o[i]);n[i]=o[i]}),n):n,{});class Pipe{constructor(t){this.data=t}static of(t){return new Pipe(t)}static maybe(t,e,...n){return null==t?t:e.apply(t,[t,...n])}tap(t,...e){return t.apply(this,[this.data,...e]),new Pipe(this.data)}fmap(t,...e){const n=t.apply(this,[this.data,...e]);return new Pipe(n)}unwrap(){return this.data}}const n="https://ljsp.lwcdn.com".concat("/web/public/countdown/time.json"),o=window,i=o._flowplayerTimekeeper||(o._flowplayerTimekeeper={});function r(t){return fetch(t).then(t=>t.json())}function a(){let t=[].join.call(arguments,"/");return"/"!==t[0]&&(t="/"+t),s()+"/web/public/native/config"+t}const s=()=>"https://ljsp.lwcdn.com";function l(t){(async function(){const t=i.cachedServerOffset;if(t)return t;const e=i.pendingRequest||(i.pendingRequest=fetch(n)),o=await e,r=parseInt(o.headers.get("age")||"0"),a=await o.json(),s=Date.now()-a.millisUtc-1e3*r;return i.cachedServerOffset=s,i.cachedServerOffset})().then(e=>Object.assign(t,{server_time_offset:e}))}function c(t){return~t.indexOf("/")?t:"/media/"+t}var d={404:"media not found",402:"invalid subscription",400:"bad request",415:"unsupported media type"};function u(t){const e=t.ima,n=t.duration;if(!e||!n)return t;const o=null==e?void 0:e.ads;return Array.isArray(o)&&(e.ads=o.map((function(t){return"number"==typeof t.percentage&&(t.time=t.percentage*n),t}))),t}function p(t,n){var o,i;n="object"==typeof n?n:{};const r={title:null===(o=null==t?void 0:t.metadata)||void 0===o?void 0:o.title,description:null===(i=null==t?void 0:t.metadata)||void 0===i?void 0:i.description},a={ima:{parameters:function({media_id:t,duration:e,title:n,tags:o,category_name:i,ad_keywords:r}){return{ad_keywords:r||"",media_id:t||"",category:i||"",media_name:n||"",media_tags:o||"",media_duration:e||-1}}((null==t?void 0:t.metadata)||{})}},s=n.embed||{};return delete s.src,e(a,r,t,(delete(l=n).src,delete l.metadata,delete l.title,delete l.description,delete l.duration,delete l.poster,l),s);var l}const m=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/;function f(t){return"object"==typeof t&&"ovp/base64"==t.type}function v(t,e){return function(t,e){return!t.startsWith("blob:")&&(!(~t.indexOf(".")||!m.test(t))&&(e.type="video/ovp",!0))}(t,e)||f(e)}function y(t){try{return function(t){return null===t?{}:JSON.parse(t)}(decodeURIComponent(atob(t).split("").map((function(t){return"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2)})).join("")))}catch(t){return{err:t.message}}}function h(t){const e=t.split(/[^0-9]/).map(t=>parseInt(t,10));return Date.UTC(e[0],e[1]-1,e[2],e[3],e[4],e[5])}function w(t){return t.live}var _=Object.freeze({__proto__:null,OVP_ERROR:"ovp:error",OVP_MEDIA_REQUEST_START:"ovp:request:start",OVP_MEDIA_REQUEST_COMPLETE:"ovp:request:media:complete",OVP_PLAYLIST_REQUEST_COMPLETE:"ovp:request:playlist:complete",LIVE_COUNTDOWN_TICK:"ovp:live:countdown:tick",LIVE_COUNTDOWN_START:"ovp:live:countdown:start",LIVE_COUNTDOWN_COMPLETE:"ovp:live:countdown:complete",OVP_MEDIA_CHANGED:"ovp:media:changed",OVP_REALTIME_MESSAGE:"ovp:message:realtime"});function g(t,e){const n=null==e?void 0:e.src;if(f(e))return function(t,e){const n=y(e.src||"");if(function(t){return"string"==typeof t.err}(n))return console.error(n.err);b(t,n)}(t,e);n&&Pipe.of(n).fmap(c).fmap(a).fmap(t=>fetch(t)).fmap(e=>e.then(t=>Promise.all([t.status,t.json()])).then(([e,n])=>200==e?b(t,n):E(t,n)))}function b(t,n){return t.emit("ovp:media:changed",n),function(t){return Array.isArray(t.playlist)}(n)?function(t,n){if("function"!=typeof window.flowplayer.playlist)return console.warn("OVP responded with Playlist media but the playlist plugin does not exist"),E(t,{status:415});t.emit("ovp:request:playlist:complete",function(t,n){const o=Object.assign({},t),i=(null==t?void 0:t.playlist)||{},r=e(n,i),a=((null==r?void 0:r.playlist)||[]).map(t=>p(t,o));return Object.assign(r,{playlist:a})}(t.opts,n))}(t,n):w(n)?function(t,e){var n,o;const i=(null===(n=null==e?void 0:e.metadata)||void 0===n?void 0:n.live_start_time)||(null===(o=null==e?void 0:e.metadata)||void 0===o?void 0:o.starttime);i&&(e.live_start_time=Pipe.of(i).fmap(h).unwrap());t.emit("ovp:live:countdown:start",Pipe.of(e).fmap(p,t.opts).fmap(u).unwrap())}(t,n):function(t,e){t.emit("ovp:request:media:complete",Pipe.of(e).fmap(p,t.opts).fmap(u).unwrap())}(t,n)}function E(t,e){return e.message?t.emit("ovp:error",e):e.status?t.emit("ovp:error",new Error(d[e.status])):t.emit("ovp:error",e)}const O={};function P(t,e,n){"object"!=typeof O[e]&&(O[e]=n);const o=t.opts,i=(null==o?void 0:o.metadata)||{};i.player_id=e,o.metadata=i,n.title&&delete n.title,n.description&&delete n.description;const r=Object.assign(o,n);t.setOpts(r),n.autoplay&&t.togglePlay(!0)}let j=!1;function A(t,e,n){T()||Pipe.of("recommendation").fmap(a,e,n).fmap(r).fmap(e=>e.then(e=>function(t,e){const n=e.playlist;if(t.opts.recommendations=n,!n.length)return;t.emit("recommendationsready",{playlist:n.map((function(t){var e;return{poster:t.poster,src:t.src,title:null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.title,metadata:t.metadata||{}}}))})}(t,e)).catch(L))}function T(){return j}function L(t){j=!0,console.error("Failed to load recommendations: %j",t)}function C(t){const e="number"==typeof t?t:parseInt(t,10);return(e>9?"":"0")+e}function x(t,e){const n=t._customElements.get(e);return n&&t.root.querySelector(n)||void 0}const S="flowplayer-live-countdown";function M(t){return t&&t.live_start_time&&t.live_start_time-Date.now()>0}function D(t,e){let n=0;function o(){return function(t,e){const n=Date.now()-e;return Math.floor((t-n)/1e3)}(e.live_start_time||0,e.server_time_offset||0)}function i(){const i=o();if(i<0||isNaN(i)||0===t.reaper)return clearInterval(n),function(t,e){t.emit("ovp:live:countdown:complete");const n=x(t,S);n&&n.remove(),t.root.classList.remove("is-livecountdown"),t.emit("ovp:request:media:complete",e)}(t,e);var r,a,s;r=t,a=t.root,s=i,a.classList.add("is-livecountdown"),r.emit("ovp:live:countdown:tick",{remaining_time:I(s+1)}),r.hasState("is-starting")||r.setState("is-starting",!0)}l(e),i(),n=setInterval(i,250)}function I(t){const e=function(t){"number"!=typeof t&&(t=parseInt(t,10)),t=Math.round(t);const e=Math.floor(t/86400);t-=86400*e;const n=Math.floor(t/3600);t-=3600*n;const o=Math.floor(t/60);return{days:e,hours:n,minutes:o,seconds:t-=60*o}}(t);let n="";return e.days&&(n+=e.days+":"),n+C(e.hours)+":"+C(e.minutes)+":"+C(e.seconds)}class WebsocketBridge{constructor(t){this.manualDisconnect=!1,this.video=t,this.onClose=this.onClose.bind(this),this.onMessage=this.onMessage.bind(this)}static of(t){return new WebsocketBridge(t)}connect(t){this.client=new WebSocket("wss://player.ws.flowplayer.com?mediaId="+t),this.current_media_id=t,this.wireup()}onClose(){this.manualDisconnect?this.manualDisconnect=!1:this.current_media_id&&this.reconnect(this.current_media_id)}onMessage(t){JSON.parse(t.data).forEach(t=>{this.video.emit("ovp:message:realtime",t)})}reconnect(t){this.cleanup(),this.connect(t)}wireup(){this.client&&(this.client.addEventListener("message",this.onMessage),this.client.addEventListener("close",this.onClose))}cleanup(){this.client&&(this.client.removeEventListener("message",this.onMessage),this.client.removeEventListener("close",this.onClose),this.client=void 0)}disconnect(){this.client&&(this.manualDisconnect=!0,this.client.close())}}const k=(t,e)=>new(((t,e)=>{const n=t.get(e);if(!n)throw new Error(`no flowplayer component with the name ${e} exists`);const o=window.customElements.get(e);if(!o)throw new Error(`no default flowplayer component with the name ${e} exists`);const i=window.customElements.get(n);return"function"!=typeof i?o:i})(t._customElements,e))(t);class FlowplayerComponent extends HTMLElement{constructor(t){super(),this.player=t}}class FlowplayerLiveCountdown extends FlowplayerComponent{constructor(t){super(t),this.classList.add("fp-livecountdown");const e=function(...t){const e=document.createElement("div");return 0==t.length||e.classList.add(...t),e}("fp-inner");this.append(e);const n=document.createElement("p");n.innerText=t.i18n("ovp.starting_in"),e.append(n);const o=document.createElement("p");o.classList.add("fp-countdown"),e.append(o),t.on("ovp:live:countdown:tick",e=>{const n=e.detail.remaining_time;t.root.classList.add("is-livecountdown"),o.innerText=n})}}const q=["*.lwcdn.com","*.flowplayer.com"];function V(){try{return window.location.hostname!==window.parent.location.hostname?function(t){const e=document.createElement("a");return e.href=t,e}(document.referrer).hostname:document.location.hostname}catch(t){return window.location.hostname}}class OVP{constructor(t){((t,e,n)=>{window.customElements.get(e)||window.customElements.define(e,n),t.customElements.get(e)||t.customElements.set(e,e)})(t,S,FlowplayerLiveCountdown)}onload(t,e,n,o){if("string"==typeof o.src)return"string"!=typeof t.player_id||0===o.src.indexOf(t.player_id)||f(o)||(o.src=[t.player_id,o.src].join("/")),g(n,o)}wants(t,e,n){return v(t,e)}init(t,n,o){const i=new WebsocketBridge(o);let s=Object.assign({},t);const l=function(t){if(!s)return t;delete s.src;const n=e(t,s);return s=!1,n};o.on("ovp:error",(function(t){o.emit("error",t.data)})),o.on("ovp:request:start",(function(){o.setState("is-waiting",!0),t.recommendations&&(t.recommendations=!1)})),o.on("ovp:media:changed",(function({data:t}){var e;const n=null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.media_id;(null==t?void 0:t.live)&&n&&(i.disconnect(),i.connect(n))})),o.on("ovp:message:realtime",(function({data:e}){var n;const i=null==e?void 0:e.event,r=null==e?void 0:e.value,a=o.opt("metadata",{live_start_time:""});switch(i){case"METADATA":{const e=Object.assign(a,r),i=Object.assign(t,{metadata:e});i.live&&(null===(n=null==i?void 0:i.metadata)||void 0===n?void 0:n.live_start_time)&&(i.live_start_time=h(i.metadata.live_start_time)),o.setOpts(i);break}}})),o.on("beforeplay",(function(e){const n=t;if(w(n)){if(R(n))return;e.preventDefault()}})),o.on("ovp:request:media:complete",(function(t){const e=t.data;if(!e)return;if(0==o.reaper||"object"!=typeof t.data||M(t.data))return;const n=l(e);o.setOpts(n),o.setAttrs(n),n.src&&o.setSrc(n.src),n.autoplay&&o.togglePlay(!0)})),o.on("config",(function({data:e}){var i,s;if("string"==typeof t.src&&v(t.src,{}))return;if(t.src&&N(t.src))return;if((null==e?void 0:e.domains)&&(null==e?void 0:e.domains.length)&&!((t,e)=>{const n=t.split(".").reverse();return e.concat(q).some(t=>{const e=t.split(".").reverse(),o="*"===e[e.length-1];return o&&e.pop(),(o||e.length===n.length)&&e.every((t,e)=>n[e]===t)})})(V(),e.domains))return function({root:t,video:e,data:n}){e&&e.destroy(),console.error(new Error(n.details||n.reason)),t.innerHTML="",t.classList.remove("flowplayer"),t.classList.add("flowplayer-fatal"),t.style.removeProperty("background-image");const o=document.createElement("h2");o.textContent="Playback Error";const i=document.createElement("p");i.textContent="Are you the site owner?";const r=document.createElement("a");r.classList.add("troubleshoot"),r.target="_blank",r.href="https://flowplayer.com/help/developers/troubleshooting#"+n.reason,r.textContent="Troubleshoot?";const a=document.createElement("img");a.src="https://flowplayer.com/user/pages/images/logo-white.png",t.append(o,i,r,a)}({root:n,video:o,data:{details:`Hostname ${window.location.hostname} is not allowed to load player ${null===(i=e.metadata)||void 0===i?void 0:i.player_id}.`,reason:"domain"}});const l=null==e?void 0:e.brand_color;return l&&o.root.style.setProperty("--fp-brand-color","#"==l[0]?l:"#"+l),"string"==typeof t.player_id&&(null===(s=null==t?void 0:t.metadata)||void 0===s?void 0:s.player_id)!==t.player_id?function(t,e){if("object"==typeof O[e])return console.debug("using Cache(%s)",e),P(t,e,O[e]);Pipe.of(e).fmap(a).fmap(r).fmap(n=>n.then(n=>P(t,e,n)).catch(console.error))}(o,t.player_id):void 0})),o.on("ovp:request:playlist:complete",(function(t){const e=t.data;if(!e||0==o.reaper)return;const{playlist:n}=e,i=function(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(t);i<o.length;i++)e.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(t,o[i])&&(n[o[i]]=t[o[i]])}return n}(e,["playlist"]),r=l({playlist:i});Array.isArray(r.playlist)&&(r.playlist=i),o.setOpts(r);const a={type:"flowplayer/playlist",items:n};o.setSrc(a)})),o.on("ovp:live:countdown:start",(function(e){const i=e.data;if(!i||0==o.reaper)return;const r=l(i);if(o.setOpts(r),o.setAttrs(r),!M(i))return o.emit("ovp:request:media:complete",i);x(o,S)||(n.appendChild(k(o,S)),D(o,t))})),o.on("timeupdate",(function(){var e,n,i;const r=t;w(r)?R(r)||(o.togglePlay(!1),o.emit("ended")):t.recommendations&&(null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.media_id)&&(Array.isArray(t.recommendations)||o.currentTime/o.duration<.8||T()||(null===(n=null==t?void 0:t.metadata)||void 0===n?void 0:n.media_id)&&(null===(i=null==t?void 0:t.metadata)||void 0===i?void 0:i.player_id)&&A(o,t.metadata.media_id,t.metadata.player_id))})),o.on("reap",(function(){i.disconnect()}))}}function R(t){var e,n;const o=null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.live_stop_time;if(!o)return!0;return!!(null===(n=null==t?void 0:t.metadata)||void 0===n?void 0:n.allow_after_stop_time)||h(o)>Date.now()}OVP.events=_;const N=t=>{var e;if(t&&Array.isArray(t))return"object"==typeof t[0]&&"ovp/base64"===(null===(e=t[0])||void 0===e?void 0:e.type)};return function(t,e){if("object"==typeof exports&&"undefined"!=typeof module)return e;"flowplayer"in t||(t.flowplayer={extensions:[]});const n=t.flowplayer;"function"==typeof n?n(e):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(e)||n.extensions.push(e))}(window,OVP),OVP}));
15
+ ***************************************************************************** */const t=t=>"object"==typeof t&&null!==t&&!Array.isArray(t),e=(...n)=>n.reduce((n,o)=>t(o)?(Object.keys(o).forEach(i=>{if(t(n[i])&&t(o[i]))return n[i]=e(n[i],o[i]);n[i]=o[i]}),n):n,{});class Pipe{constructor(t){this.data=t}static of(t){return new Pipe(t)}static maybe(t,e,...n){return null==t?t:e.apply(t,[t,...n])}tap(t,...e){return t.apply(this,[this.data,...e]),new Pipe(this.data)}fmap(t,...e){const n=t.apply(this,[this.data,...e]);return new Pipe(n)}unwrap(){return this.data}}const n="https://ljsp.lwcdn.com".concat("/web/public/countdown/time.json"),o=window,i=o._flowplayerTimekeeper||(o._flowplayerTimekeeper={});function r(t){return fetch(t).then(t=>t.json())}function a(){let t=[].join.call(arguments,"/");return"/"!==t[0]&&(t="/"+t),s()+"/web/public/native/config"+t}const s=()=>"https://ljsp.lwcdn.com";function l(t){(async function(){const t=i.cachedServerOffset;if(t)return t;const e=i.pendingRequest||(i.pendingRequest=fetch(n)),o=await e,r=parseInt(o.headers.get("age")||"0"),a=await o.json(),s=Date.now()-a.millisUtc-1e3*r;return i.cachedServerOffset=s,i.cachedServerOffset})().then(e=>Object.assign(t,{server_time_offset:e}))}function c(t){return~t.indexOf("/")?t:"/media/"+t}var d={404:"media not found",402:"invalid subscription",400:"bad request",415:"unsupported media type"};function u(t){const e=t.ima,n=t.duration;if(!e||!n)return t;const o=null==e?void 0:e.ads;return Array.isArray(o)&&(e.ads=o.map((function(t){return"number"==typeof t.percentage&&(t.time=t.percentage*n),t}))),t}function p(t,n){var o,i;n="object"==typeof n?n:{};const r={title:null===(o=null==t?void 0:t.metadata)||void 0===o?void 0:o.title,description:null===(i=null==t?void 0:t.metadata)||void 0===i?void 0:i.description},a={ima:{parameters:function({media_id:t,duration:e,title:n,tags:o,category_name:i,ad_keywords:r}){return{ad_keywords:r||"",media_id:t||"",category:i||"",media_name:n||"",media_tags:o||"",media_duration:e||-1}}((null==t?void 0:t.metadata)||{})}},s=n.embed||{};return delete s.src,e(a,r,t,(delete(l=n).src,delete l.metadata,delete l.title,delete l.description,delete l.duration,delete l.poster,l),s);var l}const m=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/;function f(t){return"object"==typeof t&&"ovp/base64"==t.type}function v(t,e){return function(t,e){return!t.startsWith("blob:")&&(!(~t.indexOf(".")||!m.test(t))&&(e.type="video/ovp",!0))}(t,e)||f(e)}function y(t){try{return function(t){return null===t?{}:JSON.parse(t)}(decodeURIComponent(atob(t).split("").map((function(t){return"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2)})).join("")))}catch(t){return{err:t.message}}}function h(t){const e=t.split(/[^0-9]/).map(t=>parseInt(t,10));return Date.UTC(e[0],e[1]-1,e[2],e[3],e[4],e[5])}function w(t){return t.live}var _=Object.freeze({__proto__:null,OVP_ERROR:"ovp:error",OVP_MEDIA_REQUEST_START:"ovp:request:start",OVP_MEDIA_REQUEST_COMPLETE:"ovp:request:media:complete",OVP_PLAYLIST_REQUEST_COMPLETE:"ovp:request:playlist:complete",LIVE_COUNTDOWN_TICK:"ovp:live:countdown:tick",LIVE_COUNTDOWN_START:"ovp:live:countdown:start",LIVE_COUNTDOWN_COMPLETE:"ovp:live:countdown:complete",OVP_MEDIA_CHANGED:"ovp:media:changed",OVP_REALTIME_MESSAGE:"ovp:message:realtime"});function g(t,e){const n=null==e?void 0:e.src;if(f(e))return function(t,e){const n=y(e.src||"");if(function(t){return"string"==typeof t.err}(n))return console.error(n.err);b(t,n)}(t,e);n&&Pipe.of(n).fmap(c).fmap(a).fmap(t=>fetch(t)).fmap(e=>e.then(t=>Promise.all([t.status,t.json()])).then(([e,n])=>200==e?b(t,n):E(t,n)))}function b(t,n){return t.emit("ovp:media:changed",n),function(t){return Array.isArray(t.playlist)}(n)?function(t,n){if("function"!=typeof window.flowplayer.playlist)return console.warn("OVP responded with Playlist media but the playlist plugin does not exist"),E(t,{status:415});t.emit("ovp:request:playlist:complete",function(t,n){const o=Object.assign({},t),i=(null==t?void 0:t.playlist)||{},r=e(n,i),a=((null==r?void 0:r.playlist)||[]).map(t=>p(t,o));return Object.assign(r,{playlist:a})}(t.opts,n))}(t,n):w(n)?function(t,e){var n,o;const i=(null===(n=null==e?void 0:e.metadata)||void 0===n?void 0:n.live_start_time)||(null===(o=null==e?void 0:e.metadata)||void 0===o?void 0:o.starttime);i&&(e.live_start_time=Pipe.of(i).fmap(h).unwrap());t.emit("ovp:live:countdown:start",Pipe.of(e).fmap(p,t.opts).fmap(u).unwrap())}(t,n):function(t,e){t.emit("ovp:request:media:complete",Pipe.of(e).fmap(p,t.opts).fmap(u).unwrap())}(t,n)}function E(t,e){return e.message?t.emit("ovp:error",e):e.status?t.emit("ovp:error",new Error(d[e.status])):t.emit("ovp:error",e)}const O={};function P(t,e,n){"object"!=typeof O[e]&&(O[e]=n);const o=t.opts,i=(null==o?void 0:o.metadata)||{};i.player_id=e,o.metadata=i,n.title&&delete n.title,n.description&&delete n.description;const r=Object.assign(o,n);t.setOpts(r),n.autoplay&&t.togglePlay(!0)}let j=!1;function A(t,e,n){T()||Pipe.of("recommendation").fmap(a,e,n).fmap(r).fmap(e=>e.then(e=>function(t,e){const n=e.playlist;if(t.opts.recommendations=n,!n.length)return;t.emit("recommendationsready",{playlist:n.map((function(t){var e;return{poster:t.poster,src:t.src,title:null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.title,metadata:t.metadata||{}}}))})}(t,e)).catch(L))}function T(){return j}function L(t){j=!0,console.error("Failed to load recommendations: %j",t)}function C(t){const e="number"==typeof t?t:parseInt(t,10);return(e>9?"":"0")+e}function x(t,e){const n=t._customElements.get(e);return n&&t.root.querySelector(n)||void 0}const S="flowplayer-live-countdown";function M(t){return t&&t.live_start_time&&t.live_start_time-Date.now()>0}function D(t,e){let n=0;function o(){return function(t,e){const n=Date.now()-e;return Math.floor((t-n)/1e3)}(e.live_start_time||0,e.server_time_offset||0)}function i(){const i=o();if(i<0||isNaN(i)||0===t.reaper)return clearInterval(n),function(t,e){t.emit("ovp:live:countdown:complete");const n=x(t,S);n&&n.remove(),t.root.classList.remove("is-livecountdown"),t.emit("ovp:request:media:complete",e)}(t,e);var r,a,s;r=t,a=t.root,s=i,a.classList.add("is-livecountdown"),r.emit("ovp:live:countdown:tick",{remaining_time:I(s+1)}),r.hasState("is-starting")||r.setState("is-starting",!0)}l(e),i(),n=setInterval(i,250)}function I(t){const e=function(t){"number"!=typeof t&&(t=parseInt(t,10)),t=Math.round(t);const e=Math.floor(t/86400);t-=86400*e;const n=Math.floor(t/3600);t-=3600*n;const o=Math.floor(t/60);return{days:e,hours:n,minutes:o,seconds:t-=60*o}}(t);let n="";return e.days&&(n+=e.days+":"),n+C(e.hours)+":"+C(e.minutes)+":"+C(e.seconds)}class WebsocketBridge{constructor(t){this.manualDisconnect=!1,this.video=t,this.onClose=this.onClose.bind(this),this.onMessage=this.onMessage.bind(this)}static of(t){return new WebsocketBridge(t)}connect(t){this.client=new WebSocket("wss://player.ws.flowplayer.com?mediaId="+t),this.current_media_id=t,this.wireup()}onClose(){this.manualDisconnect?this.manualDisconnect=!1:this.current_media_id&&this.reconnect(this.current_media_id)}onMessage(t){JSON.parse(t.data).forEach(t=>{this.video.emit("ovp:message:realtime",t)})}reconnect(t){this.cleanup(),this.connect(t)}wireup(){this.client&&(this.client.addEventListener("message",this.onMessage),this.client.addEventListener("close",this.onClose))}cleanup(){this.client&&(this.client.removeEventListener("message",this.onMessage),this.client.removeEventListener("close",this.onClose),this.client=void 0)}disconnect(){this.client&&(this.manualDisconnect=!0,this.client.close())}}const k=(t,e)=>new(((t,e)=>{const n=t.get(e);if(!n)throw new Error(`no flowplayer component with the name ${e} exists`);const o=window.customElements.get(e);if(!o)throw new Error(`no default flowplayer component with the name ${e} exists`);const i=window.customElements.get(n);return"function"!=typeof i?o:i})(t._customElements,e))(t);class FlowplayerComponent extends HTMLElement{constructor(t){super(),this.player=t}}class FlowplayerLiveCountdown extends FlowplayerComponent{constructor(t){super(t),this.classList.add("fp-livecountdown");const e=function(...t){const e=document.createElement("div");return 0==t.length||e.classList.add(...t),e}("fp-inner");this.append(e);const n=document.createElement("p");n.innerText=t.i18n("ovp.starting_in"),e.append(n);const o=document.createElement("p");o.classList.add("fp-countdown"),e.append(o),t.on("ovp:live:countdown:tick",e=>{const n=e.detail.remaining_time;t.root.classList.add("is-livecountdown"),o.innerText=n})}}const q=["*.lwcdn.com","*.flowplayer.com"];function V(){try{return window.location.hostname!==window.parent.location.hostname?function(t){const e=document.createElement("a");return e.href=t,e}(document.referrer).hostname:document.location.hostname}catch(t){return window.location.hostname}}class OVP{constructor(t){((t,e,n)=>{window.customElements.get(e)||window.customElements.define(e,n),t.customElements.get(e)||t.customElements.set(e,e)})(t,S,FlowplayerLiveCountdown)}onload(t,e,n,o){if("string"==typeof o.src)return"string"!=typeof t.player_id||0===o.src.indexOf(t.player_id)||f(o)||(o.src=[t.player_id,o.src].join("/")),g(n,o)}wants(t,e,n){return v(t,e)}init(t,n,o){const i=new WebsocketBridge(o);let s=Object.assign({},t);const l=function(t){if(!s)return t;delete s.src;const n=e(t,s);return s=!1,n};o.on("ovp:error",(function(t){o.emit("error",t.data)})),o.on("ovp:request:start",(function(){o.setState("is-waiting",!0),t.recommendations&&(t.recommendations=!1)})),o.on("ovp:media:changed",(function({data:t}){var e;const n=null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.media_id;(null==t?void 0:t.live)&&n&&(i.disconnect(),i.connect(n))})),o.on("ovp:message:realtime",(function({data:e}){var n;const i=null==e?void 0:e.event,r=null==e?void 0:e.value,a=o.opt("metadata",{live_start_time:""});switch(i){case"METADATA":{const e=Object.assign(a,r),i=Object.assign(t,{metadata:e});i.live&&(null===(n=null==i?void 0:i.metadata)||void 0===n?void 0:n.live_start_time)&&(i.live_start_time=h(i.metadata.live_start_time)),o.setOpts(i);break}}})),o.on("beforeplay",(function(e){const n=t;if(w(n)){if(R(n))return;e.preventDefault()}})),o.on("ovp:request:media:complete",(function(t){const e=t.data;if(!e)return;if(0==o.reaper||"object"!=typeof t.data||M(t.data))return;const n=l(e);o.setOpts(n),o.setAttrs(n),n.src&&o.setSrc(n.src),n.autoplay&&o.togglePlay(!0)})),o.on("config",(function({data:e}){var i,s;if("string"==typeof t.src&&v(t.src,{}))return;if(t.src&&N(t.src))return;if((null==e?void 0:e.domains)&&(null==e?void 0:e.domains.length)&&!((t,e)=>{const n=t.split(".").reverse();return e.concat(q).some(t=>{const e=t.split(".").reverse(),o="*"===e[e.length-1];return o&&e.pop(),(o||e.length===n.length)&&e.every((t,e)=>n[e]===t)})})(V(),e.domains))return function({root:t,video:e,data:n}){e&&e.destroy(),console.error(new Error(n.details||n.reason)),t.innerHTML="",t.classList.remove("flowplayer"),t.classList.add("flowplayer-fatal"),t.style.removeProperty("background-image");const o=document.createElement("h2");o.textContent="Playback Error";const i=document.createElement("p");i.textContent="Are you the site owner?";const r=document.createElement("a");r.classList.add("troubleshoot"),r.target="_blank",r.href="https://docs.flowplayer.com/troubleshooting/player#"+n.reason,r.textContent="Troubleshoot?";const a=document.createElement("img");a.src="https://flowplayer.com/user/pages/images/logo-white.png",t.append(o,i,r,a)}({root:n,video:o,data:{details:`Hostname ${window.location.hostname} is not allowed to load player ${null===(i=e.metadata)||void 0===i?void 0:i.player_id}.`,reason:"domain"}});const l=null==e?void 0:e.brand_color;return l&&o.root.style.setProperty("--fp-brand-color","#"==l[0]?l:"#"+l),"string"==typeof t.player_id&&(null===(s=null==t?void 0:t.metadata)||void 0===s?void 0:s.player_id)!==t.player_id?function(t,e){if("object"==typeof O[e])return console.debug("using Cache(%s)",e),P(t,e,O[e]);Pipe.of(e).fmap(a).fmap(r).fmap(n=>n.then(n=>P(t,e,n)).catch(console.error))}(o,t.player_id):void 0})),o.on("ovp:request:playlist:complete",(function(t){const e=t.data;if(!e||0==o.reaper)return;const{playlist:n}=e,i=function(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(t);i<o.length;i++)e.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(t,o[i])&&(n[o[i]]=t[o[i]])}return n}(e,["playlist"]),r=l({playlist:i});Array.isArray(r.playlist)&&(r.playlist=i),o.setOpts(r);const a={type:"flowplayer/playlist",items:n};o.setSrc(a)})),o.on("ovp:live:countdown:start",(function(e){const i=e.data;if(!i||0==o.reaper)return;const r=l(i);if(o.setOpts(r),o.setAttrs(r),!M(i))return o.emit("ovp:request:media:complete",i);x(o,S)||(n.appendChild(k(o,S)),D(o,t))})),o.on("timeupdate",(function(){var e,n,i;const r=t;w(r)?R(r)||(o.togglePlay(!1),o.emit("ended")):t.recommendations&&(null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.media_id)&&(Array.isArray(t.recommendations)||o.currentTime/o.duration<.8||T()||(null===(n=null==t?void 0:t.metadata)||void 0===n?void 0:n.media_id)&&(null===(i=null==t?void 0:t.metadata)||void 0===i?void 0:i.player_id)&&A(o,t.metadata.media_id,t.metadata.player_id))})),o.on("reap",(function(){i.disconnect()}))}}function R(t){var e,n;const o=null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.live_stop_time;if(!o)return!0;return!!(null===(n=null==t?void 0:t.metadata)||void 0===n?void 0:n.allow_after_stop_time)||h(o)>Date.now()}OVP.events=_;const N=t=>{var e;if(t&&Array.isArray(t))return"object"==typeof t[0]&&"ovp/base64"===(null===(e=t[0])||void 0===e?void 0:e.type)};return function(t,e){if("object"==typeof exports&&"undefined"!=typeof module)return e;"flowplayer"in t||(t.flowplayer={extensions:[]});const n=t.flowplayer;"function"==typeof n?n(e):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(e)||n.extensions.push(e))}(window,OVP),OVP}));
@@ -1 +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.playlist=e())}(this,(function(){"use strict";function t(t,e){if(!e)throw new Error(t)}var e;function n(t,n){var i,o;const l=n.sort||s,r=null!==(i=n.mode)&&void 0!==i?i:e.FIFO;return t=l(t.slice(0),r),{mode:r,sort:l,members:t,last_idx:t.length-1,plays:null!==(o=n.plays)&&void 0!==o?o:0,idx:-1}}function i(t){return t.idx==t.last_idx}function o(t){return-1==t.idx?t.members[0]:t.members[t.idx]}function s(t,n){return(n&e.SHUFFLE)==e.SHUFFLE?t.sort((function(){return Math.random()-Math.random()})):t.slice(0)}function l(t){return n(t.members,{mode:t.mode,plays:t.plays+1,sort:t.sort})}!function(t){t[t.SHUFFLE=1]="SHUFFLE",t[t.FIFO=2]="FIFO",t[t.LOOP=4]="LOOP"}(e||(e={}));var r={PLAYLIST_NEXT:"playlist:next",PLAYLIST_PREVIOUS:"playlist:previous",PLAYLIST_SELECTION:"playlist:selection",PLAYLIST_LOOP:"playlist:loop",PLAYLIST_ENDED:"playlist:ended",PLAYLIST_READY:"playlist:ready",PLAYLIST_ADD:"playlist:add",PLAYLIST_REMOVE:"playlist:remove",PLAYLIST_INTERSTITIAL:"playlist:interstitial",PLAYLIST_INTERSTITIAL_END:"playlist:interstitial_end"};function a(t,e,n){const i=function(t){return++t.idx,t.members[t.idx]}(e),o=e.idx+e.plays<1;return function(t,e,n){"object"==typeof e&&t.setOpts(Object.assign(Object.assign({},e),{playlist:n}));u(t,{should_play:n.should_play},e)}(t,i,n),o&&n.autoplay?t.togglePlay(!0):o?t.setState("is-starting",!0):!o&&n.advance?function(t,e,n){var i;const o=setTimeout(n,e.delay||0);null!==(i=e.delay)&&void 0!==i&&i&&t.emit(r.PLAYLIST_INTERSTITIAL,{timer:o,config:e})}(t,n,(function(){t.paused&&(t.setState("is-seamless",!0),t.togglePlay(!0))})):void t.emit(r.PLAYLIST_INTERSTITIAL,{config:n})}function u(t,e,n){var i,o;const s=null===(i=t.playlist)||void 0===i?void 0:i.queue;if(s&&(s.idx=s.members.indexOf(n)),n.src&&t.setSrc(n.src),t.emit(r.PLAYLIST_NEXT,n),null!==(o=e.should_play)&&void 0!==o&&o)return t.togglePlay(!0)}function c(t,e){const n=t._customElements.get(e);return n&&t.root.querySelector(n)||void 0}function p(t,e){const n=t.style;return Object.keys(e).forEach(t=>n[t]=e[t]),t}function d(t,e,n){return t.setAttribute(e,n),t}function f(t,e){return t.classList.add(...e.split(" ")),t}function y(t,e,n){return e.split(" ").forEach(e=>t.classList.toggle(e,n)),t}function m(...t){const e=document.createElement("div");return 0==t.length||e.classList.add(...t),e}const h=(t,e)=>new(((t,e)=>{const n=t.get(e);if(!n)throw new Error(`no flowplayer component with the name ${e} exists`);const i=window.customElements.get(e);if(!i)throw new Error(`no default flowplayer component with the name ${e} exists`);const o=window.customElements.get(n);return"function"!=typeof o?i:o})(t._customElements,e))(t),L=(t,e,n)=>{window.customElements.get(e)||window.customElements.define(e,n),t.customElements.get(e)||t.customElements.set(e,e)};function v(t,e){if(!e[t])return;const n=document.createElement("span");n.innerText=e[t];const i=m(t);return i.append(n),i}function w(t){return Math.min(100*t,100)+"%"}function E(t){const e=m("fp-interstitial"),n=c(t,"flowplayer-middle");null==n||n.append(e),t.on(r.PLAYLIST_INTERSTITIAL,(function(i){const s=i.data;t.setState("is-interstitial",!0);const l=t.playlist&&o(t.playlist.queue);if(!l)return;s&&n&&e.append(...function(t,e,n,i){const o=m("left");o.append(h(t,"flowplayer-play-icon")),e.poster&&(o.style.backgroundImage=["url(",e.poster,")"].join(""));const s=m("right"),l=m("up-next"),r=document.createElement("span");r.innerText=t.i18n("playlist.up_next");const a=m("fp-color","countdown");l.append(r,a),s.append(l);const u=v("title",e);u&&s.append(u);const c=v("description",e);if(c&&s.append(c),i.timer){const e=m("cancel");e.onclick=function(t){return i.timer&&clearTimeout(i.timer),i.timer=void 0,t.target.remove(),t.preventDefault(),!1};const n=document.createElement("span");n.innerText=t.i18n("playlist.cancel"),e.append(n),s.append(e)}return[o,s]}(t,l,0,s)),t.once("play",t=>{e.innerHTML=""});t.opt("playlist",{}).advance&&s&&function(t,e,n){var i;if(!n)throw new Error("no element to animate was passed");const o=null!==(i=e.config.delay)&&void 0!==i?i:0,s=Date.now()+o;let l=Date.now();const r=Math.ceil(1e3/60);!function i(){const a=Date.now();if(a>s||!t.paused)return;if(!e.timer)return p(n,{width:w(0)});requestAnimationFrame(i),a-l<r||(l=a,p(n,{width:w(1-(s-a)/o)}))}()}(t,s,e.querySelector(".countdown"))})),t.on(["src","playing","waiting"],(function(){t.emit(r.PLAYLIST_INTERSTITIAL_END)})),t.on(r.PLAYLIST_INTERSTITIAL_END,(function(){t.setState("is-interstitial",!1)}))}const I={translation_key:"core.skip-next",name:"fp-skip-next"},T={translation_key:"core.skip-prev",name:"fp-skip-prev"};class Pipe{constructor(t){this.data=t}static of(t){return new Pipe(t)}static maybe(t,e,...n){return null==t?t:e.apply(t,[t,...n])}tap(t,...e){return t.apply(this,[this.data,...e]),new Pipe(this.data)}fmap(t,...e){const n=t.apply(this,[this.data,...e]);return new Pipe(n)}unwrap(){return this.data}}function x(t){return"invalid playlist configuration\ndetails: "+t+"\n\tmust match Object of shape:\n"+["\t\t{ controls?: Selector|HTMLElement","player: Selector|HTMLElement","playlist: PlaylistId|Array(MediaId|PlayerConfig)","shuffle?: Boolean|false","loop?: Boolean|false","advance?: Boolean|true","delay?: Milliseconds|5000"].join("\n\t\t, ")+"\n\t\t}"}function A(e,n){Pipe.of(e).fmap(x).fmap(t,n)}function b(t){return void 0!==t}function P(t){return"string"==typeof t}function g(t){return"object"==typeof t}function S(t){return t instanceof HTMLElement}function _(t){var e;A("Config must be an Object",b(t)&&g(t)),A("property `playlist` is required",b(t.playlist)),A("property `playlist` was not a String(MediaId)",P(t.playlist)||(e=t.playlist,A("playlist property was not of type PlaylistId|Array(MediaId|PlayConfig)",Array.isArray(e)),A("playlist property cannot be an empty Array",e.length>0),!e.forEach((function(t,e){A("item at playlist["+e+"] was not valid",P(t)||g(t))})))),"loop shuffle".split(" ").forEach((function(e){b(t[e])&&A(e+" must be a boolean value if present","boolean"==typeof t[e])})),b(t.delay)&&A("property `delay` must be a Number (Milliseconds)","number"==typeof t.delay)}function O(t){try{_(t)}catch(t){return!1}return!0}class FlowplayerComponent extends HTMLElement{constructor(t){super(),this.player=t}}class FlowplayerIcon extends FlowplayerComponent{constructor(t,e){super(t),this.classList.add("fp-icon",e.name),e.title&&this.setAttribute("title",e.title),e.title&&this.setAttribute("aria-label",e.title),this.setAttribute("tabindex","0"),this.setAttribute("focusable","true")}}function q(t,e){return{queue:e,events:r,play:function(e){this.queue.idx=e,u(t,{should_play:!0},o(this.queue))},next:function(){this.queue.idx!==this.queue.last_idx&&this.play(this.queue.idx+1)},prev:function(){this.queue.idx&&this.play(this.queue.idx-1)},remove:function(e){const n=this.queue;return n.members[e]?n.idx===e?console.warn("operation failed: you cannot remove current playlist item"):(n.members.splice(e,1),n.last_idx=n.members.length-1,e<n.idx&&--n.idx,void t.emit(r.PLAYLIST_REMOVE,{index:e})):console.warn("there is no playlist item at this index")},push:function(...e){const n=t.root;if(0==this.queue.idx&&n.classList.contains("is-interstitial"))return console.warn("new items cannot be added when playlist has ended.");const i=this.queue.members;i.push(...e),this.queue.last_idx=i.length-1,t.emit(r.PLAYLIST_ADD,{members:e})},clear:function(){this.queue.members=[],this.queue.plays--,function(t,e){t.playlist&&(e=t.playlist.queue=l(e),t.emit(r.PLAYLIST_READY,{queue:e,should_play:!1}))}(t,this.queue)}}}function Y(t,e,n){const i=function(t){return Array.isArray(t)?t.slice(0):t.split(".")}(e);for(;i.length;){if(null==t)return n;const e=i.shift();if("string"!=typeof e)return n;t=t[e]}return null==t?n:t}!function(){let t=!1;try{const e=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("testPassive",null,e),window.removeEventListener("testPassive",null,e)}catch(t){}}();const F=["touchstart","touchmove"];function k(t,e,n){const i=function(t,e){const n=new CustomEvent(t,{detail:e,cancelable:!0});return e&&Object.defineProperty(n,"data",{get:()=>e}),n}(e,n);return t.dispatchEvent(i),t}function N(t,e,n,i){Array.isArray(e)?e.forEach(e=>D(t,e,n,i)):D(t,e,n,i)}function D(t,e,n,i){if(o=e,!~F.indexOf(o))return t.addEventListener(e,n,i),t;var o;const s=Object.assign(i||{},{passive:!0});return t.addEventListener(e,n,s),t}class FlowplayerPlaylistControls extends FlowplayerComponent{constructor(t){super(t),t.on(r.PLAYLIST_READY,e=>{const n=Y(e,"data.queue",Y(t,"playlist.queue"));n&&this.list(n,t)}),t.on(r.PLAYLIST_NEXT,e=>{var n;e.data&&(null===(n=t.playlist)||void 0===n?void 0:n.queue)&&Array.from(this.querySelectorAll("li")).forEach((e,n)=>{var i;n===(null===(i=t.playlist)||void 0===i?void 0:i.queue.idx)?e.className="is-current":e.className="is-queued"})}),t.on(["playing","pause"],t=>{const e=this.querySelector(".is-current");e&&(e.classList.toggle("is-playing","playing"===t.type),e.classList.toggle("is-paused","flowplayer-pause-icon"===t.type))}),t.on(r.PLAYLIST_ADD,e=>{var n;const i=null===(n=t.playlist)||void 0===n?void 0:n.queue;if(!e.data||!i)return;e.data.members.forEach(e=>{const n=this.videoRow(e,t);n&&this.append(n)})}),t.on(r.PLAYLIST_REMOVE,t=>{if(!t.data)return;const e=Array.from(this.querySelectorAll("li"))[t.data.index];e&&this.removeChild(e)})}list(t,e){this.innerHTML="",f(this,"fp-playlist"),t.members.forEach(t=>{const n=this.videoRow(t,e);n&&this.append(n)})}videoRow(t,e){if(!t.title)return;const n=document.createElement("li");var i,o;return n.classList.add("is-queued"),n.onclick=this.videoRow_onclick.bind(this,n,t,e),i=n,o=[m("fp-color"),this.videoInfo(t),this.buttons(t,e)],i.append(...o),n}videoRow_onclick(t,e,n){if(t.classList.contains("is-current"))return n.togglePlay(!n.playerState["is-playing"]);k(this,r.PLAYLIST_SELECTION,{video:e})}videoInfo(t){const e=m("video-info"),n=v("title",t);n&&e.append(n);const i=v("description",t);return i&&e.append(i),e}buttons(t,e){const n=m("video-buttons"),i=h(e,"flowplayer-play-icon"),o=h(e,"flowplayer-pause-icon");return n.append(i,o),t.poster&&(n.style.backgroundImage=["url(",t.poster,")"].join("")),n}}function R(t){const n=h(t,"flowplayer-skip-previous-icon");d(n,"role","button"),N(n,"click",(function(){t.playlist&&t.playlist.prev()}));const o=h(t,"flowplayer-skip-next-icon");d(o,"role","button"),N(o,"click",(function(){t.playlist&&t.playlist.next()}));const s=m("fp-playlist-prev-preview"),l=m("fp-playlist-next-preview"),a=c(t,"flowplayer-control-buttons");return a&&(a.prepend(n),a.append(o),a.append(s),a.append(l)),t.on("reap",(function(){t.skip_controls=void 0})),"flowplayer-skip-previous-icon"===n.localName&&"flowplayer-skip-next-icon"===o.localName&&t.on([r.PLAYLIST_NEXT,r.PLAYLIST_ADD,r.PLAYLIST_REMOVE],(function(n){const o=Y(n,"data.queue",Y(t,"playlist.queue"));if(!o)return;a&&(y(a,"is-prev-button-disabled",!o.idx),y(a,"is-next-button-disabled",o.idx===o.last_idx));const r=o.idx<o.last_idx?function(t){if(!i(t)||0!=(t.mode&e.LOOP))return t.members[function(t){const e=t.idx+1;return e>t.last_idx?0:e}(t)]}(o):null,u=o.idx>0?function(t){if(0!==t.idx||0!=(t.mode&e.LOOP))return t.members[function(t){const e=t.idx-1;return e<0?t.last_idx:e}(t)]}(o):null;l.style.backgroundImage=["url(",r?r.poster:null,")"].join(""),s.style.backgroundImage=["url(",u?u.poster:null,")"].join("")})),{prevButton:n,nextButton:o,prevPreview:s,nextPreview:l}}class Playlist{constructor(t){L(t,"flowplayer-playlist-controls",FlowplayerPlaylistControls),L(t,"flowplayer-skip-next-icon",class extends FlowplayerIcon{constructor(t){super(t,I)}}),L(t,"flowplayer-skip-previous-icon",class extends FlowplayerIcon{constructor(t){super(t,T)}})}init(e,n,o){const s=e.playlist||{};s.delay="number"==typeof s.delay?1e3*s.delay:1e4,o.setOpts(Object.assign(Object.assign({},e),{playlist:s})),function(e,n){if(!n)return;n.skip_controls&&(e.skip_controls=R(e));const i=function(e){let n=null;if(i=e.controls,!P(i)&&!S(i))return;var i;S(e.controls)?n=e.controls:P(e.controls)&&(n=document.querySelector(e.controls));return t("Could not find controls by Selector["+e.controls+"]",S(n)),n}(n);if(!i)return;const o=h(e,"flowplayer-playlist-controls");if(i.append(o),o.addEventListener(r.PLAYLIST_SELECTION,t=>{var n;const i=null===(n=t.detail)||void 0===n?void 0:n.video;i&&u(e,{should_play:!0},i)}),!(o instanceof FlowplayerPlaylistControls))return;const s=e.opt("playlist",{});f(i,"fp-playlist-controls "+(s.theme||"fp-dark"));const l=e.root.className.split(" ").filter((function(t){return t.match(/^use-play/)})).pop();l&&f(i,l)}(o,e.playlist),E(o),function(t){t.on(r.PLAYLIST_READY,(function(e){var n,i;const o=t.opt("playlist",{}),s=null===(n=e.data)||void 0===n?void 0:n.queue,l=null===(i=e.data)||void 0===i?void 0:i.should_play;s&&o&&(t.playlist=q(t,s),l&&a(t,s,o))})),t.on("ended",(function(e){setTimeout((function(){const n=t.opt("playlist");if(!e.defaultPrevented&&t.playlist&&n)return i(t.playlist.queue)?function(t,e){if(t.emit(r.PLAYLIST_ENDED),!e.loop)return;if(!t.playlist)return;const n=t.playlist.queue=l(t.playlist.queue);t.emit(r.PLAYLIST_LOOP),a(t,n,e)}(t,n):void(0!=n.advance&&a(t,t.playlist.queue,n))}),0)}))}(o)}onload(t,i,o,s){!function(t,i,o){if(Array.isArray(i))return o(function(t,i){let o=i.shuffle?e.SHUFFLE:e.FIFO;return i.loop&&(o|=e.LOOP),n(t,{mode:o,sort:i.sort})}(i,t));throw new Error("config.playlist must be an Array")}(t.playlist||{},s.items,(function(t){o.setState("is-playlist",!0),o.emit(r.PLAYLIST_READY,{queue:t,should_play:0===o.currentSrc.length})}))}wants(t,e,n){return"flowplayer/playlist"==e.type&&!!e.items&&O(Object.assign(Object.assign({},n),{playlist:e.items}))}}return Playlist.events=r,function(t,e){if("object"==typeof exports&&"undefined"!=typeof module)return e;"flowplayer"in t||(t.flowplayer={extensions:[]});const n=t.flowplayer;"function"==typeof n?n(e):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(e)||n.extensions.push(e))}(window,Playlist),Playlist}));
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.playlist=e())}(this,(function(){"use strict";var t={PLAYLIST_NEXT:"playlist:next",PLAYLIST_PREVIOUS:"playlist:previous",PLAYLIST_SELECTION:"playlist:selection",PLAYLIST_LOOP:"playlist:loop",PLAYLIST_ENDED:"playlist:ended",PLAYLIST_READY:"playlist:ready",PLAYLIST_ADD:"playlist:add",PLAYLIST_REMOVE:"playlist:remove",INTERSTITIAL_END:"interstitial/end",INTERSTITIAL_CANCEL:"interstitial/cancel",INTERSTITIAL_NEXT_ITEM:"interstitial/next_item"};const e={translation_key:"core.skip-next",name:"fp-skip-next"},n={translation_key:"core.skip-prev",name:"fp-skip-prev"};class Pipe{constructor(t){this.data=t}static of(t){return new Pipe(t)}static maybe(t,e,...n){return null==t?t:e.apply(t,[t,...n])}tap(t,...e){return t.apply(this,[this.data,...e]),new Pipe(this.data)}fmap(t,...e){const n=t.apply(this,[this.data,...e]);return new Pipe(n)}unwrap(){return this.data}}function i(t,e){if(!e)throw new Error(t)}function s(t){return"invalid playlist configuration\ndetails: "+t+"\n\tmust match Object of shape:\n"+["\t\t{ controls?: Selector|HTMLElement","player: Selector|HTMLElement","playlist: PlaylistId|Array(MediaId|PlayerConfig)","shuffle?: Boolean|false","loop?: Boolean|false","advance?: Boolean|true","delay?: Milliseconds|5000"].join("\n\t\t, ")+"\n\t\t}"}function o(t,e){Pipe.of(t).fmap(s).fmap(i,e)}function l(t){return void 0!==t}function r(t){return"string"==typeof t}function a(t){return"object"==typeof t}function c(t){return t instanceof HTMLElement}function u(t){var e;o("Config must be an Object",l(t)&&a(t)),o("property `playlist` is required",l(t.playlist)),o("property `playlist` was not a String(MediaId)",r(t.playlist)||(e=t.playlist,o("playlist property was not of type PlaylistId|Array(MediaId|PlayConfig)",Array.isArray(e)),o("playlist property cannot be an empty Array",e.length>0),!e.forEach((function(t,e){o("item at playlist["+e+"] was not valid",r(t)||a(t))})))),"loop shuffle".split(" ").forEach((function(e){l(t[e])&&o(e+" must be a boolean value if present","boolean"==typeof t[e])})),l(t.delay)&&o("property `delay` must be a Number (Milliseconds)","number"==typeof t.delay)}function p(t){try{u(t)}catch(t){return!1}return!0}class FlowplayerComponent extends HTMLElement{constructor(t){super(),this.player=t}}class FlowplayerIcon extends FlowplayerComponent{constructor(t,e){super(t),this.classList.add("fp-icon",e.name),e.title&&this.setAttribute("title",e.title),e.title&&this.setAttribute("aria-label",e.title),this.setAttribute("tabindex","0"),this.setAttribute("focusable","true")}}const d=["title","delay","description","poster","src"];class UpNext extends FlowplayerComponent{static get observedAttributes(){return d}constructor(e){super(e),this.classList.add("up-next"),this.addEventListener("animationend",()=>{this.dispatchEvent(new CustomEvent(t.INTERSTITIAL_END))}),this.addEventListener("animationcancel",()=>{this.classList.add("cancelled"),this.dispatchEvent(new CustomEvent(t.INTERSTITIAL_CANCEL))}),this.addEventListener(t.INTERSTITIAL_NEXT_ITEM,this._setUpNext.bind(this))}getTitle(){return this.getAttribute("title")||""}getDescription(){return this.getAttribute("description")||""}getPoster(){return this.getAttribute("poster")||""}getDelay(){return this.getAttribute("delay")||""}connectedCallback(){this.isConnected&&this._render()}attributeChangedCallback(){this._render()}_render(){var e,n;this.innerHTML="",this.classList.remove("cancelled");const i=document.createDocumentFragment(),s=document.createElement("div");s.classList.add("pane","left");const o=document.createElement("div");o.classList.add("pane","right"),i.append(s,o);const l=document.createElement("div");l.classList.add("poster"),l.style.backgroundImage="url("+this.getPoster()+")",s.append(l),l.addEventListener("click",()=>this.dispatchEvent(new CustomEvent(t.INTERSTITIAL_END)));const r=document.createElement("span");r.classList.add("fp-icon","fp-play"),l.append(r);const a=document.createElement("span");a.classList.add("title"),a.textContent=this.getTitle();const c=document.createElement("span");c.classList.add("description"),c.textContent=this.getDescription();const u=document.createElement("span");u.classList.add("countdown"),this.getDelay()&&(u.style.setProperty("--up-next-delay",this.getDelay()+"s"),u.classList.add("go"));const p=document.createElement("span");p.classList.add("cancel"),p.textContent=null!==(n=null===(e=this.player)||void 0===e?void 0:e.i18n("playlist.cancel"))&&void 0!==n?n:"cancel",p.addEventListener("click",()=>u.classList.remove("go")),o.append(a,c,p,u),this.append(i)}_setUpNext(t){var e,n,i;const s=t.detail.next,o=this.player.opt("playlist.delay",void 0)||10;this.setAttribute("title",null!==(e=s.title)&&void 0!==e?e:""),this.setAttribute("description",null!==(n=s.description)&&void 0!==n?n:""),this.setAttribute("poster",null!==(i=s.poster)&&void 0!==i?i:""),this.setAttribute("delay",o+"")}}const y=(t,e)=>new(((t,e)=>{const n=t.get(e);if(!n)throw new Error(`no flowplayer component with the name ${e} exists`);const i=window.customElements.get(e);if(!i)throw new Error(`no default flowplayer component with the name ${e} exists`);const s=window.customElements.get(n);return"function"!=typeof s?i:s})(t._customElements,e))(t),f=(t,e,n)=>{window.customElements.get(e)||window.customElements.define(e,n),t.customElements.get(e)||t.customElements.set(e,e)};function m(t,e){const n=t._customElements.get(e);return n&&t.root.querySelector(n)||void 0}function h(t,e,n){return t.setAttribute(e,n),t}function v(t,e){return t.classList.add(...e.split(" ")),t}function L(t,e,n){return e.split(" ").forEach(e=>t.classList.toggle(e,n)),t}function E(...t){const e=document.createElement("div");return 0==t.length||e.classList.add(...t),e}function w(t,e,n){const i=function(t){return Array.isArray(t)?t.slice(0):t.split(".")}(e);for(;i.length;){if(null==t)return n;const e=i.shift();if("string"!=typeof e)return n;t=t[e]}return null==t?n:t}function b(t,e){if(!e[t])return;const n=document.createElement("span");n.innerText=e[t];const i=E(t);return i.append(n),i}class FlowplayerPlaylistControls extends FlowplayerComponent{constructor(e){super(e),e.on(t.PLAYLIST_READY,t=>{const n=w(t,"data.queue",w(e,"playlist.queue"));n&&this.list(n,e)}),e.on(t.PLAYLIST_NEXT,()=>{var t;(null===(t=e.playlist)||void 0===t?void 0:t.queue)&&Array.from(this.querySelectorAll("li")).forEach((t,n)=>{var i;n===(null===(i=e.playlist)||void 0===i?void 0:i.queue.idx)?t.className="is-current":t.className="is-queued"})}),e.on(["playing","pause"],t=>{const e=this.querySelector(".is-current");e&&(e.classList.toggle("is-playing","playing"===t.type),e.classList.toggle("is-paused","flowplayer-pause-icon"===t.type))}),e.on(t.PLAYLIST_ADD,t=>{var n;const i=null===(n=e.playlist)||void 0===n?void 0:n.queue;if(!t.data||!i)return;t.data.members.forEach(t=>{const n=this.videoRow(t,e);n&&this.append(n)})}),e.on(t.PLAYLIST_REMOVE,t=>{if(!t.data)return;const e=Array.from(this.querySelectorAll("li"))[t.data.index];e&&this.removeChild(e)})}list(t,e){this.innerHTML="",v(this,"fp-playlist"),t.members.forEach(t=>{const n=this.videoRow(t,e);n&&this.append(n)})}videoRow(t,e){if(!t.title)return;const n=document.createElement("li");var i,s;return n.classList.add("is-queued"),n.onclick=this.videoRow_onclick.bind(this,n,t,e),i=n,s=[E("fp-color"),this.videoInfo(t),this.buttons(t,e)],i.append(...s),n}videoRow_onclick(t,e,n){var i;if(t.classList.contains("is-current"))return n.togglePlay(!n.playerState["is-playing"]);const s=Array.from(this.querySelectorAll("li")).indexOf(t);-1!==s&&(null===(i=n.playlist)||void 0===i||i.play(s))}videoInfo(t){const e=E("video-info"),n=b("title",t);n&&e.append(n);const i=b("description",t);return i&&e.append(i),e}buttons(t,e){const n=E("video-buttons"),i=y(e,"flowplayer-play-icon"),s=y(e,"flowplayer-pause-icon");return n.append(i,s),t.poster&&(n.style.backgroundImage=["url(",t.poster,")"].join("")),n}}var g;function x(t,e){var n,i;const s=e.sort||I,o=null!==(n=e.mode)&&void 0!==n?n:g.FIFO;return t=s(t.slice(0),o),{mode:o,sort:s,members:t,last_idx:t.length-1,plays:null!==(i=e.plays)&&void 0!==i?i:0,idx:-1}}function A(t){return t.idx==t.last_idx}function I(t,e){return(e&g.SHUFFLE)==g.SHUFFLE?t.sort((function(){return Math.random()-Math.random()})):t.slice(0)}function T(t){return x(t.members,{mode:t.mode,plays:t.plays+1,sort:t.sort})}!function(t){t[t.SHUFFLE=1]="SHUFFLE",t[t.FIFO=2]="FIFO",t[t.LOOP=4]="LOOP"}(g||(g={}));!function(){let t=!1;try{const e=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("testPassive",null,e),window.removeEventListener("testPassive",null,e)}catch(t){}}();const _=["touchstart","touchmove"];function P(t,e,n){const i=function(t,e){const n=new CustomEvent(t,{detail:e,cancelable:!0});return e&&Object.defineProperty(n,"data",{get:()=>e}),n}(e,n);return t.dispatchEvent(i),t}function S(t,e,n,i){Array.isArray(e)?e.forEach(e=>q(t,e,n,i)):q(t,e,n,i)}function q(t,e,n,i){if(s=e,!~_.indexOf(s))return t.addEventListener(e,n,i),t;var s;const o=Object.assign(i||{},{passive:!0});return t.addEventListener(e,n,o),t}function O(e,n,i){const s=function(t){return++t.idx,t.members[t.idx]}(n),o=n.idx+n.plays<1;return function(t,e,n){"object"==typeof e&&t.setOpts(Object.assign(Object.assign({},e),{playlist:n}));N(t,{should_play:n.should_play})}(e,s,i),o&&i.autoplay?e.togglePlay(!0):o?e.setState("is-starting",!0):i.delay?void function(e,n){var i;const s=m(e,"flowplayer-playlist-interstitial");if(!s||!(null===(i=e.playlist)||void 0===i?void 0:i.queue)||!n.delay)return;e.root.classList.add("is-interstitial");const o=function(t){return-1==t.idx?t.members[0]:t.members[t.idx]}(e.playlist.queue);P(s,t.INTERSTITIAL_NEXT_ITEM,{next:o})}(e,i):e.togglePlay(!0)}function N(e,n){var i,s;const o=null===(i=e.playlist)||void 0===i?void 0:i.queue;if(!o)return;const l=o.idx,r=o.members[l];return r.src&&e.setSrc(r.src),e.emit(t.PLAYLIST_NEXT,{next_index:l}),null!==(s=n.should_play)&&void 0!==s&&s?e.togglePlay(!0):void 0}function C(e,n){return{queue:n,events:t,play:function(t){t<0||t>=n.members.length||(this.queue.idx=t,N(e,{should_play:!0}))},next:function(){this.queue.idx!==this.queue.last_idx&&this.play(this.queue.idx+1)},prev:function(){this.queue.idx&&this.play(this.queue.idx-1)},remove:function(n){const i=this.queue;return i.members[n]?i.idx===n?console.warn("operation failed: you cannot remove current playlist item"):(i.members.splice(n,1),i.last_idx=i.members.length-1,n<i.idx&&--i.idx,void e.emit(t.PLAYLIST_REMOVE,{index:n})):console.warn("there is no playlist item at this index")},push:function(...n){const i=e.root;if(0==this.queue.idx&&i.classList.contains("is-interstitial"))return console.warn("new items cannot be added when playlist has ended.");const s=this.queue.members;s.push(...n),this.queue.last_idx=s.length-1,e.emit(t.PLAYLIST_ADD,{members:n})},clear:function(){this.queue.members=[],this.queue.plays--,function(e,n){e.playlist&&(n=e.playlist.queue=T(n),e.emit(t.PLAYLIST_READY,{queue:n,should_play:!1}))}(e,this.queue)}}}function k(e){const n=y(e,"flowplayer-skip-previous-icon");h(n,"role","button"),S(n,"click",(function(){e.playlist&&e.playlist.prev()}));const i=y(e,"flowplayer-skip-next-icon");h(i,"role","button"),S(i,"click",(function(){e.playlist&&e.playlist.next()}));const s=E("fp-playlist-prev-preview"),o=E("fp-playlist-next-preview"),l=m(e,"flowplayer-control-buttons");return l&&(l.prepend(n),l.append(i),l.append(s),l.append(o)),e.on("reap",(function(){e.skip_controls=void 0})),e.on([t.PLAYLIST_NEXT,t.PLAYLIST_ADD,t.PLAYLIST_REMOVE],(function(t){const n=w(t,"data.queue",w(e,"playlist.queue"));if(!n||!l||!e.skip_controls)return;L(l,"is-prev-button-disabled",!n.idx),L(l,"is-next-button-disabled",n.idx===n.last_idx);const i=n.idx<n.last_idx?function(t){if(!A(t)||0!=(t.mode&g.LOOP))return t.members[function(t){const e=t.idx+1;return e>t.last_idx?0:e}(t)]}(n):null,r=n.idx>0?function(t){if(0!==t.idx||0!=(t.mode&g.LOOP))return t.members[function(t){const e=t.idx-1;return e<0?t.last_idx:e}(t)]}(n):null;o.style.backgroundImage=["url(",i?i.poster:null,")"].join(""),s.style.backgroundImage=["url(",r?r.poster:null,")"].join("")})),{prevButton:n,nextButton:i,prevPreview:s,nextPreview:o}}function F(t,e){if(!e)return;e.skip_controls&&(t.skip_controls=k(t));const n=function(t){let e=null;if(n=t.controls,!r(n)&&!c(n))return;var n;c(t.controls)?e=t.controls:r(t.controls)&&(e=document.querySelector(t.controls));return i("Could not find controls by Selector["+t.controls+"]",c(e)),e}(e);if(!n)return;const s=y(t,"flowplayer-playlist-controls");if(n.append(s),!(s instanceof FlowplayerPlaylistControls))return;v(n,"fp-playlist-controls "+(t.opt("playlist",{}).theme||"fp-dark"));const o=t.root.className.split(" ").filter((function(t){return t.match(/^use-play/)})).pop();o&&v(n,o)}function Y(t,e,n){if(Array.isArray(e))return n(function(t,e){let n=e.shuffle?g.SHUFFLE:g.FIFO;return e.loop&&(n|=g.LOOP),x(t,{mode:n,sort:e.sort})}(e,t));throw new Error("config.playlist must be an Array")}function D(e){var n;e.on(t.PLAYLIST_READY,(function(t){var n,i;const s=e.opt("playlist",{}),o=null===(n=t.detail)||void 0===n?void 0:n.queue,l=null===(i=t.detail)||void 0===i?void 0:i.should_play;o&&s&&(e.playlist=C(e,o),l&&O(e,o,s))})),e.on("ended",(n=n=>{if(n.prevented_from_ads)return;const i=e.opt("playlist");return e.playlist&&i?A(e.playlist.queue)?function(e,n){if(e.emit(t.PLAYLIST_ENDED),!n.loop)return;if(!e.playlist)return;const i=e.playlist.queue=T(e.playlist.queue);e.emit(t.PLAYLIST_LOOP),O(e,i,n)}(e,i):void(i.advance&&O(e,e.playlist.queue,i)):void 0},t=>{setTimeout((function(){if(!t.defaultPrevented)return n(t)}),0)})),e.on(["playing","waiting","seeking"],(function(){if(!e.root.classList.contains("is-interstitial"))return;const n=m(e,"flowplayer-playlist-interstitial");n&&P(n,t.INTERSTITIAL_CANCEL)}))}class Playlist{constructor(t){f(t,"flowplayer-playlist-controls",FlowplayerPlaylistControls),f(t,"flowplayer-playlist-interstitial",class extends UpNext{constructor(t){super(t),this.classList.add("fp-interstitial")}}),f(t,"flowplayer-skip-next-icon",class extends FlowplayerIcon{constructor(t){super(t,e)}}),f(t,"flowplayer-skip-previous-icon",class extends FlowplayerIcon{constructor(t){super(t,n)}})}init(e,n,i){const s=e.playlist||{};s.delay="number"==typeof s.delay?s.delay:0,i.setOpts(Object.assign(Object.assign({},e),{playlist:s})),F(i,e.playlist),function(e){var n;const i=y(e,"flowplayer-playlist-interstitial");i.addEventListener(t.INTERSTITIAL_CANCEL,()=>e.root.classList.remove("is-interstitial")),i.addEventListener(t.INTERSTITIAL_END,()=>{e.root.classList.remove("is-interstitial"),e.togglePlay(!0)}),null===(n=m(e,"flowplayer-ui"))||void 0===n||n.prepend(i)}(i),D(i)}onload(e,n,i,s){Y(e.playlist||{},s.items,(function(e){i.setState("is-playlist",!0),i.emit(t.PLAYLIST_READY,{queue:e,should_play:0===i.currentSrc.length})}))}wants(t,e,n){return"flowplayer/playlist"==e.type&&!!e.items&&p(Object.assign(Object.assign({},n),{playlist:e.items}))}}return Playlist.events=t,function(t,e){if("object"==typeof exports&&"undefined"!=typeof module)return e;"flowplayer"in t||(t.flowplayer={extensions:[]});const n=t.flowplayer;"function"==typeof n?n(e):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(e)||n.extensions.push(e))}(window,Playlist),Playlist}));