@flowplayer/player 3.4.1 → 3.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core.js +1 -1
- package/default.js +1 -1
- package/embed.js +27 -27
- package/package.json +1 -1
- package/plugins/ads.js +2 -2
- package/plugins/airplay.js +1 -1
- package/plugins/analytics.js +1 -1
- package/plugins/asel.js +1 -1
- package/plugins/float-on-scroll.js +1 -1
- package/plugins/health.js +1 -1
- package/plugins/hls.js +1 -1
- package/plugins/ovp.js +1 -1
- package/plugins/playlist.js +1 -1
- package/plugins/qsel.js +1 -1
- package/plugins/share.js +1 -1
- package/plugins/speed.js +1 -1
- package/plugins/subtitles.js +1 -1
package/plugins/analytics.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.analytics=t())}(this,(function(){"use strict";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="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};var b="ping",A="display",O="view";const T=["sitegroup_id","session_id","media_id","site_id","player_id","video_type"],S=["created","position"],M=["player_version","created","source","category","category_id","autoplay","muted","customer_user_id"];function P(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 R(e,t,n){if(!t.segment_duration&&!P(e,t))return;const r=function(e,t,n){const r=t.last_idx,i=n?99:x(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(b,{position:r})}function x(e,t){return Math.min(Math.floor(e.currentTime/t.segment_duration),99)}const N="vod",I="live",L=[A,b,O];function j(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(b,{position:60*t.ticks}))}(e,t);case"vod":return R(e,t,"boolean"==typeof n&&n)}}function q(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 U(){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:()=>{j(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.4.1"},a=c.Tracker.of(n,{verb:c.Tracker.verb.POST,url:"https://ptm.flowplayer.com/:video_type/:sitegroup_id/:event_type",events:L,required_keys:T,optional_keys:M.concat(S).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)?I:N;a.put({video_type:s,source:e.source||U()||""}),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(A)}));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=q(n);if(e)return u=Promise.resolve(e).then((function(){r.last_media_id=a.metadata.media_id,n.emit(O),u=0})).catch((function(){u=0}));r.last_media_id=a.metadata.media_id,n.emit(O)})),n.on("timeupdate",(function(){var t;a&&(u||q(n)||r.ended||(!e.live&&n.currentTime+.25>=n.duration&&j(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){P(e,t),t.last_idx=x(e,t)}(n,r.ticker)})),n.on("ended",(function(){a&&function(e,t){t.ended||(t.ended=!0,j(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:void 0!==E?E:{},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="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};var b="ping",A="display",O="view";const T=["sitegroup_id","session_id","media_id","site_id","player_id","video_type"],S=["created","position"],M=["player_version","created","source","category","category_id","autoplay","muted","customer_user_id"];function P(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 R(e,t,n){if(!t.segment_duration&&!P(e,t))return;const r=function(e,t,n){const r=t.last_idx,i=n?99:x(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(b,{position:r})}function x(e,t){return Math.min(Math.floor(e.currentTime/t.segment_duration),99)}const N="vod",I="live",L=[A,b,O];function j(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(b,{position:60*t.ticks}))}(e,t);case"vod":return R(e,t,"boolean"==typeof n&&n)}}function q(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 U(){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:()=>{j(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.4.2"},a=c.Tracker.of(n,{verb:c.Tracker.verb.POST,url:"https://ptm.flowplayer.com/:video_type/:sitegroup_id/:event_type",events:L,required_keys:T,optional_keys:M.concat(S).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)?I:N;a.put({video_type:s,source:e.source||U()||""}),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(A)}));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=q(n);if(e)return u=Promise.resolve(e).then((function(){r.last_media_id=a.metadata.media_id,n.emit(O),u=0})).catch((function(){u=0}));r.last_media_id=a.metadata.media_id,n.emit(O)})),n.on("timeupdate",(function(){var t;a&&(u||q(n)||r.ended||(!e.live&&n.currentTime+.25>=n.duration&&j(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){P(e,t),t.last_idx=x(e,t)}(n,r.ticker)})),n.on("ended",(function(){a&&function(e,t){t.ended||(t.ended=!0,j(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:void 0!==E?E:{},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
|
|
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 i(e){return e.toLowerCase()}function o(e,s,o){s=s.slice(0);const a={},l=e.getItem("@flowplayer/audio/track");let r=function(){try{return n.reduce((e,t)=>~t.indexOf("-")?e.concat(t,t.split("-")[0]):e.concat(t),[])}catch(e){return[]}}().map(i),c=-1;if("number"==typeof o)return o;for("string"==typeof o&&(o=o.toLowerCase(),~r.indexOf(o)&&r.splice(r.indexOf(o),1),r.unshift(i(o))),Array.isArray(o)&&(r=o.map(i));s.length;){++c;const e=s.shift();if(null==e?void 0:e.autoselect){if(l==e.lang)return console.debug("restoring lang from previous session: ",l),c;if(e.default&&(a.fallback=[c,e]),e.lang&&~r.indexOf(e.lang.toLowerCase())){const n=r.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 i=window.customElements.get(n);return"function"!=typeof i?s:i})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}const l="fp-on",r="fp-invis";class FlowplayerMenu extends FlowplayerComponent{constructor(e){super(e),this.player=e,this.menuContainer=document.createElement("details"),this.summaryEle=document.createElement("summary"),this.olEle=document.createElement("ol"),this.olEle.id=u(),this.menu=document.createElement("div"),this.closeEle=document.createElement("span"),this.menu.classList.add("fp-menu"),this.menu.append(this.closeEle,this.olEle),this.closeEle.classList.add("fp-close"),this.closeEle.textContent="×",this.menuContainer.append(this.summaryEle,this.menu),this.menuContainer.addEventListener("click",t=>{t.preventDefault();const n=this.menuContainer.open;n||(c(),document.active_menu=this.menuContainer),this.menuContainer.open=!n,e.root.classList.toggle("has-menu-opened",!n),this.olEle.setAttribute("aria-expanded",n?"false":"true")}),this.append(this.menuContainer),this.summaryEle.setAttribute("aria-haspopup","true"),this.summaryEle.setAttribute("aria-controls",this.olEle.id),this.summaryEle.setAttribute("tabindex","0"),this.summaryEle.setAttribute("role","button")}get options(){return this.olEle.querySelectorAll("li")}setMenuAttrs(e){if(this.summaryEle.id||(this.summaryEle.id=e.id||u()),this.className=`${e.class} ${r}`,this.menuContainer.classList.add("fp-menu-container"),this.olEle.setAttribute("aria-labelledby",this.summaryEle.id),this.olEle.setAttribute("role","menu"),this.summaryEle.setAttribute("aria-label",e.menuTitle||"Menu"),e.summaryTitle&&(this.summaryEle.textContent=e.summaryTitle),e.summaryIcon){const t=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(r,!(null==e?void 0:e.length)))}menuOption(e,t){const n=document.createElement("li");n.setAttribute("role","menuitem"),n.setAttribute("tabindex","0"),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(l,n===e&&("flowplayer-subtitles-menu"!==this.localName||!t.classList.contains(l)))})}unselect_item(){this.options.forEach(e=>{e.classList.remove(l)})}}function c(){Array.from(document.querySelectorAll(".fp-engine")).forEach(e=>{var t;const n=e.root.querySelector("details[open].fp-menu-container");n&&(n.open=!1,null===(t=n.querySelector("summary"))||void 0===t||t.removeAttribute("aria-expanded"),e.root.classList.toggle("has-menu-opened",!1))})}function u(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function d(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,i,l){if(!1===n.asel)return;let c=[];const u=a(l,"flowplayer-audio-menu");u instanceof FlowplayerMenu&&u.setMenuAttrs({summaryTitle:l.i18n("audio.button_txt"),menuTitle:l.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}(l);l.asel=m,l.on("mount",(function(){var e;null===(e=function(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}(l,"flowplayer-control"))||void 0===e||e.append(u)})),l.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 i=t(n,"asel.sort");"function"==typeof i&&m.tracks.sort(i),d(u,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,l,n)}}));const a=m.tracks.filter((function(e){return e.enabled}))[0];a&&d(u,Asel.events.SWITCH,{selected_index:m.tracks.indexOf(a)});const f=o(l._storage,m.tracks,t(n,"asel.default_lang",!1));return u instanceof FlowplayerMenu&&u.classList.toggle(r,e.data.length<2),void 0!==f?m.set(f):void 0})),l.on(e.SWITCH,(function(e){l.asel.tracks.find((t,n)=>{var s,i;t!==e.detail&&t.id!==(null!==(i=null===(s=e.detail)||void 0===s?void 0:s.id)&&void 0!==i?i:-1)||(l.asel.active_track=t,d(u,Asel.events.SWITCH,{selected_index:n}))})})),l.audioTracks&&(l.audioTracks.addEventListener("addtrack",(function(){l.hls||l.emit(e.TRACKS,Array.from(l.audioTracks))})),l.on(e.SET,(function(e){l.hls||Array.from(l.audioTracks).forEach((t,n)=>{var s;t.enabled=(null===(s=e.data)||void 0===s?void 0:s.id)===t.id,t.enabled&&d(u,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.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 n=(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),o=(e,t,n)=>{window.customElements.get(t)||window.customElements.define(t,n),e.customElements.get(t)||e.customElements.set(t,t)};function i(e){return function(e){const t=e.getBoundingClientRect(),n=window.innerHeight,o=t.y;return o>n||o+t.height<0?0:t.y<0?(t.height+o)/t.height:n-t.y>t.height?1:Math.abs((n-t.y)/t.height)}(e)>.8}function s(t,n,o){0!=o.reaper&&o.floating&&r(o,n,e)}function r(t,n,o){o&&t.emit(o),setTimeout((function(){const i=n.querySelector(".fp-float-wrapper"),s=n.clientWidth/n.clientHeight;if(!i)return;i.style.height=o===e?"auto":i.clientWidth/s+"px";const r=i.querySelector(".fp-ad-container > div");r&&(r.style.position=o==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 l={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,o(this.flowplayer,"flowplayer-mute-icon",class extends FlowplayerIcon{constructor(e){super(e,l)}}),o(this.flowplayer,"flowplayer-unmute-icon",class extends FlowplayerIcon{constructor(e){super(e,a)}}),o(this.flowplayer,"flowplayer-close-icon",class extends FlowplayerIcon{constructor(e){super(e,c)}})}init(t,o,l){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.autopause&&l.setOpts({autopause:!1});const a={pop_out_container:void 0,was_user_toggled:!1};l.on("mount",(function(){a.pop_out_container=function(e,t){const n=document.createElement("div");return n.classList.add("fp-float-wrapper"),e.appendChild(n),Array.from(e.childNodes).forEach((function(e){e instanceof Element&&(e===n||e.classList.contains("fp-ratio"))||n.appendChild(e)})),t.getFullsceenTarget=()=>n,n}(o,l)})),l.on("renderplugin",(function(e){var t;e.preventDefault(),e.detail&&(null===(t=a.pop_out_container)||void 0===t||t.append(e.detail))}));const c=function(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}(l,"flowplayer-header");c&&function(e,t,o,i){const r=document.createElement("div");r.classList.add("fp-exit-float"),r.append(Object.assign(n(i,"flowplayer-close-icon"),{role:"button"}));const l=()=>{t.was_user_toggled=!0,i.togglePlay(!1),s(0,o,i)};r.addEventListener("click",l),e.append(r),setTimeout(()=>{const e=o.querySelector(".fp-ad-controls");if(!e)return;const t=r.cloneNode(!0);e.append(t),t.addEventListener("click",l)},0);const a=document.createElement("div");a.classList.add("fp-mute-float"),a.append(...Object.assign([n(i,"flowplayer-mute-icon"),n(i,"flowplayer-unmute-icon")],{role:"button"})),a.addEventListener("click",(function(){i.toggleMute()})),e.append(a)}(c,a,o,l);const u=function(e,t){const n=e||60,o=Math.ceil(1e3/n);let i=Date.now(),s=-1;return function(...e){return s>-1||Date.now()<i||(s=requestAnimationFrame((function(){s=-1,t(),i=Date.now()+o}))),s}}(0,(function(){if(i(o)){if(l.hasState("is-fullscreen"))return;s(0,o,l)}})),p=function(){r(l,o)};l.on("viewleave",e=>{(function(e){return!e.paused||!(!e.ads||!e.ads.adPlaying)})(l)&&!a.was_user_toggled&&(e.preventDefault(),function(e,t,n){0==n.reaper||n.floating||r(n,t,"float:pop:out")}(0,o,l))}),l.on("viewenter",(function(){a.was_user_toggled=!1})),l.on("float:pop:out",(function(){window.addEventListener("scroll",u),l.floating=!0,l.setState("is-popped-out",!0),window.addEventListener("resize",p)})),l.on(e,(function(){window.removeEventListener("scroll",u),l.floating=!1,l.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 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,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 n=(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),o=(e,t,n)=>{window.customElements.get(t)||window.customElements.define(t,n),e.customElements.get(t)||e.customElements.set(t,t)};function i(e){return function(e){const t=e.getBoundingClientRect(),n=window.innerHeight,o=t.y;return o>n||o+t.height<0?0:t.y<0?(t.height+o)/t.height:n-t.y>t.height?1:Math.abs((n-t.y)/t.height)}(e)>.8}function s(t,n,o){0!=o.reaper&&o.floating&&r(o,n,e)}function r(t,n,o){o&&t.emit(o),setTimeout((function(){const i=n.querySelector(".fp-float-wrapper"),s=n.clientWidth/n.clientHeight;if(!i)return;i.style.height=o===e?"auto":i.clientWidth/s+"px";const r=i.querySelector(".fp-ad-container > div");r&&(r.style.position=o==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),t.translation_key&&this.setAttribute("aria-label",e.i18n(t.translation_key)),this.setAttribute("tabindex","0"),this.setAttribute("focusable","true")}}const l={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,o(this.flowplayer,"flowplayer-mute-icon",class extends FlowplayerIcon{constructor(e){super(e,l)}}),o(this.flowplayer,"flowplayer-unmute-icon",class extends FlowplayerIcon{constructor(e){super(e,a)}}),o(this.flowplayer,"flowplayer-close-icon",class extends FlowplayerIcon{constructor(e){super(e,c)}})}init(t,o,l){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.autopause&&l.setOpts({autopause:!1});const a={pop_out_container:void 0,was_user_toggled:!1};l.on("mount",(function(){a.pop_out_container=function(e,t){const n=document.createElement("div");return n.classList.add("fp-float-wrapper"),e.appendChild(n),Array.from(e.childNodes).forEach((function(e){e instanceof Element&&(e===n||e.classList.contains("fp-ratio"))||n.appendChild(e)})),t.getFullsceenTarget=()=>n,n}(o,l)})),l.on("renderplugin",(function(e){var t;e.preventDefault(),e.detail&&(null===(t=a.pop_out_container)||void 0===t||t.append(e.detail))}));const c=function(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}(l,"flowplayer-header");c&&function(e,t,o,i){const r=document.createElement("div");r.classList.add("fp-exit-float"),r.append(Object.assign(n(i,"flowplayer-close-icon"),{role:"button"}));const l=()=>{t.was_user_toggled=!0,i.togglePlay(!1),s(0,o,i)};r.addEventListener("click",l),e.append(r),setTimeout(()=>{const e=o.querySelector(".fp-ad-controls");if(!e)return;const t=r.cloneNode(!0);e.append(t),t.addEventListener("click",l)},0);const a=document.createElement("div");a.classList.add("fp-mute-float"),a.append(...Object.assign([n(i,"flowplayer-mute-icon"),n(i,"flowplayer-unmute-icon")],{role:"button"})),a.addEventListener("click",(function(){i.toggleMute()})),e.append(a)}(c,a,o,l);const u=function(e,t){const n=e||60,o=Math.ceil(1e3/n);let i=Date.now(),s=-1;return function(...e){return s>-1||Date.now()<i||(s=requestAnimationFrame((function(){s=-1,t(),i=Date.now()+o}))),s}}(0,(function(){if(i(o)){if(l.hasState("is-fullscreen"))return;s(0,o,l)}})),p=function(){r(l,o)};l.on("viewleave",e=>{(function(e){return!e.paused||!(!e.ads||!e.ads.adPlaying)})(l)&&!a.was_user_toggled&&(e.preventDefault(),function(e,t,n){0==n.reaper||n.floating||r(n,t,"float:pop:out")}(0,o,l))}),l.on("viewenter",(function(){a.was_user_toggled=!1})),l.on("float:pop:out",(function(){window.addEventListener("scroll",u),l.floating=!0,l.setState("is-popped-out",!0),window.addEventListener("resize",p)})),l.on(e,(function(){window.removeEventListener("scroll",u),l.floating=!1,l.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 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,FloatOnScroll)}));
|
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",f="seeked",p="seeking";function v(e){try{return!!new URL(e)}catch(e){return!1}}function E(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(`flowplayer/${e} -- ${i}`,...o)};return i.log=i,i}const m=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=m.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()=>{const e=Date.now();try{return{adjusted_time: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}(),client_time:e}}catch(t){return{client_time:e}}},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.4.
|
|
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",f="seeked",p="seeking";function v(e){try{return!!new URL(e)}catch(e){return!1}}function E(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(`flowplayer/${e} -- ${i}`,...o)};return i.log=i,i}const m=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=m.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()=>{const e=Date.now();try{return{adjusted_time: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}(),client_time:e}}catch(t){return{client_time:e}}},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.4.2",commit:"01d44d5db5202dd3a2d8dea07785c5a796e4a648",ima_sdk_version:b(),preload:e.opt("preload"),autoplay:D(e.opt("autoplay")),live:e.opt("live"),dvr:!!e.live_state.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 F(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 j=(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=E("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,E,m){!function(t){t.on(u,(function(n){t.seeking||t.networkState===t.NETWORK_LOADING&&t.readyState!==t.HAVE_NOTHING&&t.emit(e)}))}(m),m.on("health:record",({detail:e})=>{const t=k(m,this.eventInfo(e.event));Object.assign(t,e.detail||{}),A(this,t)}),[_,d,n,s,r,a,u,e].forEach(e=>{m.on(e,e=>{A(this,k(m,this.eventInfo(e.type)))})}),[l,c,p,f,h,i,o].forEach(e=>{m.on(e,e=>{A(this,k(m,this.eventInfo(e.type)))})}),m.on("volumechange",j(800,e=>{const t=k(m,this.eventInfo(e.type));A(this,U(t,{volume:parseFloat(m.volume.toFixed(2)),muted:m.muted}))})),m.on("resize",j(800,e=>{const t=k(m,this.eventInfo(e.type));A(this,U(t,{height:E.clientHeight,width:E.clientWidth}))})),m.on("hls/failover",e=>{const t=k(m,this.eventInfo(e.type)),n=e.detail,{reason:i,from:o}=n;A(this,U(t,{reason:i,from:o}))}),m.on("qualitychange",({type:e,detail:t})=>{switch(t.kind){case"hls":return L(this,m,e,t)}});let g=Date.now()+5e3;m.on("timeupdate",e=>{if(Date.now()<g)return;g=Date.now()+5e3;const t=k(m,this.eventInfo(e.type));var n;A(this,U(t,{duration:(n=m.duration,Number.isFinite(n)?n:n===1/0?-1:void 0)}))}),m.addEventListener("error",e=>{const t=k(m,this.eventInfo(e.type)),n=e.error||m.error;if(!n)return A(this,t,!0);const i=n.code,o={error_message:n.message||F(i),error_code:i,error_stack:n.stack||""};return A(this,U(t,o),!0)}),m.on("src",e=>{var t;const n=null===(t=e.detail)||void 0===t?void 0:t.src;if("string"!=typeof n)return;if(!v(m.original_src))return;if(!v(n))return;if(n==m.original_src)return;this.media_session_id=B();A(this,k(m,this.eventInfo(e.type))),T(this)}),m.on("visibilitychange",e=>{A(this,k(m,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
|
@@ -370,4 +370,4 @@
|
|
|
370
370
|
/*!*********************************!*\
|
|
371
371
|
!*** ./src/utils/xhr-loader.ts ***!
|
|
372
372
|
\*********************************/
|
|
373
|
-
/*! 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"),a=/^age:\s*[\d.]+\s*$/m,s=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);var a=this.context.headers;if(a)for(var s in a)r.setRequestHeader(s,a[s])}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,a=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 s=e.status;if(s>=200&&s<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>=a.maxRetry||s>=400&&s<499?(i.logger.error(s+" while loading "+t.url),this.callbacks.onError({code:s,text:e.statusText},t,e)):(i.logger.warn(s+" 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,a.maxRetryDelay),r.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),a.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&&a.test(this.loader.getAllResponseHeaders())){var e=this.loader.getResponseHeader("age");t=e?parseFloat(e):null}return t},t}();e.default=s}}).default},t.exports=r())})));var r=Object.freeze({__proto__:null,ATTACHED:"hls:attached"});const i="com.widevine.alpha";const n="application/vnd.apple.mpegURL",a=[n,"application/x-mpegurl"],s=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(!s||!u)&&(!(r&&!Object.keys(r).find(t=>{return e=t,[i].filter((function(t){return t===e})).length;var e}))&&(!(!e||!a.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 a=t.subtitleTracks.filter((function(t){return t.groupId==n})).map((function(t){return e.textTracks[t.id]}));e.emit("tracks:text:all",a)}(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,p;function m(t,e){const r=function(){try{return localStorage.getItem("flowplayer/debug")}catch(t){return""}}(),i=(i,...n)=>{const a=(null==e?void 0:e.debug)||r;a&&t.match(a)&&console.log(`flowplayer/${t} -- ${i}`,...n)};return i.log=i,i}!function(t){t[t.LOW=1]="LOW",t[t.MEDIUM=2]="MEDIUM",t[t.HIGH=4]="HIGH"}(v||(v={})),function(t){t[t.FRAGMENT_ERRORS=0]="FRAGMENT_ERRORS",t[t.STALE_MANIFEST=1]="STALE_MANIFEST"}(p||(p={}));const y=m("hls:failover");class FailoverLoaderController{constructor(){this.playlistCounts={},this.fragmentFailures={},this.ttlMilliseconds=3e3}setHls(t){this.hls=t}reset(){return this.playlistCounts={},this.fragmentFailures={},this}failover(t){var e;this.reset();const r=this.hls;if(!r)return;if(r.levels[r.currentLevel].url.length<2)return;const i=r.levels[r.currentLevel].details;r.levelController.redundantFailover(r.currentLevel),null===(e=r.media)||void 0===e||e.dispatchEvent(new CustomEvent("hls/failover",{detail:{reason:t,from:null==i?void 0:i.url}}))}currentLevel(){var t;return null===(t=this.hls)||void 0===t?void 0:t.levels[this.hls.currentLevel]}nextTTL(){var t;const e=Date.now()+this.ttlMilliseconds,r=this.currentLevel();if(!r)return e;const i=null===(t=r.details)||void 0===t?void 0:t.averagetargetduration;return i?Date.now()+500*i:e}ensurePlaylistUpdating(t,e){this.playlistCounts[t]||(this.playlistCounts[t]={checksum:e,count:0,ttl:this.nextTTL()});const r=this.playlistCounts[t];Date.now()<r.ttl||(r.count=r.checksum===e?r.count+1:0,r.ttl=this.nextTTL(),r.checksum=e,r.count<3||(y(`${t} / no change in ${r.count} tries`,this.playlistCounts),this.failover(p.STALE_MANIFEST)))}trackFragmentError(t){const e=this.fragmentFailures[t]||0;this.fragmentFailures[t]=e+1,this.fragmentFailures[t]>2&&this.failover(p.FRAGMENT_ERRORS)}createPlaylistLoader(){const t=this;return class extends e.DefaultConfig.loader{load(e,r,i){const n=i.onSuccess;i.onSuccess=({data:e,url:r},...i)=>{t.ensurePlaylistUpdating(r,e),n({data:e,url:r},...i)},super.load(e,r,i)}}}createFragmentLoader(){const t=this;return class extends e.DefaultConfig.loader{load(e,r,i){const n=i.onError;i.onError=e=>{t.trackFragmentError(e.url),n(...arguments)},super.load(e,r,i)}}}}const E=m("hls");function T(t,r,i){if(!t.reaper||!i.src)return;t.hls&&t.hls.destroy();const n="live"in r==0,a={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 s=new FailoverLoaderController,o=function(t){return Object.assign(Object.assign({autoStartLoad:!1,levelLoadingMaxRetry:1},t.hls),{startPosition:t.start_time||-1})}(r);o.pLoader=s.createPlaylistLoader(),o.fLoader=s.createFragmentLoader();const l=t.hls=new e(o);s.setHls(l),l.subtitleDisplay=!1,l.attachMedia(t),l.loadSource(i.src),t.emit("hls:attached",{hls:l}),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)})))}))}(l,t),f(l,t);const h=function(t){var e;const r=null===(e=t.data)||void 0===e?void 0:e.level;"number"==typeof r&&(l.levels[r]||-1===r?l.nextLevel=r:console.error(new Error("skipping invalid quality: "+t.data)))},p=function(t){var e;const r=null===(e=t.data)||void 0===e?void 0:e.id;"number"==typeof r&&r!=l.audioTrack&&setTimeout((function(){l.audioTrack=r}),0)};t.on("quality:set",h),t.on(u,p),t.on("src",(function(){t.hls&&t.hls.destroy(),t.off("quality:set",h),t.off(u,p)})),t.on("audioonlysource",(function(){a.is_audio_only=!0})),t.on("reap",(function(){l&&l.destroy()})),t.on("remotesession:started",()=>{t.hls&&t.hls.stopLoad()}),t.on("remotesession:ended",()=>{t.hls&&S(t)}),n&&l.on(e.Events.LEVEL_LOADED,(function(e,r){t.setOpts({live:r.details.live})})),l.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;E("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 a=(null===(i=e.hls)||void 0===i?void 0:i.maxBufferSize)||1024,s=(null===(n=e.hls)||void 0===n?void 0:n.maxBufferLength)||30;E("Setting maxBufferSize to %d",a),t.hls.config.maxBufferSize=a,"metadata"===e.preload&&E("preload === metadata, setting maxBufferLength to 1sec");if(t.hls.config.maxBufferLength="metadata"===e.preload?1:s,t.once("playing",()=>{E("Playback started, set maxBufferLenght to %d",s),t.hls&&(t.hls.config.maxBufferLength=s)}),"none"===e.preload&&!e.autoplay)return;S(t,e.start_time||-1)}(t,r,n.slice(0,-1));const a=n.find(t=>!!t.videoCodec);a||t.emit("audioonlysource"),!t.opt("ratio")&&a&&0!=a.width&&0!=a.height&&t.setOpts({ratio:a.width+":"+a.height})})),l.on(e.Events.INIT_PTS_FOUND,(function(t,e){a.fragDuration=e.frag.duration})),l.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,l.config)})),l.on(e.Events.LEVEL_PTS_UPDATED,(function(e,r){var i;if("video"!==r.type&&(!a.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 s=n[0].start||0,o=n[n.length-1].start+n[n.length-1].duration;t.emit("dvr/window",o-s)})),l.on(e.Events.LEVEL_SWITCHING,(e,r)=>{const i=l.levels[l.currentLevel],n=l.levels[r.level];t.emit("qualitychange",{before:i,after:n,kind:"hls"})});const m=t.opt("start_time");m&&t.once("loadedmetadata",(function(){t.currentTime=m})),"none"!==r.preload||r.autoplay||t.once("beforeplay",()=>{t.hasState("is-casting")||S(t,r.start_time||-1)})}function S(t,e){var r;!t.hasState("is-loaded")&&t.setState("is-loading",!0),null===(r=t.hls)||void 0===r||r.startLoad(e)}class HLS{init(){}onload(t,e,r,i){T(r,t,i)}wants(t,r,i){return e.isSupported()&&l(r,i)}}return HLS.events=r,HLS.version=e.version,HLS.failover={Reasons:p},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}));
|
|
373
|
+
/*! 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"),a=/^age:\s*[\d.]+\s*$/m,s=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);var a=this.context.headers;if(a)for(var s in a)r.setRequestHeader(s,a[s])}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,a=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 s=e.status;if(s>=200&&s<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>=a.maxRetry||s>=400&&s<499?(i.logger.error(s+" while loading "+t.url),this.callbacks.onError({code:s,text:e.statusText},t,e)):(i.logger.warn(s+" 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,a.maxRetryDelay),r.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),a.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&&a.test(this.loader.getAllResponseHeaders())){var e=this.loader.getResponseHeader("age");t=e?parseFloat(e):null}return t},t}();e.default=s}}).default},t.exports=r())})));var r=Object.freeze({__proto__:null,ATTACHED:"hls:attached"});const i="com.widevine.alpha";const n="application/vnd.apple.mpegURL",a=[n,"application/x-mpegurl"],s=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(!s||!u)&&(!(r&&!Object.keys(r).find(t=>{return e=t,[i].filter((function(t){return t===e})).length;var e}))&&(!(!e||!a.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 a=t.subtitleTracks.filter((function(t){return t.groupId==n})).map((function(t){return e.textTracks[t.id]}));e.emit("tracks:text:all",a)}(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,p;function m(t,e){const r=function(){try{return localStorage.getItem("flowplayer/debug")}catch(t){return""}}(),i=(i,...n)=>{const a=(null==e?void 0:e.debug)||r;a&&t.match(a)&&console.log(`flowplayer/${t} -- ${i}`,...n)};return i.log=i,i}!function(t){t[t.LOW=1]="LOW",t[t.MEDIUM=2]="MEDIUM",t[t.HIGH=4]="HIGH"}(v||(v={})),function(t){t[t.FRAGMENT_ERRORS=0]="FRAGMENT_ERRORS",t[t.STALE_MANIFEST=1]="STALE_MANIFEST"}(p||(p={}));const y=m("hls:failover");class FailoverLoaderController{constructor(){this.playlistCounts={},this.fragmentFailures={},this.ttlMilliseconds=3e3}setHls(t){this.hls=t}reset(){return this.playlistCounts={},this.fragmentFailures={},this}failover(t){var e;this.reset();const r=this.hls;if(!r)return;if(r.levels[r.currentLevel].url.length<2)return;const i=r.levels[r.currentLevel].details;r.levelController.redundantFailover(r.currentLevel),null===(e=r.media)||void 0===e||e.dispatchEvent(new CustomEvent("hls/failover",{detail:{reason:t,from:null==i?void 0:i.url}}))}currentLevel(){var t;return null===(t=this.hls)||void 0===t?void 0:t.levels[this.hls.currentLevel]}nextTTL(){var t;const e=Date.now()+this.ttlMilliseconds,r=this.currentLevel();if(!r)return e;const i=null===(t=r.details)||void 0===t?void 0:t.averagetargetduration;return i?Date.now()+500*i:e}ensurePlaylistUpdating(t,e){this.playlistCounts[t]||(this.playlistCounts[t]={checksum:e,count:0,ttl:this.nextTTL()});const r=this.playlistCounts[t];Date.now()<r.ttl||(r.count=r.checksum===e?r.count+1:0,r.ttl=this.nextTTL(),r.checksum=e,r.count<3||(y(`${t} / no change in ${r.count} tries`,this.playlistCounts),this.failover(p.STALE_MANIFEST)))}trackFragmentError(t){const e=this.fragmentFailures[t]||0;this.fragmentFailures[t]=e+1,this.fragmentFailures[t]>2&&this.failover(p.FRAGMENT_ERRORS)}createPlaylistLoader(){const t=this;return class extends e.DefaultConfig.loader{load(e,r,i){const n=i.onSuccess;i.onSuccess=({data:e,url:r},...i)=>{t.ensurePlaylistUpdating(r,e),n({data:e,url:r},...i)},super.load(e,r,i)}}}createFragmentLoader(){const t=this;return class extends e.DefaultConfig.loader{load(e,r,i){const n=i.onError;i.onError=e=>{t.trackFragmentError(e.url),n(...arguments)},super.load(e,r,i)}}}}const E=m("hls");function T(t,r,i){if(!t.reaper||!i.src)return;t.hls&&t.hls.destroy();const n="live"in r==0,a={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 s=new FailoverLoaderController,o=function(t){return Object.assign(Object.assign({autoStartLoad:!1,levelLoadingMaxRetry:1},t.hls),{startPosition:t.start_time||-1})}(r);o.pLoader=s.createPlaylistLoader(),o.fLoader=s.createFragmentLoader();const l=t.hls=new e(o);s.setHls(l),l.subtitleDisplay=!1,l.attachMedia(t),l.loadSource(i.src),t.emit("hls:attached",{hls:l}),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)})))}))}(l,t),f(l,t);const h=function(t){var e;const r=null===(e=t.data)||void 0===e?void 0:e.level;"number"==typeof r&&(l.levels[r]||-1===r?l.nextLevel=r:console.error(new Error("skipping invalid quality: "+t.data)))},p=function(t){var e;const r=null===(e=t.data)||void 0===e?void 0:e.id;"number"==typeof r&&r!=l.audioTrack&&setTimeout((function(){l.audioTrack=r}),0)};t.on("quality:set",h),t.on(u,p),t.on("src",(function(){t.hls&&t.hls.destroy(),t.off("quality:set",h),t.off(u,p)})),t.on("audioonlysource",(function(){a.is_audio_only=!0})),t.on("reap",(function(){l&&l.destroy()})),t.on("remotesession:started",()=>{t.hls&&t.hls.stopLoad()}),t.on("remotesession:ended",()=>{t.hls&&S(t)}),n&&l.on(e.Events.LEVEL_LOADED,(function(e,r){t.setOpts({live:r.details.live})})),l.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;E("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 a=(null===(i=e.hls)||void 0===i?void 0:i.maxBufferSize)||1024,s=(null===(n=e.hls)||void 0===n?void 0:n.maxBufferLength)||30;E("Setting maxBufferSize to %d",a),t.hls.config.maxBufferSize=a,"metadata"===e.preload&&E("preload === metadata, setting maxBufferLength to 1sec");if(t.hls.config.maxBufferLength="metadata"===e.preload?1:s,t.once("playing",()=>{E("Playback started, set maxBufferLenght to %d",s),t.hls&&(t.hls.config.maxBufferLength=s)}),"none"===e.preload&&!e.autoplay)return;S(t,e.start_time||-1)}(t,r,n.slice(0,-1));const a=n.find(t=>!!t.videoCodec);a||t.emit("audioonlysource"),!t.opt("ratio")&&a&&0!=a.width&&0!=a.height&&t.setOpts({ratio:a.width+":"+a.height})})),l.on(e.Events.INIT_PTS_FOUND,(function(t,e){a.fragDuration=e.frag.duration})),l.on(e.Events.ERROR,(function(r,i){!function(t,r){var i,n;if(0==t.reaper)return;if(0==r.fatal)return;switch(r.type){case e.ErrorTypes.MEDIA_ERROR:return null===(i=t.hls)||void 0===i?void 0:i.recoverMediaError();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:return 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);default:null===(n=t.hls)||void 0===n||n.destroy()}}(t,i)})),l.on(e.Events.LEVEL_PTS_UPDATED,(function(e,r){var i;if("video"!==r.type&&(!a.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 s=n[0].start||0,o=n[n.length-1].start+n[n.length-1].duration;t.emit("dvr/window",o-s)})),l.on(e.Events.LEVEL_SWITCHING,(e,r)=>{const i=l.levels[l.currentLevel],n=l.levels[r.level];t.emit("qualitychange",{before:i,after:n,kind:"hls"})});const m=t.opt("start_time");m&&t.once("loadedmetadata",(function(){t.currentTime=m})),"none"!==r.preload||r.autoplay||t.once("beforeplay",()=>{t.hasState("is-casting")||S(t,r.start_time||-1)})}function S(t,e){var r;!t.hasState("is-loaded")&&t.setState("is-loading",!0),null===(r=t.hls)||void 0===r||r.startLoad(e)}class HLS{init(){}onload(t,e,r,i){T(r,t,i)}wants(t,r,i){return e.isSupported()&&l(r,i)}}return HLS.events=r,HLS.version=e.version,HLS.failover={Reasons:p},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/ovp.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((t="undefined"!=typeof globalThis?globalThis:t||self).flowplayer=t.flowplayer||{},t.flowplayer.ovp=e())}(this,(function(){"use strict";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=>{n.ima&&Object.assign(t,{ima:n.ima});const e=p(t,o);return delete e.playlist,e});return delete r.ima,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){const e=Date.now()-(t.server_time_offset||0);return Math.floor(((t.live_start_time||0)-e)/1e3)}function I(t,e){let n=0;function o(){const o=M(e);if(o<0||isNaN(o)||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 i,r,a;i=t,r=t.root,a=o,r.classList.add("is-livecountdown"),i.emit("ovp:live:countdown:tick",{remaining_time:D(a+1)}),i.hasState("is-starting")||i.setState("is-starting",!0)}l(e),o(),n=setInterval(o,250)}function D(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 e||M(e)>0)return;const n=l(e);o.setOpts(n),o.setAttrs(n),n.src&&o.setSrc(n.src)})),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(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)<=0)return o.emit("ovp:request:media:complete",i);x(o,S)||(n.appendChild(k(o,S)),I(o,t))})),o.on("timeupdate",(function(){var e,n,i;const r=t;w(r)?R(r)||(o.togglePlay(!1),o.emit("ended")):t.recommendations&&(null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.media_id)&&(Array.isArray(t.recommendations)||o.currentTime/o.duration<.8||T()||(null===(n=null==t?void 0:t.metadata)||void 0===n?void 0:n.media_id)&&(null===(i=null==t?void 0:t.metadata)||void 0===i?void 0:i.player_id)&&A(o,t.metadata.media_id,t.metadata.player_id))})),o.on("reap",(function(){i.disconnect()}))}}function R(t){var e,n;const o=null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.live_stop_time;if(!o)return!0;return!!(null===(n=null==t?void 0:t.metadata)||void 0===n?void 0:n.allow_after_stop_time)||h(o)>Date.now()}OVP.events=_;const N=t=>{var e;if(t&&Array.isArray(t))return"object"==typeof t[0]&&"ovp/base64"===(null===(e=t[0])||void 0===e?void 0:e.type)};return function(t,e){if("object"==typeof exports&&"undefined"!=typeof module)return e;"flowplayer"in t||(t.flowplayer={extensions:[]});const n=t.flowplayer;"function"==typeof n?n(e):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(e)||n.extensions.push(e))}(window,OVP),OVP}));
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((t="undefined"!=typeof globalThis?globalThis:t||self).flowplayer=t.flowplayer||{},t.flowplayer.ovp=e())}(this,(function(){"use strict";const t=t=>"object"==typeof t&&null!==t&&!Array.isArray(t),e=(...n)=>n.reduce((n,o)=>t(o)?(Object.keys(o).forEach(i=>{if(t(n[i])&&t(o[i]))return n[i]=e(n[i],o[i]);n[i]=o[i]}),n):n,{});class Pipe{constructor(t){this.data=t}static of(t){return new Pipe(t)}static maybe(t,e,...n){return null==t?t:e.apply(t,[t,...n])}tap(t,...e){return t.apply(this,[this.data,...e]),new Pipe(this.data)}fmap(t,...e){const n=t.apply(this,[this.data,...e]);return new Pipe(n)}unwrap(){return this.data}}const n="https://ljsp.lwcdn.com".concat("/web/public/countdown/time.json"),o=window,i=o._flowplayerTimekeeper||(o._flowplayerTimekeeper={});function r(t){return fetch(t).then(t=>t.json())}function a(){let t=[].join.call(arguments,"/");return"/"!==t[0]&&(t="/"+t),s()+"/web/public/native/config"+t}const s=()=>"https://ljsp.lwcdn.com";function l(t){(async function(){const t=i.cachedServerOffset;if(t)return t;const e=i.pendingRequest||(i.pendingRequest=fetch(n)),o=await e,r=parseInt(o.headers.get("age")||"0"),a=await o.json(),s=Date.now()-a.millisUtc-1e3*r;return i.cachedServerOffset=s,i.cachedServerOffset})().then(e=>Object.assign(t,{server_time_offset:e}))}function c(t){return~t.indexOf("/")?t:"/media/"+t}var d={404:"media not found",402:"invalid subscription",400:"bad request",415:"unsupported media type"};function u(t){const e=t.ima,n=t.duration;if(!e||!n)return t;const o=null==e?void 0:e.ads;return Array.isArray(o)&&(e.ads=o.map((function(t){return"number"==typeof t.percentage&&(t.time=t.percentage*n),t}))),t}function p(t,n){var o,i;n="object"==typeof n?n:{};const r={title:null===(o=null==t?void 0:t.metadata)||void 0===o?void 0:o.title,description:null===(i=null==t?void 0:t.metadata)||void 0===i?void 0:i.description},a={ima:{parameters:function({media_id:t,duration:e,title:n,tags:o,category_name:i,ad_keywords:r}){return{ad_keywords:r||"",media_id:t||"",category:i||"",media_name:n||"",media_tags:o||"",media_duration:e||-1}}((null==t?void 0:t.metadata)||{})}},s=n.embed||{};return delete s.src,e(a,r,t,(delete(l=n).src,delete l.metadata,delete l.title,delete l.description,delete l.duration,delete l.poster,l),s);var l}const m=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/;function f(t){return"object"==typeof t&&"ovp/base64"==t.type}function v(t,e){return function(t,e){return!t.startsWith("blob:")&&(!(~t.indexOf(".")||!m.test(t))&&(e.type="video/ovp",!0))}(t,e)||f(e)}function y(t){try{return function(t){return null===t?{}:JSON.parse(t)}(decodeURIComponent(atob(t).split("").map((function(t){return"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2)})).join("")))}catch(t){return{err:t.message}}}function h(t){const e=t.split(/[^0-9]/).map(t=>parseInt(t,10));return Date.UTC(e[0],e[1]-1,e[2],e[3],e[4],e[5])}function w(t){return t.live}var _=Object.freeze({__proto__:null,OVP_ERROR:"ovp:error",OVP_MEDIA_REQUEST_START:"ovp:request:start",OVP_MEDIA_REQUEST_COMPLETE:"ovp:request:media:complete",OVP_PLAYLIST_REQUEST_COMPLETE:"ovp:request:playlist:complete",LIVE_COUNTDOWN_TICK:"ovp:live:countdown:tick",LIVE_COUNTDOWN_START:"ovp:live:countdown:start",LIVE_COUNTDOWN_COMPLETE:"ovp:live:countdown:complete",OVP_MEDIA_CHANGED:"ovp:media:changed",OVP_REALTIME_MESSAGE:"ovp:message:realtime"});function g(t,e){const n=null==e?void 0:e.src;if(f(e))return function(t,e){const n=y(e.src||"");if(function(t){return"string"==typeof t.err}(n))return console.error(n.err);b(t,n)}(t,e);n&&Pipe.of(n).fmap(c).fmap(a).fmap(t=>fetch(t)).fmap(e=>e.then(t=>Promise.all([t.status,t.json()])).then(([e,n])=>200==e?b(t,n):E(t,n)))}function b(t,n){return t.emit("ovp:media:changed",n),function(t){return Array.isArray(t.playlist)}(n)?function(t,n){if("function"!=typeof window.flowplayer.playlist)return console.warn("OVP responded with Playlist media but the playlist plugin does not exist"),E(t,{status:415});t.emit("ovp:request:playlist:complete",function(t,n){const o=Object.assign({},t),i=(null==t?void 0:t.playlist)||{},r=e(n,i),a=((null==r?void 0:r.playlist)||[]).map(t=>{n.ima&&Object.assign(t,{ima:n.ima});const e=p(t,o);return delete e.playlist,e});return delete r.ima,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){const e=Date.now()-(t.server_time_offset||0);return Math.floor(((t.live_start_time||0)-e)/1e3)}function I(t,e){let n=0;function o(){const o=M(e);if(o<0||isNaN(o)||0===t.reaper||void 0===e.live_start_time)return clearInterval(n),function(t,e,n){t.emit("ovp:live:countdown:complete");const o=x(t,S);o&&o.remove(),t.root.classList.remove("is-livecountdown"),n||t.emit("ovp:request:media:complete",e)}(t,e,void 0===e.live_start_time);var i,r,a;i=t,r=t.root,a=o,r.classList.add("is-livecountdown"),i.emit("ovp:live:countdown:tick",{remaining_time:D(a+1)}),i.hasState("is-starting")||i.setState("is-starting",!0)}l(e),o(),n=setInterval(o,250)}function D(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 e||M(e)>0)return;const n=l(e);o.setOpts(n),o.setAttrs(n),n.src&&o.setSrc(n.src)})),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(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)<=0)return o.emit("ovp:request:media:complete",i);x(o,S)||(n.appendChild(k(o,S)),I(o,t))})),o.on("timeupdate",(function(){var e,n,i;const r=t;w(r)?R(r)||(o.togglePlay(!1),o.emit("ended")):t.recommendations&&(null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.media_id)&&(Array.isArray(t.recommendations)||o.currentTime/o.duration<.8||T()||(null===(n=null==t?void 0:t.metadata)||void 0===n?void 0:n.media_id)&&(null===(i=null==t?void 0:t.metadata)||void 0===i?void 0:i.player_id)&&A(o,t.metadata.media_id,t.metadata.player_id))})),o.on("reap",(function(){i.disconnect()}))}}function R(t){var e,n;const o=null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.live_stop_time;if(!o)return!0;return!!(null===(n=null==t?void 0:t.metadata)||void 0===n?void 0:n.allow_after_stop_time)||h(o)>Date.now()}OVP.events=_;const N=t=>{var e;if(t&&Array.isArray(t))return"object"==typeof t[0]&&"ovp/base64"===(null===(e=t[0])||void 0===e?void 0:e.type)};return function(t,e){if("object"==typeof exports&&"undefined"!=typeof module)return e;"flowplayer"in t||(t.flowplayer={extensions:[]});const n=t.flowplayer;"function"==typeof n?n(e):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(e)||n.extensions.push(e))}(window,OVP),OVP}));
|
package/plugins/playlist.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((t="undefined"!=typeof globalThis?globalThis:t||self).flowplayer=t.flowplayer||{},t.flowplayer.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 x(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=x("title",t);n&&e.append(n);const i=x("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 b;function g(t,e){var n,i;const s=e.sort||I,o=null!==(n=e.mode)&&void 0!==n?n:b.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&b.SHUFFLE)==b.SHUFFLE?t.sort((function(){return Math.random()-Math.random()})):t.slice(0)}function T(t){return g(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"}(b||(b={}));!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=n.idx+n.plays<0;return N(e,function(t,e,n){return t.idx=e&&"number"==typeof n&&n>=0&&n<=t.last_idx?n:t.idx+1,t.members[t.idx]}(n,s,i.start_index),i),s&&i.autoplay?e.togglePlay(!0):s?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,i){"object"==typeof n&&e.setOpts(n),function(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];if(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)}(e,{should_play:i.should_play})}function C(e,n){return{queue:n,events:t,play:function(t){t<0||t>=n.members.length||(this.queue.idx=t,N(e,n.members[t],Object.assign({should_play:!0},e.opt("playlist"))))},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&b.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&b.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;!1!==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?b.SHUFFLE:b.FIFO;return e.loop&&(n|=b.LOOP),g(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(!1!==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:5,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}));
|
|
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),e.translation_key&&this.setAttribute("aria-label",t.i18n(e.translation_key)),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 b(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 w(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=b(t,"data.queue",b(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=w("title",t);n&&e.append(n);const i=w("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 x;function g(t,e){var n,i;const s=e.sort||I,o=null!==(n=e.mode)&&void 0!==n?n:x.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&x.SHUFFLE)==x.SHUFFLE?t.sort((function(){return Math.random()-Math.random()})):t.slice(0)}function T(t){return g(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"}(x||(x={}));!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=n.idx+n.plays<0;return N(e,function(t,e,n){return t.idx=e&&"number"==typeof n&&n>=0&&n<=t.last_idx?n:t.idx+1,t.members[t.idx]}(n,s,i.start_index),i),s&&i.autoplay?e.togglePlay(!0):s?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,i){"object"==typeof n&&e.setOpts(n),function(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];if(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)}(e,{should_play:i.should_play})}function C(e,n){return{queue:n,events:t,play:function(t){t<0||t>=n.members.length||(this.queue.idx=t,N(e,n.members[t],Object.assign({should_play:!0},e.opt("playlist"))))},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=b(t,"data.queue",b(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&x.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&x.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;!1!==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?x.SHUFFLE:x.FIFO;return e.loop&&(n|=x.LOOP),g(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(!1!==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:5,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}));
|
package/plugins/qsel.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.qsel=t())}(this,(function(){"use strict";function e(e,t,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 t=(e,t)=>new(((e,t)=>{const n=e.get(t);if(!n)throw new Error(`no flowplayer component with the name ${t} exists`);const s=window.customElements.get(t);if(!s)throw new Error(`no default flowplayer component with the name ${t} exists`);const i=window.customElements.get(n);return"function"!=typeof i?s:i})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}const n="fp-on",s="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",
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.qsel=t())}(this,(function(){"use strict";function e(e,t,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 t=(e,t)=>new(((e,t)=>{const n=e.get(t);if(!n)throw new Error(`no flowplayer component with the name ${t} exists`);const s=window.customElements.get(t);if(!s)throw new Error(`no default flowplayer component with the name ${t} exists`);const i=window.customElements.get(n);return"function"!=typeof i?s:i})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}const n="fp-on",s="fp-invis";class FlowplayerMenu extends FlowplayerComponent{constructor(e){super(e),this.player=e,this.menuContainer=document.createElement("details"),this.summaryEle=document.createElement("summary"),this.olEle=document.createElement("ol"),this.olEle.id=o(),this.menu=document.createElement("div"),this.closeEle=document.createElement("span"),this.menu.classList.add("fp-menu"),this.menu.append(this.closeEle,this.olEle),this.closeEle.classList.add("fp-close"),this.closeEle.textContent="×",this.menuContainer.append(this.summaryEle,this.menu),this.menuContainer.addEventListener("click",t=>{t.preventDefault();const n=this.menuContainer.open;n||(i(),document.active_menu=this.menuContainer),this.menuContainer.open=!n,e.root.classList.toggle("has-menu-opened",!n),this.olEle.setAttribute("aria-expanded",n?"false":"true")}),this.append(this.menuContainer),this.summaryEle.setAttribute("aria-haspopup","true"),this.summaryEle.setAttribute("aria-controls",this.olEle.id),this.summaryEle.setAttribute("tabindex","0"),this.summaryEle.setAttribute("role","button")}get options(){return this.olEle.querySelectorAll("li")}setMenuAttrs(e){if(this.summaryEle.id||(this.summaryEle.id=e.id||o()),this.className=`${e.class} ${s}`,this.menuContainer.classList.add("fp-menu-container"),this.olEle.setAttribute("aria-labelledby",this.summaryEle.id),this.olEle.setAttribute("role","menu"),this.summaryEle.setAttribute("aria-label",e.menuTitle||"Menu"),e.summaryTitle&&(this.summaryEle.textContent=e.summaryTitle),e.summaryIcon){const n=t(this.player,e.summaryIcon);n.setAttribute("tabindex",""),this.summaryEle.append(n)}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(s,!(null==e?void 0:e.length)))}menuOption(e,t){const n=document.createElement("li");n.setAttribute("role","menuitem"),n.setAttribute("tabindex","0"),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,s)=>{t.classList.toggle(n,s===e&&("flowplayer-subtitles-menu"!==this.localName||!t.classList.contains(n)))})}unselect_item(){this.options.forEach(e=>{e.classList.remove(n)})}}function i(){Array.from(document.querySelectorAll(".fp-engine")).forEach(e=>{var t;const n=e.root.querySelector("details[open].fp-menu-container");n&&(n.open=!1,null===(t=n.querySelector("summary"))||void 0===t||t.removeAttribute("aria-expanded"),e.root.classList.toggle("has-menu-opened",!1))})}function o(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function l(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)&&(i(),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 Qsel{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-quality-menu",FlowplayerMenu)}init(n,s,i){if(!1===n.qsel)return;const o=t(i,"flowplayer-quality-menu");o instanceof FlowplayerMenu&&o.setMenuAttrs({summaryTitle:"HD",menuTitle:i.i18n("qsel.menu_title"),class:"fp-qsel",options_event:Qsel.events.TRACKS,item_selected_event:Qsel.events.SWITCH}),i.on("mount",(function(){var e;null===(e=function(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}(i,"flowplayer-control"))||void 0===e||e.append(o)})),i.on("qualities",t=>{if(!Array.isArray(t.detail))return;const s=t.detail,a=e(n,"qsel.labels",[]);l(o,Qsel.events.TRACKS,s.flatMap((e,t)=>{if("boolean"==typeof a[t]&&!a[t])return[];let n=e.height?e.height+"p":e.text;return"number"==typeof e.height&&e.height>719&&(n+=" HD"),{text:a[t]||n,onclick:r.bind(0,i,e)}}))})}}function r(e,t){e.emit("quality:set",t)}return Qsel.events={TRACKS:"quality:tracks",SWITCH:"quality:update"},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,Qsel)}));
|
package/plugins/share.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.share=t())}(this,(function(){"use strict";const e={name:"fp-facebook"},t={name:"fp-link"},n={name:"fp-share"},o={name:"fp-embed"},s={name:"fp-twitter"};function i(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 r(){try{return(document.querySelector("meta[name='description']")||{content:""}).content}catch(e){return""}}function l(e){if("string"==typeof e.link)return e.link;const t=document.querySelector("link[rel=canonical]");return t?t.href:window.location.toString()}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 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 o=window.customElements.get(t);if(!o)throw new Error(`no default flowplayer component with the name ${t} exists`);const s=window.customElements.get(n);return"function"!=typeof s?o:s})(e._customElements,t))(e),c=(e,t,n)=>{window.customElements.get(t)||window.customElements.define(t,n),e.customElements.get(t)||e.customElements.set(t,t)},u="flowplayer-share-menu",p="fp-on",d="fp-invis";class FlowplayerMenu extends FlowplayerComponent{constructor(e){super(e),this.player=e,this.menuContainer=document.createElement("details"),this.summaryEle=document.createElement("summary"),this.olEle=document.createElement("ol"),this.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||(m(),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} ${d}`,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(d,!(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 o=document.createElement("span");o.textContent=e.text,n.append(o),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(p,n===e&&("flowplayer-subtitles-menu"!==this.localName||!t.classList.contains(p)))})}unselect_item(){this.options.forEach(e=>{e.classList.remove(p)})}}function m(){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 h(e,t,n){const o=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(o),e}function f(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}document.addEventListener("click",(function(e){this.active_menu&&!e.composedPath().includes(this.active_menu)&&(m(),this.active_menu=void 0)})),function(){let e=!1;try{const t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("testPassive",null,t),window.removeEventListener("testPassive",null,t)}catch(e){}}();class Share{constructor(i){this.umd=i,this.share_options=[],c(i,u,FlowplayerMenu),c(this.umd,"flowplayer-facebook-icon",class extends FlowplayerIcon{constructor(t){super(t,e)}}),c(this.umd,"flowplayer-twitter-icon",class extends FlowplayerIcon{constructor(e){super(e,s)}}),c(this.umd,"flowplayer-link-icon",class extends FlowplayerIcon{constructor(e){super(e,t)}}),c(this.umd,"flowplayer-embed-icon",class extends FlowplayerIcon{constructor(e){super(e,o)}}),c(this.umd,"flowplayer-share-icon",class extends FlowplayerIcon{constructor(e){super(e,n)}})}init(e,t,n){const o=a(n,u);o instanceof FlowplayerMenu&&o.setMenuAttrs({menuTitle:n.i18n("share.menu_title"),class:"fp-share-menu fp-togglable",summaryIcon:"flowplayer-share-icon",icons:!0,options_event:Share.events.OPTIONS});const s={prev_config:0,webshare_listener:0};n.on("mount",(function(){var e;null===(e=f(n,t.classList.contains("logo-on-right")?"flowplayer-header-right-zone":"flowplayer-header-left-zone"))||void 0===e||e.append(o),o instanceof FlowplayerMenu&&o.menuContainer.addEventListener("toggle",(function(){t.classList.toggle("is-share-menu",this.open);const e=f(n,"flowplayer-control");this.open&&(t.classList.contains("is-small")?n.pause():e&&function(e,t){if(!t)return;e.menu.style.maxHeight=t.getBoundingClientRect().top+parseFloat(window.getComputedStyle(t).getPropertyValue("padding"))-e.menuContainer.getBoundingClientRect().bottom+"px"}(o,e))}))})),n.on("config",t=>{const c=i(t,"data.share",{});if(!1===c)return o instanceof FlowplayerMenu&&void o.classList.remove("webshare-enabled");if(s.prev_config===c)return;if(s.prev_config=c,o instanceof FlowplayerMenu&&function(){try{return"https:"===window.location.protocol&&"function"==typeof navigator.share}catch(e){return!1}}()&&i(c,"web_share",!0))return function(e){e.classList.add("webshare-enabled")}(o),s.webshare_listener||function(e,t,n){n.webshare_listener=!0,t.addEventListener("click",(function(){if(!t.classList.contains("webshare-enabled"))return;t.menuContainer.open=!1;navigator.share({title:i(e,"share.title",document.title),text:i(e,"share.text",r()),url:l(i(e,"share",{}))}).catch((function(){}))}))}(e,o,s);this.share_options=[];const u="string"==typeof c.link?c.link:window.location.toString();if(c.iframe){const e="string"==typeof c.iframe?c.iframe:u;this.share_options.push(y(n,o,"share.embed",b.bind(null,e,n),a(n,"flowplayer-embed-icon")))}c.link&&this.share_options.push(y(n,o,"share.link",_.bind(null,u),a(n,"flowplayer-link-icon"))),c.facebook&&this.share_options.push(y(n,o,"Facebook",E.bind(null,u),a(n,"flowplayer-facebook-icon"))),c.twitter&&this.share_options.push(y(n,o,"Twitter",v.bind(null,u),a(n,"flowplayer-twitter-icon"))),h(o,Share.events.OPTIONS,this.share_options)})}add_options(e,...t){const n=e.root.querySelector(u);n&&t.forEach(t=>{const o=y(e,n,t.text,t.onclick,t.icon);n.menuOption(o,n.options.length)})}}function y(e,t,n,o,s){return{text:w(e,n),icon:s,onclick:g.bind(null,e,t,o)}}function w(e,t){return 0===t.indexOf("share.")?e.i18n(t):t}function g(e,t,n){t instanceof FlowplayerMenu&&t.unselect_item();const o=n();o.success&&o.message&&e.message&&e.emit(e.message.events.SHOW_MESSAGE,{message:o.message})}function b(e,t){const n=t.videoHeight/t.videoWidth;return _('<div style="position:relative;width:100%;display:inline-block;"><iframe src="__IFRAME_SRC__" allowfullscreen style="border:none;position:absolute;top:0;left:0;width:100%;height:100%;"></iframe><div style="padding-top: __RATIO__%;"></div></div>'.replace("__IFRAME_SRC__",encodeURI(e)).replace("__RATIO__",""+100*n))}function _(e){const t=document.createElement("textarea");t.setAttribute("style","position:absolute;opacity:0"),t.value=e;const n=document.body;n.append(t),t.select();const o=document.execCommand("copy");return n.removeChild(t),{success:o,message:o?"<trans share.clipboard_success trans>":"<trans share.clipboard_failure trans>"}}function E(e){return x("https://www.facebook.com/sharer.php?u="+encodeURIComponent(e)),{success:!0}}function v(e){return x("https://twitter.com/intent/tweet?url="+encodeURIComponent(e)),{success:!0}}function x(e){let t;const n=screen.height,o=screen.width,s=Math.round(o/2-275);t=0,n>420&&(t=Math.round(n/2-210)),window.open(e,"sharer","scrollbars=yes,resizable=yes,toolbar=no,location=yes,width=550,height=420,left="+s+",top="+t)}return Share.events={OPTIONS:"share:options"},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,Share),Share}));
|
|
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.share=t())}(this,(function(){"use strict";const e={name:"fp-facebook"},t={name:"fp-link"},n={name:"fp-share"},s={name:"fp-embed"},o={name:"fp-twitter"};function i(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}function r(){try{return(document.querySelector("meta[name='description']")||{content:""}).content}catch(e){return""}}function l(e){if("string"==typeof e.link)return e.link;const t=document.querySelector("link[rel=canonical]");return t?t.href:window.location.toString()}class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}class FlowplayerIcon extends FlowplayerComponent{constructor(e,t){super(e),this.classList.add("fp-icon",t.name),t.title&&this.setAttribute("title",t.title),t.title&&this.setAttribute("aria-label",t.title),t.translation_key&&this.setAttribute("aria-label",e.i18n(t.translation_key)),this.setAttribute("tabindex","0"),this.setAttribute("focusable","true")}}const 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),c=(e,t,n)=>{window.customElements.get(t)||window.customElements.define(t,n),e.customElements.get(t)||e.customElements.set(t,t)},u="flowplayer-share-menu",m="fp-on",d="fp-invis";class FlowplayerMenu extends FlowplayerComponent{constructor(e){super(e),this.player=e,this.menuContainer=document.createElement("details"),this.summaryEle=document.createElement("summary"),this.olEle=document.createElement("ol"),this.olEle.id=h(),this.menu=document.createElement("div"),this.closeEle=document.createElement("span"),this.menu.classList.add("fp-menu"),this.menu.append(this.closeEle,this.olEle),this.closeEle.classList.add("fp-close"),this.closeEle.textContent="×",this.menuContainer.append(this.summaryEle,this.menu),this.menuContainer.addEventListener("click",t=>{t.preventDefault();const n=this.menuContainer.open;n||(p(),document.active_menu=this.menuContainer),this.menuContainer.open=!n,e.root.classList.toggle("has-menu-opened",!n),this.olEle.setAttribute("aria-expanded",n?"false":"true")}),this.append(this.menuContainer),this.summaryEle.setAttribute("aria-haspopup","true"),this.summaryEle.setAttribute("aria-controls",this.olEle.id),this.summaryEle.setAttribute("tabindex","0"),this.summaryEle.setAttribute("role","button")}get options(){return this.olEle.querySelectorAll("li")}setMenuAttrs(e){if(this.summaryEle.id||(this.summaryEle.id=e.id||h()),this.className=`${e.class} ${d}`,this.menuContainer.classList.add("fp-menu-container"),this.olEle.setAttribute("aria-labelledby",this.summaryEle.id),this.olEle.setAttribute("role","menu"),this.summaryEle.setAttribute("aria-label",e.menuTitle||"Menu"),e.summaryTitle&&(this.summaryEle.textContent=e.summaryTitle),e.summaryIcon){const t=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(d,!(null==e?void 0:e.length)))}menuOption(e,t){const n=document.createElement("li");n.setAttribute("role","menuitem"),n.setAttribute("tabindex","0"),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(m,n===e&&("flowplayer-subtitles-menu"!==this.localName||!t.classList.contains(m)))})}unselect_item(){this.options.forEach(e=>{e.classList.remove(m)})}}function p(){Array.from(document.querySelectorAll(".fp-engine")).forEach(e=>{var t;const n=e.root.querySelector("details[open].fp-menu-container");n&&(n.open=!1,null===(t=n.querySelector("summary"))||void 0===t||t.removeAttribute("aria-expanded"),e.root.classList.toggle("has-menu-opened",!1))})}function h(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function f(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 y(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}document.addEventListener("click",(function(e){this.active_menu&&!e.composedPath().includes(this.active_menu)&&(p(),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 Share{constructor(i){this.umd=i,this.share_options=[],c(i,u,FlowplayerMenu),c(this.umd,"flowplayer-facebook-icon",class extends FlowplayerIcon{constructor(t){super(t,e)}}),c(this.umd,"flowplayer-twitter-icon",class extends FlowplayerIcon{constructor(e){super(e,o)}}),c(this.umd,"flowplayer-link-icon",class extends FlowplayerIcon{constructor(e){super(e,t)}}),c(this.umd,"flowplayer-embed-icon",class extends FlowplayerIcon{constructor(e){super(e,s)}}),c(this.umd,"flowplayer-share-icon",class extends FlowplayerIcon{constructor(e){super(e,n)}})}init(e,t,n){const s=a(n,u);s instanceof FlowplayerMenu&&s.setMenuAttrs({menuTitle:n.i18n("share.menu_title"),class:"fp-share-menu fp-togglable",summaryIcon:"flowplayer-share-icon",icons:!0,options_event:Share.events.OPTIONS});const o={prev_config:0,webshare_listener:0};n.on("mount",(function(){var e;null===(e=y(n,t.classList.contains("logo-on-right")?"flowplayer-header-right-zone":"flowplayer-header-left-zone"))||void 0===e||e.append(s),s instanceof FlowplayerMenu&&s.menuContainer.addEventListener("toggle",(function(){t.classList.toggle("is-share-menu",this.open);const e=y(n,"flowplayer-control");this.open&&(t.classList.contains("is-small")?n.pause():e&&function(e,t){if(!t)return;e.menu.style.maxHeight=t.getBoundingClientRect().top+parseFloat(window.getComputedStyle(t).getPropertyValue("padding"))-e.menuContainer.getBoundingClientRect().bottom+"px"}(s,e))}))})),n.on("config",t=>{const c=i(t,"data.share",{});if(!1===c)return s instanceof FlowplayerMenu&&void s.classList.remove("webshare-enabled");if(o.prev_config===c)return;if(o.prev_config=c,s instanceof FlowplayerMenu&&function(){try{return"https:"===window.location.protocol&&"function"==typeof navigator.share}catch(e){return!1}}()&&i(c,"web_share",!0))return function(e){e.classList.add("webshare-enabled")}(s),o.webshare_listener||function(e,t,n){n.webshare_listener=!0,t.addEventListener("click",(function(){if(!t.classList.contains("webshare-enabled"))return;t.menuContainer.open=!1;navigator.share({title:i(e,"share.title",document.title),text:i(e,"share.text",r()),url:l(i(e,"share",{}))}).catch((function(){}))}))}(e,s,o);this.share_options=[];const u="string"==typeof c.link?c.link:window.location.toString();if(c.iframe){const e="string"==typeof c.iframe?c.iframe:u;this.share_options.push(w(n,s,"share.embed",E.bind(null,e,n),a(n,"flowplayer-embed-icon")))}c.link&&this.share_options.push(w(n,s,"share.link",_.bind(null,u),a(n,"flowplayer-link-icon"))),c.facebook&&this.share_options.push(w(n,s,"Facebook",v.bind(null,u),a(n,"flowplayer-facebook-icon"))),c.twitter&&this.share_options.push(w(n,s,"Twitter",x.bind(null,u),a(n,"flowplayer-twitter-icon"))),f(s,Share.events.OPTIONS,this.share_options)})}add_options(e,...t){const n=e.root.querySelector(u);n&&t.forEach(t=>{const s=w(e,n,t.text,t.onclick,t.icon);n.menuOption(s,n.options.length)})}}function w(e,t,n,s,o){return{text:b(e,n),icon:o,onclick:g.bind(null,e,t,s)}}function b(e,t){return 0===t.indexOf("share.")?e.i18n(t):t}function g(e,t,n){t instanceof FlowplayerMenu&&t.unselect_item();const s=n();s.success&&s.message&&e.message&&e.emit(e.message.events.SHOW_MESSAGE,{message:s.message})}function E(e,t){const n=t.videoHeight/t.videoWidth;return _('<div style="position:relative;width:100%;display:inline-block;"><iframe src="__IFRAME_SRC__" allowfullscreen style="border:none;position:absolute;top:0;left:0;width:100%;height:100%;"></iframe><div style="padding-top: __RATIO__%;"></div></div>'.replace("__IFRAME_SRC__",encodeURI(e)).replace("__RATIO__",""+100*n))}function _(e){const t=document.createElement("textarea");t.setAttribute("style","position:absolute;opacity:0"),t.value=e;const n=document.body;n.append(t),t.select();const s=document.execCommand("copy");return n.removeChild(t),{success:s,message:s?"<trans share.clipboard_success trans>":"<trans share.clipboard_failure trans>"}}function v(e){return A("https://www.facebook.com/sharer.php?u="+encodeURIComponent(e)),{success:!0}}function x(e){return A("https://twitter.com/intent/tweet?url="+encodeURIComponent(e)),{success:!0}}function A(e){let t;const n=screen.height,s=screen.width,o=Math.round(s/2-275);t=0,n>420&&(t=Math.round(n/2-210)),window.open(e,"sharer","scrollbars=yes,resizable=yes,toolbar=no,location=yes,width=550,height=420,left="+o+",top="+t)}return Share.events={OPTIONS:"share:options"},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,Share),Share}));
|
package/plugins/speed.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.speed=t())}(this,(function(){"use strict";function e(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}class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}const t="flowplayer-speed-menu",n=(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),s="fp-on",o="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",
|
|
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.speed=t())}(this,(function(){"use strict";function e(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}class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}const t="flowplayer-speed-menu",n=(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),s="fp-on",o="fp-invis";class FlowplayerMenu extends FlowplayerComponent{constructor(e){super(e),this.player=e,this.menuContainer=document.createElement("details"),this.summaryEle=document.createElement("summary"),this.olEle=document.createElement("ol"),this.olEle.id=l(),this.menu=document.createElement("div"),this.closeEle=document.createElement("span"),this.menu.classList.add("fp-menu"),this.menu.append(this.closeEle,this.olEle),this.closeEle.classList.add("fp-close"),this.closeEle.textContent="×",this.menuContainer.append(this.summaryEle,this.menu),this.menuContainer.addEventListener("click",t=>{t.preventDefault();const n=this.menuContainer.open;n||(i(),document.active_menu=this.menuContainer),this.menuContainer.open=!n,e.root.classList.toggle("has-menu-opened",!n),this.olEle.setAttribute("aria-expanded",n?"false":"true")}),this.append(this.menuContainer),this.summaryEle.setAttribute("aria-haspopup","true"),this.summaryEle.setAttribute("aria-controls",this.olEle.id),this.summaryEle.setAttribute("tabindex","0"),this.summaryEle.setAttribute("role","button")}get options(){return this.olEle.querySelectorAll("li")}setMenuAttrs(e){if(this.summaryEle.id||(this.summaryEle.id=e.id||l()),this.className=`${e.class} ${o}`,this.menuContainer.classList.add("fp-menu-container"),this.olEle.setAttribute("aria-labelledby",this.summaryEle.id),this.olEle.setAttribute("role","menu"),this.summaryEle.setAttribute("aria-label",e.menuTitle||"Menu"),e.summaryTitle&&(this.summaryEle.textContent=e.summaryTitle),e.summaryIcon){const t=n(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(o,!(null==e?void 0:e.length)))}menuOption(e,t){const n=document.createElement("li");n.setAttribute("role","menuitem"),n.setAttribute("tabindex","0"),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(s,n===e&&("flowplayer-subtitles-menu"!==this.localName||!t.classList.contains(s)))})}unselect_item(){this.options.forEach(e=>{e.classList.remove(s)})}}function i(){Array.from(document.querySelectorAll(".fp-engine")).forEach(e=>{var t;const n=e.root.querySelector("details[open].fp-menu-container");n&&(n.open=!1,null===(t=n.querySelector("summary"))||void 0===t||t.removeAttribute("aria-expanded"),e.root.classList.toggle("has-menu-opened",!1))})}function l(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function r(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)&&(i(),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 Speed{constructor(e){((e,t,n)=>{window.customElements.get(t)||window.customElements.define(t,n),e.customElements.get(t)||e.customElements.set(t,t)})(e,t,FlowplayerMenu)}init(s,o,i){let l=void 0;const u=n(i,t);u instanceof FlowplayerMenu&&u.setMenuAttrs({menuTitle:i.i18n("speed.menu_title"),summaryTitle:"1x",class:"fp-speed",options_event:Speed.events.OPTIONS}),i.on("config",()=>{const t=e(s,"speed",!0);if(t===l)return;if(l=t,0==t)return r(u,Speed.events.OPTIONS,[]);const n=e(s,"speed.options",Speed.DEFAULT_SPEED_OPTIONS),o=e(s,"speed.labels",[]);r(u,Speed.events.OPTIONS,Array.from({length:n.length}).map((e,t)=>{const s=n[t];return{text:o[t]||s+"x",onclick:a.bind(0,i,s)}}))}),i.on("mount",(function(){var e;null===(e=function(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}(i,"flowplayer-control"))||void 0===e||e.append(u)}))}}function a(e,n){var s;const o=null===(s=e.root.querySelector(t))||void 0===s?void 0:s.summaryEle;o&&(o.textContent=n+"x"),isNaN(n)||(e.playbackRate=n)}return Speed.DEFAULT_SPEED_OPTIONS=[.2,.5,1,2,10],Speed.events={OPTIONS:"speed:options"},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,Speed)}));
|