@flowplayer/player 3.1.0-rc.1 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core.js +2 -2
- package/default.js +2 -2
- package/embed.js +35 -35
- package/flowplayer.css +1 -1
- package/package.json +1 -1
- package/plugins/ads.js +3 -3
- package/plugins/analytics.js +1 -1
- package/plugins/consent.js +1 -1
- package/plugins/gemius.js +1 -1
- package/plugins/google-analytics.js +1 -1
- package/plugins/health.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="ping",b="display",A="view";const O=["sitegroup_id","session_id","media_id","site_id","player_id","video_type"],T=["created","position"],M=["player_version","created","source","category","category_id","autoplay","muted","customer_user_id"];function S(e,t){return e.duration/1===e.duration&&Object.assign(t,function(e){const t=e/100;return{segment_duration:t,breakpoints:Array(...Array(100)).map((function(e,n){return Math.floor(n*t*1e3)/1e3}))}}(e.duration))}function P(e,t,n){if(!t.segment_duration&&!S(e,t))return;const r=function(e,t,n){const r=t.last_idx,i=n?99:R(e,t);return t.last_idx=i,i<=r?[]:t.breakpoints.slice(r,99==i?100:i).map((function(e){return t.breakpoints.indexOf(e)}))}(e,t,n);0!=r.length&&e.emit(E,{position:r})}function R(e,t){return Math.min(Math.floor(e.currentTime/t.segment_duration),99)}const x="vod",N="live",I=[b,E,A];function L(e,t,n){switch(null==t?void 0:t.kind){case"live":return function(e,t){const n=Date.now();n-t.last_tracked_ts<6e4||(t.last_tracked_ts=n,++t.ticks,e.emit(E,{position:60*t.ticks}))}(e,t);case"vod":return P(e,t,"boolean"==typeof n&&n)}}function j(e){const t=e.ads;return void 0!==t&&(void 0!==t.schedule&&("function"==typeof t.hasPreroll&&(t.currentRequests?t.currentRequests:!!t.adPlaying||!(!t.hasPreroll()||0!=t.nextIndex))))}function q(){try{return window.location!==window.parent.location?document.referrer:document.location.href}catch(e){return!1}}class Analytics{init(e,t,n){if(!w.from_token(e.token||"").is_granted(w.permissions.ANALYTICS))return;if(n.analytics)return;const r=n.analytics={ticker:void 0,last_media_id:"",ended:!1},i={locked:!1,ttl:6e3,task:()=>{L(n,r.ticker)}};const o={session_id:n.deviceId(),autoplay:n.autoplay,muted:n.muted,player_id:e.player_id,customer_user_id:e.customer_user_id},a=c.Tracker.of(n,{verb:c.Tracker.verb.POST,url:"https://ptm.flowplayer.com/:video_type/:sitegroup_id/:event_type",events:I,required_keys:O,optional_keys:M.concat(T).slice(0),metadata:o});n.on("reap",(function(){a&&a.destroy()})),n.on("config",(function(t){if(!a)return;const i=k(t,"data.metadata",{});if(!i.media_id)return;const o=k(a,"metadata.media_id");if(o&&i.media_id==o)return;const u=k(e,"analytics",{});a.put(i),a.put(u);const s=k(e,"metadata.live_start_time",e.live)?N:x;a.put({video_type:s,source:e.source||q()||""}),r.ticker=e.live?{ticks:0,last_tracked_ts:Date.now(),kind:"live"}:{last_idx:0,segment_duration:0,breakpoints:[],kind:"vod"},r.ended=!1,n.emit(b)}));let u=0;n.on("playing",(function(){if(!a)return;if(u||function(e,t){return e.metadata.media_id&&e.metadata.media_id==t.last_media_id}(a,r))return;a.put({muted:n.muted});const e=j(n);if(e)return u=Promise.resolve(e).then((function(){r.last_media_id=a.metadata.media_id,n.emit(A),u=0})).catch((function(){u=0}));r.last_media_id=a.metadata.media_id,n.emit(A)})),n.on("timeupdate",(function(){var t;a&&(u||j(n)||r.ended||(!e.live&&n.currentTime+.25>=n.duration&&L(n,r.ticker,!0),(t=i).locked||(t.locked=setTimeout((function(){return t.task(),function(e){return e.locked=!1,e}(t)}),t.ttl))))})),n.on("seeked",(function(){a&&r.ticker&&"vod"==r.ticker.kind&&function(e,t){S(e,t),t.last_idx=R(e,t)}(n,r.ticker)})),n.on("ended",(function(){a&&function(e,t){t.ended||(t.ended=!0,L(e,t.ticker))}(n,r)}))}}return function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;"function"==typeof n?n(t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t))}("undefined"!=typeof window?window:"undefined"!=typeof global?global:{},Analytics),Analytics}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.analytics=t())}(this,(function(){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function t(e){var t={exports:{}};return e(t,t.exports),t.exports}var n,r=t((function(t,n){var r=e&&e.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};n.__esModule=!0,n.remove=n.downcase=n.pluck=n.merge=void 0,n.merge=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e.reduce((function(e,t){return r(r({},e),t)}),{})},n.pluck=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return Object.keys(e).filter((function(e){return~t.indexOf(e)})).reduce((function(t,r){var i;return n.merge(t,((i={})[r]=e[r],i))}),{})},n.downcase=function(e){return(e||"").toString().toLowerCase()},n.remove=function(e,t){var n=e.lastIndexOf(t);return~n&&e.splice(n,1),e}})),i=t((function(t,n){var i=e&&e.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=e&&e.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.hasOwnProperty.call(e,n)&&i(t,e,n);return o(t,e),t};n.__esModule=!0;var u=a(r),s=function(){function e(){this.pending=[],this.open=[],this.stats={failures:0,ttl:0}}return e.of=function(){return new e},e.is_empty=function(e){return 0==e.pending.length},e.is_high_water=function(t){return t.open.length==e.MAX_OPEN_REQUESTS},e.maybe_spawn_req=function(t){if(e.is_empty(t))return t;if(e.is_high_water(t))return t;try{var n=e.lpop(t);n&&e.request(t,n)}catch(e){}},e.increment_failures=function(t){return t.stats.failures++,t.stats.failures>e.MAX_FAILURE_COUNT&&(t.stats.ttl=Date.now()+e.REQUEST_TTL_MS),t},e.handle_error=function(t,n){e.rm(t,n),e.increment_failures(t)},e.request=function(t,n){var r=n[0],i=n[1],o=n[2];if(!(Date.now()<t.stats.ttl)){var a=new XMLHttpRequest;t.open.push(a),a.timeout=e.REQUEST_TIMEOUT_MS,a.ontimeout=function(){e.handle_error(t,a)},a.onerror=function(n){e.handle_error(t,a)},a.onreadystatechange=function(){a.readyState==XMLHttpRequest.DONE&&e.rm(t,a),Math.floor(a.status/100)},a.onload=function(){e.rm(t,a),t.stats.failures&&t.stats.failures--},a.open(i,r),a.setRequestHeader("Content-Type","text/plain;charset=UTF-8");try{a.send(JSON.stringify(o))}catch(e){}}},e.rpush=function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];return n.forEach((function(n){t.pending.length>=e.MAX_PENDING||(t.pending.push(n),e.maybe_spawn_req(t))})),t},e.lpop=function(e){return e.pending.shift()},e.rm=function(e,t){return u.remove(e.open,t),e},e.MAX_OPEN_REQUESTS=3,e.MAX_PENDING=5,e.REQUEST_TIMEOUT_MS=4e3,e.REQUEST_TTL_MS=5e3,e.MAX_FAILURE_COUNT=3,e}();n.default=s})),o=t((function(t,n){var r=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};n.__esModule=!0;var o=r(i);n.default=o.default.of()})),a=t((function(e,t){t.__esModule=!0,t.prepare_url=t.URL_PARAM=void 0,t.URL_PARAM=/:([a-zA-Z_]+)/g,t.prepare_url=function(e,n){return e.url.replace(t.URL_PARAM,(function(t){if((t=t.slice(1,t.length))in n)return n[t].toString();e.log.error(new Error("\n preparing url["+e.url+"] failed\n \n parameter["+t+"] not detected in params:\n \n "+JSON.stringify(n,null,2)+"\n "))}))}})),u=t((function(e,t){t.__esModule=!0,t.Log=void 0;var n=function(){function e(e){this.emitter=e}return e.prepare=function(e,t){var n=document.createEvent("Event");return n.initEvent(e,!1,!0),n.ns=e,n.data=t,n},e.of=function(t){return new e(t)},e.prototype.info=function(t){this.emitter.dispatchEvent(e.prepare(e.NAMESPACE.INFO,t))},e.prototype.error=function(t){this.emitter.dispatchEvent(e.prepare(e.NAMESPACE.ERROR,t))},e.prototype.warn=function(t){this.emitter.dispatchEvent(e.prepare(e.NAMESPACE.WARN,t))},e.NAMESPACE={INFO:"tracker:info",ERROR:"tracker:err",WARN:"tracker:warn"},e}();t.Log=n})),s=t((function(e,t){var n;t.__esModule=!0,t.Verb=void 0,(n=t.Verb||(t.Verb={})).POST="POST",n.PUT="PUT",n.GET="GET"})),d=t((function(t,n){var d=e&&e.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),c=e&&e.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),f=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.hasOwnProperty.call(e,n)&&d(t,e,n);return c(t,e),t},l=e&&e.__spreadArrays||function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),i=0;for(t=0;t<n;t++)for(var o=arguments[t],a=0,u=o.length;a<u;a++,i++)r[i]=o[a];return r},p=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};n.__esModule=!0;var _=p(o),v=p(i),m=f(a),h=f(r),y=function(){function e(t,n){var r=this;void 0===n&&(n={});var i=this;if(this.emitter=t,this.url=n.url,this.log=u.Log.of(this.emitter),this.verb=n.verb,this.metadata=h.merge({},n.metadata||{}),this.rq=n.rq||_.default,this.events=n.events||[],this.required_keys=n.required_keys||[],this.optional_keys=n.optional_keys||[],this.listeners=[],this.valid_keys=this.required_keys.slice(0).concat(this.optional_keys),e.assert_emitter_api(this.emitter),void 0===e.verb[this.verb])throw new Error("invalid HTTP verb["+this.verb+"] passed");if("string"!=typeof this.url)throw new Error("invalid API url["+this.url+"] passed");e.TRACKERS.push(this),i.events.forEach((function(t){e.create_listener(r,t,(function(n){void 0===n&&(n={});var o=h.merge(i.metadata,{event_type:t},n.data||n),a=m.prepare_url(i,o),u=e.pluck_valid_keys(i,o),s=e.ensure_required_keys(i,u);if(s.length)return i.log.error("Tracker.validate_metadata() failed for \n Event["+t+"]\n missing keys: "+s+"\n payload:\n "+JSON.stringify(u,null,2));v.default.rpush(r.rq,[a,r.verb,u])}))}))}return e.of=function(t,n){return new e(t,n)},e.ensure_required_keys=function(e,t){return e.required_keys.filter((function(e){return!(e in t)}))},e.pluck_valid_keys=function(e,t){return h.pluck.apply(h,l([t],e.valid_keys))},e.merge_metadata=function(t,n){return void 0===n&&(n={}),t.metadata=e.pluck_valid_keys(t,h.merge(t.metadata,n)),t},e.assert_emitter_api=function(e){if("function"!=typeof(e||{}).addEventListener)throw new Error("Tracker() received an emitter that does not implement the addEventListener method");if("function"!=typeof(e||{}).removeEventListener)throw new Error("Tracker() received an emitter that does not implement the removeEventListener method")},e.create_listener=function(e,t,n){e.listeners.push([t,n]),e.emitter.addEventListener(t,n)},e.prototype.destroy=function(){var t=this;this.listeners.forEach((function(e){var n=e[0],r=e[1];return t.emitter.removeEventListener(n,r)})),delete this.rq,delete this.emitter,h.remove(e.TRACKERS,this)},e.prototype.put=function(t){return void 0===t&&(t={}),e.merge_metadata(this,t),this},e.TRACKERS=[],e.QUEUE=_.default,e.verb=s.Verb,e}();n.default=y})),c=t((function(t,n){var r=e&&e.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=e&&e.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.hasOwnProperty.call(e,n)&&r(t,e,n);return i(t,e),t},u=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};n.__esModule=!0,n.API=n.Tracker=void 0;var s=u(d);n.Tracker=s.default;var c=o(a);n.API=c}));!function(e){e[e.ADS=2]="ADS",e[e.ANALYTICS=4]="ANALYTICS",e[e.NO_METERING=8]="NO_METERING",e[e.DEVELOPER_PLAN=16]="DEVELOPER_PLAN"}(n||(n={}));const f=["localhost","127.0.0.1","0.0.0.0","s.codepen.io","cdpn.io","try.flowplayer.com"];function l(e,t){return!!~f.indexOf(e)||e.indexOf(t)===e.length-t.length}l.check_whitelist=function(e){return!!~f.indexOf(e)};function p(e){this.message=e}p.prototype=new Error,p.prototype.name="InvalidCharacterError";var _="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new p("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,r,i=0,o=0,a="";r=t.charAt(o++);~r&&(n=i%4?64*n+r:r,i++%4)?a+=String.fromCharCode(255&n>>(-2*i&6)):0)r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(r);return a};var v=function(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(_(e).replace(/(.)/g,(function(e,t){var n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return _(t)}};function m(e){this.message=e}m.prototype=new Error,m.prototype.name="InvalidTokenError";var h=function(e,t){if("string"!=typeof e)throw new m("Invalid token specified");var n=!0===(t=t||{}).header?0:1;try{return JSON.parse(v(e.split(".")[n]))}catch(e){throw new m("Invalid token specified: "+e.message)}};h.InvalidTokenError=m;const y="production";function g(e,t){const n={valid_jwt:!1,raw:"",data:{acl:0},exp:0};let r={c:"{}",exp:0};t=t||{};try{r=h(e),n.valid_jwt=!0}catch(e){}return n.raw=e,n.data=JSON.parse(r.c),n.exp=r.exp,t.require_valid_token&&g.validate(n),n}function w(e){return{grant:e,is_granted:t=>(e&t)===t}}function k(e,t,n){const r=function(e){return Array.isArray(e)?e.slice(0):e.split(".")}(t);for(;r.length;){if(null==e)return n;const t=r.shift();if("string"!=typeof t)return n;e=e[t]}return null==e?n:e}g.validate=function(e){if("string"==typeof e&&(e=g(e)),!e||!e.raw){if(l.check_whitelist(window.location.hostname)||"dev"===y.toString())return!0;throw new Error("No token provided in configuration")}if(!e.valid_jwt)throw new Error("Invalid token provided");const t=window.location.hostname,n=l.bind(null,t);if("dev"!==y.toString()&&e.data.domain&&e.data.domain.length&&!e.data.domain.some(n))throw new Error("Domain not allowed");if("dev"!==y.toString()&&1e3*e.exp-Date.now()<0)throw new Error("Expired token");return!0},g.id=function(e){if(e)return"string"==typeof e&&(e=g(e)),e.data.id},w.of=w,w.from_token=function(e){const t=g(e,{require_valid_token:!0});return w.of(t.data.acl)},w.permissions=n;var E="ping",b="display",A="view";const O=["sitegroup_id","session_id","media_id","site_id","player_id","video_type"],T=["created","position"],S=["player_version","created","source","category","category_id","autoplay","muted","customer_user_id"];function M(e,t){return e.duration/1===e.duration&&Object.assign(t,function(e){const t=e/100;return{segment_duration:t,breakpoints:Array(...Array(100)).map((function(e,n){return Math.floor(n*t*1e3)/1e3}))}}(e.duration))}function P(e,t,n){if(!t.segment_duration&&!M(e,t))return;const r=function(e,t,n){const r=t.last_idx,i=n?99:R(e,t);return t.last_idx=i,i<=r?[]:t.breakpoints.slice(r,99==i?100:i).map((function(e){return t.breakpoints.indexOf(e)}))}(e,t,n);0!=r.length&&e.emit(E,{position:r})}function R(e,t){return Math.min(Math.floor(e.currentTime/t.segment_duration),99)}const x="vod",N="live",I=[b,E,A];function L(e,t,n){switch(null==t?void 0:t.kind){case"live":return function(e,t){const n=Date.now();n-t.last_tracked_ts<6e4||(t.last_tracked_ts=n,++t.ticks,e.emit(E,{position:60*t.ticks}))}(e,t);case"vod":return P(e,t,"boolean"==typeof n&&n)}}function j(e){const t=e.ads;return void 0!==t&&(void 0!==t.schedule&&("function"==typeof t.hasPreroll&&(t.currentRequests?t.currentRequests:!!t.adPlaying||!(!t.hasPreroll()||0!=t.nextIndex))))}function q(){try{return window.location!==window.parent.location?document.referrer:document.location.href}catch(e){return!1}}class Analytics{init(e,t,n){if(!w.from_token(e.token||"").is_granted(w.permissions.ANALYTICS))return;if(n.hasState("consent-no-tracking"))return;if(n.analytics)return;const r=n.analytics={ticker:void 0,last_media_id:"",ended:!1},i={locked:!1,ttl:6e3,task:()=>{L(n,r.ticker)}};const o={session_id:n.deviceId(),autoplay:n.autoplay,muted:n.muted,player_id:e.player_id,customer_user_id:e.customer_user_id},a=c.Tracker.of(n,{verb:c.Tracker.verb.POST,url:"https://ptm.flowplayer.com/:video_type/:sitegroup_id/:event_type",events:I,required_keys:O,optional_keys:S.concat(T).slice(0),metadata:o});n.on("reap",(function(){a&&a.destroy()})),n.on("config",(function(t){if(!a)return;const i=k(t,"data.metadata",{});if(!i.media_id)return;const o=k(a,"metadata.media_id");if(o&&i.media_id==o)return;const u=k(e,"analytics",{});a.put(i),a.put(u);const s=k(e,"metadata.live_start_time",e.live)?N:x;a.put({video_type:s,source:e.source||q()||""}),r.ticker=e.live?{ticks:0,last_tracked_ts:Date.now(),kind:"live"}:{last_idx:0,segment_duration:0,breakpoints:[],kind:"vod"},r.ended=!1,n.emit(b)}));let u=0;n.on("playing",(function(){if(!a)return;if(u||function(e,t){return e.metadata.media_id&&e.metadata.media_id==t.last_media_id}(a,r))return;a.put({muted:n.muted});const e=j(n);if(e)return u=Promise.resolve(e).then((function(){r.last_media_id=a.metadata.media_id,n.emit(A),u=0})).catch((function(){u=0}));r.last_media_id=a.metadata.media_id,n.emit(A)})),n.on("timeupdate",(function(){var t;a&&(u||j(n)||r.ended||(!e.live&&n.currentTime+.25>=n.duration&&L(n,r.ticker,!0),(t=i).locked||(t.locked=setTimeout((function(){return t.task(),function(e){return e.locked=!1,e}(t)}),t.ttl))))})),n.on("seeked",(function(){a&&r.ticker&&"vod"==r.ticker.kind&&function(e,t){M(e,t),t.last_idx=R(e,t)}(n,r.ticker)})),n.on("ended",(function(){a&&function(e,t){t.ended||(t.ended=!0,L(e,t.ticker))}(n,r)}))}}return function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;"function"==typeof n?n(t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t))}("undefined"!=typeof window?window:"undefined"!=typeof global?global:{},Analytics),Analytics}));
|
package/plugins/consent.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.consent=t())}(this,(function(){"use strict";class PlayerStorage{constructor(e,t){this.implementation=e,t&&
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.consent=t())}(this,(function(){"use strict";class PlayerStorage{constructor(e,t){this.implementation=e,t&&t.keys().forEach(e=>{"string"==typeof t.implementation[e]&&this.implementation.setItem(e,t.implementation[e])})}keys(){var e;const t=[];for(var n=0;n<this.implementation.length;n++)(null===(e=this.implementation.key(n))||void 0===e?void 0:e.startsWith("flowplayer/"))&&t.push(this.implementation.key(n));return t}removeItem(e){try{this.implementation.removeItem("flowplayer/"+e)}catch(e){}}getItem(e){try{return this.implementation.getItem("flowplayer/"+e)}catch(e){return null}}setItem(e,t){try{this.implementation.setItem("flowplayer/"+e,t)}catch(e){}}clear(){try{this.keys().forEach(e=>this.implementation.removeItem(e))}catch(e){}}get length(){try{return this.keys().length}catch(e){return 0}}key(e){try{return this.implementation.key(e)}catch(e){return null}}}var e,t;!function(e){e[e.ALL=1]="ALL",e[e.NONE=2]="NONE"}(e||(e={})),function(e){e[e.ALL=8]="ALL",e[e.NONE=16]="NONE"}(t||(t={}));class ConsentPlugin{constructor(n,s){const o=s._storage.getItem("consent"),r=this.current_value=o&&!isNaN(Number(o))?Number(s._storage.getItem("consent")):e.NONE|t.NONE;this.player=s,this.adapt(Object.assign({consent:r},s.opts))}init(e,t,n){this.adapt(e),n.on("config",e=>{this.adapt(e.detail)});const s=e=>{n.setOpts({consent:e.detail})};document.addEventListener("flowplayer/consent",s),n.on("reap",()=>document.removeEventListener("flowplayer/consent",s))}adapt(n){const s=void 0===n.consent?this.current_value:n.consent;t.ALL&s?this.setStorage(t.ALL):t.NONE&s&&this.setStorage(t.NONE),e.ALL&s?this.setTracking(e.ALL):e.NONE&s&&this.setTracking(e.NONE),this.player._storage.setItem("consent",s.toString())}setStorage(e){const n=this.player._storage;switch(this.player.setState("consent-no-storage",e===t.NONE),e){case t.ALL:this.player._storage=new PlayerStorage(localStorage,this.player._storage);break;case t.NONE:this.player._storage=new PlayerStorage(sessionStorage,n),n.clear()}}setTracking(t){var n,s;switch(this.player.setState("consent-no-tracking",t===e.NONE),t){case e.ALL:null===(n=this.player.health)||void 0===n||n.toggle(!0);break;case e.NONE:null===(s=this.player.health)||void 0===s||s.toggle(!1)}}}return ConsentPlugin.tracking=e,ConsentPlugin.storage=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,ConsentPlugin)}));
|
package/plugins/gemius.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(i,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((i="undefined"!=typeof globalThis?globalThis:i||self).flowplayer=i.flowplayer||{},i.flowplayer.gemius=e())}(this,(function(){"use strict";function i(i,e,t){const r=function(i){return Array.isArray(i)?i.slice(0):i.split(".")}(e);for(;r.length;){if(null==i)return t;const e=r.shift();if("string"!=typeof e)return t;i=i[e]}return null==i?t:i}const e=["playerID","gemiusID"],t=["programID","additionalParameters.programName","additionalParameters.programType","additionalParameters.programDuration"],r=["adName","adDuration","adType","campaignClassification","quality","resolution","volume"];function s(e,t){const r=[];return t.forEach((function(t){void 0===i(e,t)&&r.push(t)})),r.length&&console.warn("Missing Gemius configuration: ",r.join(", ")),0===r.length}function a(i){return i<.5||isNaN(i)?0:Math.round(i)}function n(i,e){return-1===i||e?-1:Math.max(0,Math.min(100,Math.round(100*i)))}return function(i,e){if("object"==typeof exports&&"undefined"!=typeof module)return e;"flowplayer"in i||(i.flowplayer={extensions:[]});const t=i.flowplayer;return"function"==typeof t?(t(e),e):(Array.isArray(t.extensions)||(t.extensions=[]),~t.extensions.indexOf(e)||t.extensions.push(e),e)}(window,class GemiusPlugin{constructor(i){this.started=!1,this.starting=!1,this.paused=!1,this.seeking=!1,this.buffering=!1,this.currentTime=0,this.flowplayer=i}init(i,e,t){if("function"!=typeof GemiusPlayer)return console.warn("Gemius SDK needs to be loaded prior loading gemius plugin");if(!i.gemius)return console.warn("Gemius plugin loaded but not configured");if(this.gemius=i.gemius,t.on("reap",()=>{this.gemiusPlayer&&this.gemius&&this.gemius.programID&&this.gemiusPlayer.programEvent(this.gemius.programID,a(t.currentTime),"stop"),this.gemiusPlayer=void 0,this.resetParams(),window.removeEventListener("beforeunload",this.handle_window_unload.bind(this,t))}),window.addEventListener("beforeunload",this.handle_window_unload.bind(this,t)),t.on(["config","loadedmetadata","src","loadstart"],e=>{var r,s;(null===(r=e.data)||void 0===r?void 0:r.gemius)&&(this.gemius=Object.assign(Object.assign({},this.gemius),null===(s=e.data)||void 0===s?void 0:s.gemius)),e.type===this.getInitEventType(i)&&this.initGemius(i,t)}),t.on("volumechange",()=>{var i;this.gemiusPlayer&&(null===(i=this.gemius)||void 0===i?void 0:i.programID)&&this.gemiusPlayer.programEvent(this.gemius.programID,a(t.currentTime),"chngVol",{volume:n(t.volume,t.muted)})}),t.on("resize",()=>{var i;this.gemiusPlayer&&(null===(i=this.gemius)||void 0===i?void 0:i.programID)&&(this.sendPlayWithRequiremets(t),this.gemiusPlayer.programEvent(this.gemius.programID,a(t.currentTime),"chngRes",{resolution:t.clientWidth+"x"+t.clientHeight}))}),t.on("play",()=>{this.buffering=!1,this.starting=!0,this.started?this.sendPlay(t):this.sendPlayWithRequiremets(t),this.paused=!1}),t.on("ended",()=>{var i;this.started&&(this.resetParams(),this.gemiusPlayer&&(null===(i=this.gemius)||void 0===i?void 0:i.programID)&&this.gemiusPlayer.programEvent(this.gemius.programID,a(t.currentTime),"complete"))}),t.on("seeking",()=>{var i;this.started&&!this.seeking&&(this.seeking=!0,this.gemiusPlayer&&(null===(i=this.gemius)||void 0===i?void 0:i.programID)&&this.gemiusPlayer.programEvent(this.gemius.programID,this.currentTime,"seek"))}),t.on("seeked",()=>{var i;this.started&&!this.paused&&(this.seeking=!1,this.gemiusPlayer&&(null===(i=this.gemius)||void 0===i?void 0:i.programID)&&this.gemiusPlayer.programEvent(this.gemius.programID,a(t.currentTime),"play",{autoPlay:this.gemius.additionalParameters.autoPlay,volume:n(this.gemius.additionalParameters.volume||0)||0}))}),t.on("pause",()=>{var e;this.started&&t.currentTime>.25&&(i.live||i.duration&&i.duration-t.currentTime>.25)&&(this.paused=!0,this.gemiusPlayer&&(null===(e=this.gemius)||void 0===e?void 0:e.programID)&&this.gemiusPlayer.programEvent(this.gemius.programID,a(t.currentTime),"pause"))}),t.on("waiting",()=>{var i;!this.buffering&&t.currentTime>.5&&(this.buffering=!0,this.gemiusPlayer&&(null===(i=this.gemius)||void 0===i?void 0:i.programID)&&this.gemiusPlayer.programEvent(this.gemius.programID,a(t.currentTime),"buffer"))}),t.on("timeupdate",()=>{this.currentTime=Math.round(t.currentTime)}),t.ads){const i=this.flowplayer.AdEvents;t.ads.on(i.AD_STARTED,i=>{var e,t,s;(this.paused=!1,this.currentAd={id:i.vast_ad_id||"unknown id",duration:(null===(e=i.ad)||void 0===e?void 0:e.duration)||-1,currentTime:0},this.gemiusPlayer&&(null===(t=this.gemius)||void 0===t?void 0:t.programID))&&(this.gemiusPlayer.newAd(i.vast_ad_id,(s=Object.assign({},this.gemius.additionalParameters,function(i){var e,t,r;return{adDuration:null===(e=i.ad)||void 0===e?void 0:e.duration,adType:i.ad_type,resolution:(null===(t=i.ad)||void 0===t?void 0:t.width)+"x"+(null===(r=i.ad)||void 0===r?void 0:r.height),volume:n(i.volume)}}(i)),r.reduce((function(i,e){return s&&s.hasOwnProperty(e)&&(i[e]=s[e]),i}),{}))),this.gemiusPlayer.adEvent(this.gemius.programID,this.currentAd.id,0,"play",{autoPlay:this.gemius.additionalParameters.autoPlay,volume:n(i.volume)}))}),t.ads.on(i.AD_PAUSED,()=>{var i;this.paused=!0,this.currentAd&&this.gemiusPlayer&&(null===(i=this.gemius)||void 0===i?void 0:i.programID)&&this.gemiusPlayer.adEvent(this.gemius.programID,this.currentAd.id,this.currentAd.currentTime,"pause")}),t.ads.on(i.AD_RESUMED,i=>{var e;if(this.currentAd&&this.paused){if(this.paused=!1,!this.gemiusPlayer||!(null===(e=this.gemius)||void 0===e?void 0:e.programID))return;this.gemiusPlayer.adEvent(this.gemius.programID,this.currentAd.id,this.currentAd.currentTime,"play",{autoPlay:this.gemius.additionalParameters.autoPlay,volume:n(i.volume)})}}),t.ads.on(i.AD_COMPLETED,()=>{var i;if(this.currentAd){if(!this.gemiusPlayer||!(null===(i=this.gemius)||void 0===i?void 0:i.programID))return;this.gemiusPlayer.adEvent(this.gemius.programID,this.currentAd.id,this.currentAd.duration,"complete"),this.currentAd=void 0}}),t.ads.on(i.AD_PROGRESS,i=>{this.currentAd&&(this.currentAd.currentTime=Math.round(i.duration-i.remaining)||0)}),t.ads.on(i.AD_VOLUME_CHANGED,i=>{var e;if(this.currentAd){const t=i||-1;if(!this.gemiusPlayer||!(null===(e=this.gemius)||void 0===e?void 0:e.programID))return;this.gemiusPlayer.adEvent(this.gemius.programID,this.currentAd.id,this.currentAd.duration,"chngVol",{volume:n(t)})}})}}resetParams(){this.seeking=!1,this.starting=!1,this.started=!1,this.paused=!1,this.buffering=!1,this.currentAd=void 0,this.currentTime=0}sendPlay(i){var e;this.gemiusPlayer&&(null===(e=this.gemius)||void 0===e?void 0:e.programID)&&(this.started=!0,this.gemiusPlayer.programEvent(this.gemius.programID,a(i.currentTime),"play",{autoPlay:this.gemius.additionalParameters.autoPlay,volume:n(this.gemius.additionalParameters.volume||0)}))}sendPlayWithRequiremets(i){this.starting&&!this.started&&i.videoWidth>0&&this.sendPlay(i)}getInitEventType(i){return!i.ima&&i.autoplay?"src":"loadstart"}initGemius(r,a){if(!s(i(r,"gemius",{}),e))return;if(!this.gemius)return;const u={currentDomain:this.gemius.additionalParameters.currentDomain,volume:n(this.gemius.additionalParameters.volume||0)};if(this.gemiusPlayer&&(this.gemiusPlayer=void 0),this.gemiusPlayer=new GemiusPlayer(this.gemius.playerID,this.gemius.gemiusID,u),this.gemiusPlayer.setVideoObject(a),!s(this.gemius,t))return;const o={programName:this.gemius.additionalParameters.programName,programDuration:this.gemius.additionalParameters.programDuration,programType:this.gemius.additionalParameters.programType,volume:n(this.gemius.additionalParameters.volume||0)};this.gemiusPlayer.newProgram(this.gemius.programID,o),this.sendPlayWithRequiremets(a)}handle_window_unload(i){var e;this.gemiusPlayer&&(null===(e=this.gemius)||void 0===e?void 0:e.programID)&&this.gemiusPlayer.programEvent(this.gemius.programID,a(i.currentTime),"close"),this.resetParams()}})}));
|
|
1
|
+
!function(i,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((i="undefined"!=typeof globalThis?globalThis:i||self).flowplayer=i.flowplayer||{},i.flowplayer.gemius=e())}(this,(function(){"use strict";function i(i,e,t){const r=function(i){return Array.isArray(i)?i.slice(0):i.split(".")}(e);for(;r.length;){if(null==i)return t;const e=r.shift();if("string"!=typeof e)return t;i=i[e]}return null==i?t:i}const e=["playerID","gemiusID"],t=["programID","additionalParameters.programName","additionalParameters.programType","additionalParameters.programDuration"],r=["adName","adDuration","adType","campaignClassification","quality","resolution","volume"];function s(e,t){const r=[];return t.forEach((function(t){void 0===i(e,t)&&r.push(t)})),r.length&&console.warn("Missing Gemius configuration: ",r.join(", ")),0===r.length}function a(i){return i<.5||isNaN(i)?0:Math.round(i)}function n(i,e){return-1===i||e?-1:Math.max(0,Math.min(100,Math.round(100*i)))}return function(i,e){if("object"==typeof exports&&"undefined"!=typeof module)return e;"flowplayer"in i||(i.flowplayer={extensions:[]});const t=i.flowplayer;return"function"==typeof t?(t(e),e):(Array.isArray(t.extensions)||(t.extensions=[]),~t.extensions.indexOf(e)||t.extensions.push(e),e)}(window,class GemiusPlugin{constructor(i){this.started=!1,this.starting=!1,this.paused=!1,this.seeking=!1,this.buffering=!1,this.currentTime=0,this.flowplayer=i}init(i,e,t){if("function"!=typeof GemiusPlayer)return console.warn("Gemius SDK needs to be loaded prior loading gemius plugin");if(!i.gemius)return console.warn("Gemius plugin loaded but not configured");if(!t.hasState("consent-no-tracking")&&(this.gemius=i.gemius,t.on("reap",()=>{this.gemiusPlayer&&this.gemius&&this.gemius.programID&&this.gemiusPlayer.programEvent(this.gemius.programID,a(t.currentTime),"stop"),this.gemiusPlayer=void 0,this.resetParams(),window.removeEventListener("beforeunload",this.handle_window_unload.bind(this,t))}),window.addEventListener("beforeunload",this.handle_window_unload.bind(this,t)),t.on(["config","loadedmetadata","src","loadstart"],e=>{var r,s;(null===(r=e.data)||void 0===r?void 0:r.gemius)&&(this.gemius=Object.assign(Object.assign({},this.gemius),null===(s=e.data)||void 0===s?void 0:s.gemius)),e.type===this.getInitEventType(i)&&this.initGemius(i,t)}),t.on("volumechange",()=>{var i;this.gemiusPlayer&&(null===(i=this.gemius)||void 0===i?void 0:i.programID)&&this.gemiusPlayer.programEvent(this.gemius.programID,a(t.currentTime),"chngVol",{volume:n(t.volume,t.muted)})}),t.on("resize",()=>{var i;this.gemiusPlayer&&(null===(i=this.gemius)||void 0===i?void 0:i.programID)&&(this.sendPlayWithRequiremets(t),this.gemiusPlayer.programEvent(this.gemius.programID,a(t.currentTime),"chngRes",{resolution:t.clientWidth+"x"+t.clientHeight}))}),t.on("play",()=>{this.buffering=!1,this.starting=!0,this.started?this.sendPlay(t):this.sendPlayWithRequiremets(t),this.paused=!1}),t.on("ended",()=>{var i;this.started&&(this.resetParams(),this.gemiusPlayer&&(null===(i=this.gemius)||void 0===i?void 0:i.programID)&&this.gemiusPlayer.programEvent(this.gemius.programID,a(t.currentTime),"complete"))}),t.on("seeking",()=>{var i;this.started&&!this.seeking&&(this.seeking=!0,this.gemiusPlayer&&(null===(i=this.gemius)||void 0===i?void 0:i.programID)&&this.gemiusPlayer.programEvent(this.gemius.programID,this.currentTime,"seek"))}),t.on("seeked",()=>{var i;this.started&&!this.paused&&(this.seeking=!1,this.gemiusPlayer&&(null===(i=this.gemius)||void 0===i?void 0:i.programID)&&this.gemiusPlayer.programEvent(this.gemius.programID,a(t.currentTime),"play",{autoPlay:this.gemius.additionalParameters.autoPlay,volume:n(this.gemius.additionalParameters.volume||0)||0}))}),t.on("pause",()=>{var e;this.started&&t.currentTime>.25&&(i.live||i.duration&&i.duration-t.currentTime>.25)&&(this.paused=!0,this.gemiusPlayer&&(null===(e=this.gemius)||void 0===e?void 0:e.programID)&&this.gemiusPlayer.programEvent(this.gemius.programID,a(t.currentTime),"pause"))}),t.on("waiting",()=>{var i;!this.buffering&&t.currentTime>.5&&(this.buffering=!0,this.gemiusPlayer&&(null===(i=this.gemius)||void 0===i?void 0:i.programID)&&this.gemiusPlayer.programEvent(this.gemius.programID,a(t.currentTime),"buffer"))}),t.on("timeupdate",()=>{this.currentTime=Math.round(t.currentTime)}),t.ads)){const i=this.flowplayer.AdEvents;t.ads.on(i.AD_STARTED,i=>{var e,t,s;(this.paused=!1,this.currentAd={id:i.vast_ad_id||"unknown id",duration:(null===(e=i.ad)||void 0===e?void 0:e.duration)||-1,currentTime:0},this.gemiusPlayer&&(null===(t=this.gemius)||void 0===t?void 0:t.programID))&&(this.gemiusPlayer.newAd(i.vast_ad_id,(s=Object.assign({},this.gemius.additionalParameters,function(i){var e,t,r;return{adDuration:null===(e=i.ad)||void 0===e?void 0:e.duration,adType:i.ad_type,resolution:(null===(t=i.ad)||void 0===t?void 0:t.width)+"x"+(null===(r=i.ad)||void 0===r?void 0:r.height),volume:n(i.volume)}}(i)),r.reduce((function(i,e){return s&&s.hasOwnProperty(e)&&(i[e]=s[e]),i}),{}))),this.gemiusPlayer.adEvent(this.gemius.programID,this.currentAd.id,0,"play",{autoPlay:this.gemius.additionalParameters.autoPlay,volume:n(i.volume)}))}),t.ads.on(i.AD_PAUSED,()=>{var i;this.paused=!0,this.currentAd&&this.gemiusPlayer&&(null===(i=this.gemius)||void 0===i?void 0:i.programID)&&this.gemiusPlayer.adEvent(this.gemius.programID,this.currentAd.id,this.currentAd.currentTime,"pause")}),t.ads.on(i.AD_RESUMED,i=>{var e;if(this.currentAd&&this.paused){if(this.paused=!1,!this.gemiusPlayer||!(null===(e=this.gemius)||void 0===e?void 0:e.programID))return;this.gemiusPlayer.adEvent(this.gemius.programID,this.currentAd.id,this.currentAd.currentTime,"play",{autoPlay:this.gemius.additionalParameters.autoPlay,volume:n(i.volume)})}}),t.ads.on(i.AD_COMPLETED,()=>{var i;if(this.currentAd){if(!this.gemiusPlayer||!(null===(i=this.gemius)||void 0===i?void 0:i.programID))return;this.gemiusPlayer.adEvent(this.gemius.programID,this.currentAd.id,this.currentAd.duration,"complete"),this.currentAd=void 0}}),t.ads.on(i.AD_PROGRESS,i=>{this.currentAd&&(this.currentAd.currentTime=Math.round(i.duration-i.remaining)||0)}),t.ads.on(i.AD_VOLUME_CHANGED,i=>{var e;if(this.currentAd){const t=i||-1;if(!this.gemiusPlayer||!(null===(e=this.gemius)||void 0===e?void 0:e.programID))return;this.gemiusPlayer.adEvent(this.gemius.programID,this.currentAd.id,this.currentAd.duration,"chngVol",{volume:n(t)})}})}}resetParams(){this.seeking=!1,this.starting=!1,this.started=!1,this.paused=!1,this.buffering=!1,this.currentAd=void 0,this.currentTime=0}sendPlay(i){var e;this.gemiusPlayer&&(null===(e=this.gemius)||void 0===e?void 0:e.programID)&&(this.started=!0,this.gemiusPlayer.programEvent(this.gemius.programID,a(i.currentTime),"play",{autoPlay:this.gemius.additionalParameters.autoPlay,volume:n(this.gemius.additionalParameters.volume||0)}))}sendPlayWithRequiremets(i){this.starting&&!this.started&&i.videoWidth>0&&this.sendPlay(i)}getInitEventType(i){return!i.ima&&i.autoplay?"src":"loadstart"}initGemius(r,a){if(!s(i(r,"gemius",{}),e))return;if(!this.gemius)return;const u={currentDomain:this.gemius.additionalParameters.currentDomain,volume:n(this.gemius.additionalParameters.volume||0)};if(this.gemiusPlayer&&(this.gemiusPlayer=void 0),this.gemiusPlayer=new GemiusPlayer(this.gemius.playerID,this.gemius.gemiusID,u),this.gemiusPlayer.setVideoObject(a),!s(this.gemius,t))return;const o={programName:this.gemius.additionalParameters.programName,programDuration:this.gemius.additionalParameters.programDuration,programType:this.gemius.additionalParameters.programType,volume:n(this.gemius.additionalParameters.volume||0)};this.gemiusPlayer.newProgram(this.gemius.programID,o),this.sendPlayWithRequiremets(a)}handle_window_unload(i){var e;this.gemiusPlayer&&(null===(e=this.gemius)||void 0===e?void 0:e.programID)&&this.gemiusPlayer.programEvent(this.gemius.programID,a(i.currentTime),"close"),this.resetParams()}})}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.google_analytics=t())}(this,(function(){"use strict";return function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const i=e.flowplayer;return"function"==typeof i?(i(t),t):(Array.isArray(i.extensions)||(i.extensions=[]),~i.extensions.indexOf(t)||i.extensions.push(t),t)}(window,class GoogleAnalyticsPlugin{constructor(e){this.started=!1,this.paused=!1,this.muted=!1,this.once=!0,this.liveflag=!1,this.ga_instances=[],this.ga_extensions=[],this.quartiles=[0,0,0],this.ad_type="preroll",this.preroll_counter=0,this.midroll_counter=0,this.postroll_counter=0,this.event_categories={live:"Live",videos:"Videos"},this.event_actions={fullscreen_enter:"fullscreen_enter",fullscreen_exit:"fullscreen_exit",video_player_load:"video_player_load",video_start:"video_start",video_click_play:"video_click_play",video_pause:"video_pause",video_resume:"video_resume",video_mute:"video_mute",video_unmute:"video_unmute",video_25_percent:"video_25_percent",video_50_percent:"video_50_percent",video_75_percent:"video_75_percent",video_complete:"video_complete",live_start:"live_start",live_click_play:"live_click_play",live_pause:"live_pause",live_resume:"live_resume",live_mute:"live_mute",live_unmute:"live_unmute",live_complete:"live_complete",ad_start_preroll:"ad_start_preroll",ad_start_midroll:"ad_start_midroll",ad_start_postroll:"ad_start_postroll",ad_completed_preroll:"ad_completed_preroll",ad_completed_midroll:"ad_completed_midroll",ad_completed_postroll:"ad_completed_postroll",ad_skipped_preroll:"ad_skipped_preroll",ad_skipped_midroll:"ad_skipped_midroll",ad_skipped_postroll:"ad_skipped_postroll",ad_break_completed:"ad_break_completed"},this.flowplayer=e}init(e,t,i){if(this.config=e,this.video=i,"object"!=typeof e.ga)return;const s=this.flowplayer.AdEvents||{AD_STARTED:"ad-started",AD_COMPLETED:"ad-completed",AD_SKIPPED:"ad-skipped",AD_BREAK_COMPLETED:"ad-break-completed"};this.muted=i.muted||!1,this.media_title=e.ga.media_title||"unknown video title",this.ga_instances=e.ga.ga_instances,e.ga.event_actions&&(this.event_actions=e.ga.event_actions),e.ga.event_categories&&(this.event_categories=e.ga.event_categories),i.on(["mount","timeupdate","loadstart","ended","seeked","seeking","pause","playing","volumechange",s.AD_STARTED,s.AD_COMPLETED,s.AD_SKIPPED,s.AD_BREAK_COMPLETED,"config","click","touchend","fullscreenenter","fullscreenexit"],e=>{switch(e.type){case"playing":this.playing(e.type);break;case"pause":this.pause();break;case"mount":this.loaded();break;case"timeupdate":this.progress();break;case"ended":this.ended();break;case"volumechange":this.volumechange();break;case"ad-started":this.adstarted(e);break;case"ad-completed":this.adcompleted(e);break;case"ad-break-completed":this.adbreakcompleted(e.type);break;case"config":this.configured(e);break;case"click":this.click();break;case"fullscreenenter":this.fullscreenenter();break;case"fullscreenexit":this.fullscreenexit();break;case"ad-skipped":this.adskipped()}})}setup_ga(){window.ga&&0===this.ga_extensions.length&&this.ga_instances.forEach((e,t)=>{var i;window.ga("create",e,"auto","ext"+(t+1)),(null===(i=this.config)||void 0===i?void 0:i.ga.custom_data)&&window.ga("ext"+(t+1)+".set",this.config.ga.custom_data),this.ga_extensions.push("ext"+(t+1))})}set_started(e){var t;(null===(t=this.config)||void 0===t?void 0:t.ga.start_on)===e&&(this.liveflag?this.track(this.event_actions.live_start):this.track(this.event_actions.video_start),this.started=!0)}click(){!this.paused&&this.started||(this.liveflag?this.track(this.event_actions.live_click_play):this.track(this.event_actions.video_click_play))}playing(e){this.started?this.paused&&(this.paused=!1,this.liveflag?this.track(this.event_actions.live_resume):this.track(this.event_actions.video_resume)):this.set_started(e)}pause(){this.video&&(Math.abs(this.video.duration-this.video.currentTime)<1||!this.started||(this.paused=!0,this.liveflag?this.track(this.event_actions.live_pause):this.track(this.event_actions.video_pause)))}loaded(){}progress(){!this.liveflag&&this.video&&(this.video.currentTime/this.video.duration>.25&&0===this.quartiles[0]?(this.quartiles[0]=1,this.track(this.event_actions.video_25_percent)):this.video.currentTime/this.video.duration>.5&&0===this.quartiles[1]?(this.quartiles[1]=1,this.track(this.event_actions.video_50_percent)):this.video.currentTime/this.video.duration>.75&&0===this.quartiles[2]&&(this.quartiles[2]=1,this.track(this.event_actions.video_75_percent)))}volumechange(){this.video&&(this.video.muted&&!this.muted?(this.muted=!0,this.liveflag?this.track(this.event_actions.live_mute):this.track(this.event_actions.video_mute)):!this.video.muted&&this.muted&&(this.muted=!1,this.liveflag?this.track(this.event_actions.live_unmute):this.track(this.event_actions.video_unmute)))}ended(){this.started&&(this.liveflag?this.track(this.event_actions.live_complete):this.track(this.event_actions.video_complete)),this.reset()}reset(){this.started=!1,this.quartiles=[0,0,0],this.once=!0,this.config&&(this.config.ga.start_on="playing"),this.preroll_counter=0,this.midroll_counter=0,this.postroll_counter=0}configured(e){this.config&&this.video&&(e.data&&(e.data.live&&(this.liveflag=!0),e.data.title?this.media_title=e.data.title:e.data.metadata&&e.data.metadata.title&&(this.media_title=e.data.metadata.title)),this.config.ga.start_on||(this.config.ga.start_on="playing"),this.video.ads||(this.config.ga.start_on="playing"),this.once&&(this.once=!1,this.track(this.event_actions.video_player_load)))}fullscreenenter(){this.track(this.event_actions.fullscreen_enter)}fullscreenexit(){this.track(this.event_actions.fullscreen_exit)}checkForAdCounter(e,t){return e.replace("[x]",t+"")}adstarted(e){var t;switch((null===(t=e.data)||void 0===t?void 0:t.ad_type)||"preroll"){case"midroll":this.ad_type="midroll",this.midroll_counter++,this.track(this.checkForAdCounter(this.event_actions.ad_start_midroll,this.midroll_counter));break;case"postroll":this.ad_type="postroll",this.postroll_counter++,this.track(this.checkForAdCounter(this.event_actions.ad_start_postroll,this.postroll_counter));break;default:this.ad_type="preroll",this.preroll_counter++,this.track(this.checkForAdCounter(this.event_actions.ad_start_preroll,this.preroll_counter))}}adcompleted(e){var t;switch((null===(t=e.data)||void 0===t?void 0:t.ad_type)||"preroll"){case"midroll":this.track(this.event_actions.ad_completed_midroll);break;case"postroll":this.track(this.event_actions.ad_completed_postroll);break;default:this.track(this.event_actions.ad_completed_preroll)}}adskipped(){if(this.ad_type)switch(this.ad_type){case"midroll":this.track(this.event_actions.ad_skipped_midroll);break;case"postroll":this.track(this.event_actions.ad_skipped_postroll);break;default:this.track(this.event_actions.ad_skipped_preroll)}else this.track(this.event_actions.ad_skipped_preroll)}adbreakcompleted(e){this.set_started(e),this.track(this.event_actions.ad_break_completed)}track(e){let t=this.event_categories.videos;this.liveflag&&(t=this.event_categories.live),e&&t&&(this.setup_ga(),this.ga_extensions.length&&void 0!==window.ga&&null!==window.ga?this.ga_extensions.forEach(i=>{window.ga(i+".send","event",t,e,this.media_title)}):console.debug("ga console.send","event",t,e,this.media_title))}})}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.google_analytics=t())}(this,(function(){"use strict";return function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const i=e.flowplayer;return"function"==typeof i?(i(t),t):(Array.isArray(i.extensions)||(i.extensions=[]),~i.extensions.indexOf(t)||i.extensions.push(t),t)}(window,class GoogleAnalyticsPlugin{constructor(e){this.started=!1,this.paused=!1,this.muted=!1,this.once=!0,this.liveflag=!1,this.ga_instances=[],this.ga_extensions=[],this.quartiles=[0,0,0],this.ad_type="preroll",this.preroll_counter=0,this.midroll_counter=0,this.postroll_counter=0,this.event_categories={live:"Live",videos:"Videos"},this.event_actions={fullscreen_enter:"fullscreen_enter",fullscreen_exit:"fullscreen_exit",video_player_load:"video_player_load",video_start:"video_start",video_click_play:"video_click_play",video_pause:"video_pause",video_resume:"video_resume",video_mute:"video_mute",video_unmute:"video_unmute",video_25_percent:"video_25_percent",video_50_percent:"video_50_percent",video_75_percent:"video_75_percent",video_complete:"video_complete",live_start:"live_start",live_click_play:"live_click_play",live_pause:"live_pause",live_resume:"live_resume",live_mute:"live_mute",live_unmute:"live_unmute",live_complete:"live_complete",ad_start_preroll:"ad_start_preroll",ad_start_midroll:"ad_start_midroll",ad_start_postroll:"ad_start_postroll",ad_completed_preroll:"ad_completed_preroll",ad_completed_midroll:"ad_completed_midroll",ad_completed_postroll:"ad_completed_postroll",ad_skipped_preroll:"ad_skipped_preroll",ad_skipped_midroll:"ad_skipped_midroll",ad_skipped_postroll:"ad_skipped_postroll",ad_break_completed:"ad_break_completed"},this.flowplayer=e}init(e,t,i){if(this.config=e,this.video=i,"object"!=typeof e.ga)return;if(i.hasState("consent-no-tracking"))return;const s=this.flowplayer.AdEvents||{AD_STARTED:"ad-started",AD_COMPLETED:"ad-completed",AD_SKIPPED:"ad-skipped",AD_BREAK_COMPLETED:"ad-break-completed"};this.muted=i.muted||!1,this.media_title=e.ga.media_title||"unknown video title",this.ga_instances=e.ga.ga_instances,e.ga.event_actions&&(this.event_actions=e.ga.event_actions),e.ga.event_categories&&(this.event_categories=e.ga.event_categories),i.on(["mount","timeupdate","loadstart","ended","seeked","seeking","pause","playing","volumechange",s.AD_STARTED,s.AD_COMPLETED,s.AD_SKIPPED,s.AD_BREAK_COMPLETED,"config","click","touchend","fullscreenenter","fullscreenexit"],e=>{switch(e.type){case"playing":this.playing(e.type);break;case"pause":this.pause();break;case"mount":this.loaded();break;case"timeupdate":this.progress();break;case"ended":this.ended();break;case"volumechange":this.volumechange();break;case"ad-started":this.adstarted(e);break;case"ad-completed":this.adcompleted(e);break;case"ad-break-completed":this.adbreakcompleted(e.type);break;case"config":this.configured(e);break;case"click":this.click();break;case"fullscreenenter":this.fullscreenenter();break;case"fullscreenexit":this.fullscreenexit();break;case"ad-skipped":this.adskipped()}})}setup_ga(){window.ga&&0===this.ga_extensions.length&&this.ga_instances.forEach((e,t)=>{var i;window.ga("create",e,"auto","ext"+(t+1)),(null===(i=this.config)||void 0===i?void 0:i.ga.custom_data)&&window.ga("ext"+(t+1)+".set",this.config.ga.custom_data),this.ga_extensions.push("ext"+(t+1))})}set_started(e){var t;(null===(t=this.config)||void 0===t?void 0:t.ga.start_on)===e&&(this.liveflag?this.track(this.event_actions.live_start):this.track(this.event_actions.video_start),this.started=!0)}click(){!this.paused&&this.started||(this.liveflag?this.track(this.event_actions.live_click_play):this.track(this.event_actions.video_click_play))}playing(e){this.started?this.paused&&(this.paused=!1,this.liveflag?this.track(this.event_actions.live_resume):this.track(this.event_actions.video_resume)):this.set_started(e)}pause(){this.video&&(Math.abs(this.video.duration-this.video.currentTime)<1||!this.started||(this.paused=!0,this.liveflag?this.track(this.event_actions.live_pause):this.track(this.event_actions.video_pause)))}loaded(){}progress(){!this.liveflag&&this.video&&(this.video.currentTime/this.video.duration>.25&&0===this.quartiles[0]?(this.quartiles[0]=1,this.track(this.event_actions.video_25_percent)):this.video.currentTime/this.video.duration>.5&&0===this.quartiles[1]?(this.quartiles[1]=1,this.track(this.event_actions.video_50_percent)):this.video.currentTime/this.video.duration>.75&&0===this.quartiles[2]&&(this.quartiles[2]=1,this.track(this.event_actions.video_75_percent)))}volumechange(){this.video&&(this.video.muted&&!this.muted?(this.muted=!0,this.liveflag?this.track(this.event_actions.live_mute):this.track(this.event_actions.video_mute)):!this.video.muted&&this.muted&&(this.muted=!1,this.liveflag?this.track(this.event_actions.live_unmute):this.track(this.event_actions.video_unmute)))}ended(){this.started&&(this.liveflag?this.track(this.event_actions.live_complete):this.track(this.event_actions.video_complete)),this.reset()}reset(){this.started=!1,this.quartiles=[0,0,0],this.once=!0,this.config&&(this.config.ga.start_on="playing"),this.preroll_counter=0,this.midroll_counter=0,this.postroll_counter=0}configured(e){this.config&&this.video&&(e.data&&(e.data.live&&(this.liveflag=!0),e.data.title?this.media_title=e.data.title:e.data.metadata&&e.data.metadata.title&&(this.media_title=e.data.metadata.title)),this.config.ga.start_on||(this.config.ga.start_on="playing"),this.video.ads||(this.config.ga.start_on="playing"),this.once&&(this.once=!1,this.track(this.event_actions.video_player_load)))}fullscreenenter(){this.track(this.event_actions.fullscreen_enter)}fullscreenexit(){this.track(this.event_actions.fullscreen_exit)}checkForAdCounter(e,t){return e.replace("[x]",t+"")}adstarted(e){var t;switch((null===(t=e.data)||void 0===t?void 0:t.ad_type)||"preroll"){case"midroll":this.ad_type="midroll",this.midroll_counter++,this.track(this.checkForAdCounter(this.event_actions.ad_start_midroll,this.midroll_counter));break;case"postroll":this.ad_type="postroll",this.postroll_counter++,this.track(this.checkForAdCounter(this.event_actions.ad_start_postroll,this.postroll_counter));break;default:this.ad_type="preroll",this.preroll_counter++,this.track(this.checkForAdCounter(this.event_actions.ad_start_preroll,this.preroll_counter))}}adcompleted(e){var t;switch((null===(t=e.data)||void 0===t?void 0:t.ad_type)||"preroll"){case"midroll":this.track(this.event_actions.ad_completed_midroll);break;case"postroll":this.track(this.event_actions.ad_completed_postroll);break;default:this.track(this.event_actions.ad_completed_preroll)}}adskipped(){if(this.ad_type)switch(this.ad_type){case"midroll":this.track(this.event_actions.ad_skipped_midroll);break;case"postroll":this.track(this.event_actions.ad_skipped_postroll);break;default:this.track(this.event_actions.ad_skipped_preroll)}else this.track(this.event_actions.ad_skipped_preroll)}adbreakcompleted(e){this.set_started(e),this.track(this.event_actions.ad_break_completed)}track(e){let t=this.event_categories.videos;this.liveflag&&(t=this.event_categories.live),e&&t&&(this.setup_ga(),this.ga_extensions.length&&void 0!==window.ga&&null!==window.ga?this.ga_extensions.forEach(i=>{window.ga(i+".send","event",t,e,this.media_title)}):console.debug("ga console.send","event",t,e,this.media_title))}})}));
|
package/plugins/health.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.health=t())}(this,(function(){"use strict";const e="rebuffer";var t=Object.freeze({__proto__:null,RECORD:"health:record",REBUFFER:e});const n="load",i="fullscreenenter",o="fullscreenexit",s="loadedmetadata",r="loadeddata",a="progress",d="loadstart",c="pause",l="playing",u="waiting",_="canplay",h="ended",p="seeked",f="seeking";function m(e){try{return!!new URL(e)}catch(e){return!1}}function v(e,t){const n=function(){try{return localStorage.getItem("flowplayer/debug")}catch(e){return""}}(),i=(...i)=>{const o=(null==t?void 0:t.debug)||n;o&&e.match(o)&&console.log(e,...i)};return i.log=i,i}const E=navigator;function g(e){var t,n;const i=null===(t=e.hls)||void 0===t?void 0:t.bandwidthEstimate;return i?1e-6*i:(null===(n=E.connection)||void 0===n?void 0:n.downlink)||-1}function y(e,t){return function(e,t){return"function"==typeof navigator.sendBeacon&&navigator.sendBeacon(e,t)}(e,JSON.stringify({events:t}))}const R="https://ljsp.lwcdn.com".concat("/web/public/countdown/time.json"),O=window,I=O._flowplayerTimekeeper||(O._flowplayerTimekeeper={});var w;!function(e){e[e.OFF=0]="OFF",e[e.ON=1]="ON",e[e.AUDIO_REQUIRED=2]="AUDIO_REQUIRED"}(w||(w={}));const D=e=>{switch(e){case!0:return w.ON;case!1:return w.OFF;default:return e}},N=[];function T(e){if(e.suspended)return;const t=N.slice(0);N.length=0,0!=t.length&&(e.logger.log(`:dispatch events={${t.length}}`),y("https://health.flowplayer.com/v1/health/events",t))}async function A(e,t,n){const i=await S();N.push(Object.assign(t,i)),e.logger.log(":enqueue",t.event,t),N.length<10&&!n||T(e)}const b=()=>{var e,t;try{const n=window;return null===(t=null===(e=null==n?void 0:n.google)||void 0===e?void 0:e.ima)||void 0===t?void 0:t.VERSION}catch(e){return}},S=async()=>{try{const e=await async function(){const e=I.cachedServerOffset;if(e)return e;const t=I.pendingRequest||(I.pendingRequest=fetch(R)),n=await t,i=parseInt(n.headers.get("age")||"0"),o=await n.json(),s=Date.now()-o.millisUtc-1e3*i;return I.cachedServerOffset=s,I.cachedServerOffset}();return{timestamp:Date.now()-e,adjustedTimestamp:!0}}catch(e){return{timestamp:Date.now(),adjustedTimestamp:!1}}},U=(e,t)=>Object.assign(e,{detail:t}),k=(e,{event:t,media_session_id:n,session_id:i})=>({event:t,media_session_id:n,session_id:i,device_id:e.deviceId(),version:"3.1.0
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.health=t())}(this,(function(){"use strict";const e="rebuffer";var t=Object.freeze({__proto__:null,RECORD:"health:record",REBUFFER:e});const n="load",i="fullscreenenter",o="fullscreenexit",s="loadedmetadata",r="loadeddata",a="progress",d="loadstart",c="pause",l="playing",u="waiting",_="canplay",h="ended",p="seeked",f="seeking";function m(e){try{return!!new URL(e)}catch(e){return!1}}function v(e,t){const n=function(){try{return localStorage.getItem("flowplayer/debug")}catch(e){return""}}(),i=(...i)=>{const o=(null==t?void 0:t.debug)||n;o&&e.match(o)&&console.log(e,...i)};return i.log=i,i}const E=navigator;function g(e){var t,n;const i=null===(t=e.hls)||void 0===t?void 0:t.bandwidthEstimate;return i?1e-6*i:(null===(n=E.connection)||void 0===n?void 0:n.downlink)||-1}function y(e,t){return function(e,t){return"function"==typeof navigator.sendBeacon&&navigator.sendBeacon(e,t)}(e,JSON.stringify({events:t}))}const R="https://ljsp.lwcdn.com".concat("/web/public/countdown/time.json"),O=window,I=O._flowplayerTimekeeper||(O._flowplayerTimekeeper={});var w;!function(e){e[e.OFF=0]="OFF",e[e.ON=1]="ON",e[e.AUDIO_REQUIRED=2]="AUDIO_REQUIRED"}(w||(w={}));const D=e=>{switch(e){case!0:return w.ON;case!1:return w.OFF;default:return e}},N=[];function T(e){if(e.suspended)return;const t=N.slice(0);N.length=0,0!=t.length&&(e.logger.log(`:dispatch events={${t.length}}`),y("https://health.flowplayer.com/v1/health/events",t))}async function A(e,t,n){const i=await S();N.push(Object.assign(t,i)),e.logger.log(":enqueue",t.event,t),N.length<10&&!n||T(e)}const b=()=>{var e,t;try{const n=window;return null===(t=null===(e=null==n?void 0:n.google)||void 0===e?void 0:e.ima)||void 0===t?void 0:t.VERSION}catch(e){return}},S=async()=>{try{const e=await async function(){const e=I.cachedServerOffset;if(e)return e;const t=I.pendingRequest||(I.pendingRequest=fetch(R)),n=await t,i=parseInt(n.headers.get("age")||"0"),o=await n.json(),s=Date.now()-o.millisUtc-1e3*i;return I.cachedServerOffset=s,I.cachedServerOffset}();return{timestamp:Date.now()-e,adjustedTimestamp:!0}}catch(e){return{timestamp:Date.now(),adjustedTimestamp:!1}}},U=(e,t)=>Object.assign(e,{detail:t}),k=(e,{event:t,media_session_id:n,session_id:i})=>({event:t,media_session_id:n,session_id:i,device_id:e.deviceId(),version:"3.1.0",commit:"a315f4a3b8421b33e1424deb0b7deb368e95d46e",ima_sdk_version:b(),preload:e.opt("preload"),autoplay:D(e.opt("autoplay")),live:e.opt("live"),dvr:e.opt("dvr"),source:e.original_src,downlink_mbs:g(e),player_id:e.opt("metadata.player_id"),media_id:e.opt("metadata.media_id"),site_id:e.opt("metadata.site_id"),category_id:e.opt("metadata.category_id"),sitegroup_id:e.opt("metadata.sitegroup_id"),token:e.token,plugins:e.plugins.map(e=>e.constructor.name).sort((e,t)=>e.localeCompare(t)),current_time:e.currentTime,external_media_id:e.opt("external_media_id")}),C=e=>({bitrate:null==e?void 0:e.bitrate,resolution:null==e?void 0:e.attrs.RESOLUTION,frame_rate:null==e?void 0:e.attrs["FRAME-RATE"]});function L(e,t,n,i){const o=k(t,e.eventInfo(n)),{before:s,after:r}=i;A(e,((e,t,n)=>Object.assign(e,{state:{before:t,after:n}}))(o,C(s),C(r)))}const M=[1e7]+""+-1e3+-4e3+-8e3+-1e11,B=()=>"undefined"==typeof crypto?"":M.replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16));var x;function j(e){switch(e){case x.MEDIA_PLAYBACK_ABORTED:return"media playback was aborted";case x.MEDIA_ERR_NETWORK:return"a network error occurred";case x.MEDIA_ERR_DECODE:return"unable to decode media content";case x.MEDIA_ERR_SRC_NOT_SUPPORTED:return"unsupported media type";case x.NO_INTERNET:return"no internet connection detected";case x.MIXED_CONTENT:return"cannot load insecure content in a secure context";default:return"an unknown error occurred"}}!function(e){e[e.UNKNOWN=-1]="UNKNOWN",e[e.MEDIA_PLAYBACK_ABORTED=1]="MEDIA_PLAYBACK_ABORTED",e[e.MEDIA_ERR_NETWORK=2]="MEDIA_ERR_NETWORK",e[e.MEDIA_ERR_DECODE=3]="MEDIA_ERR_DECODE",e[e.MEDIA_ERR_SRC_NOT_SUPPORTED=4]="MEDIA_ERR_SRC_NOT_SUPPORTED",e[e.MIXED_CONTENT=1001]="MIXED_CONTENT",e[e.NO_INTERNET=1002]="NO_INTERNET"}(x||(x={}));const F=(e,t)=>{let n=null;return(...i)=>{null!==n&&(clearTimeout(n),n=null),n=setTimeout(()=>t(...i),e)}},H=B();class Health{constructor(e,t){this.session_id=H,this.suspended=!1,this.logger=v("health",t.opts),this.media_session_id=B(),this.analyticsLoop=setInterval(()=>T(this),2e3),t.on("reap",()=>clearInterval(this.analyticsLoop));const n=this;if(t.health={get media_session_id(){return n.media_session_id},set media_session_id(e){n.media_session_id=e},get session_id(){return n.session_id},set session_id(e){n.session_id=e},toggle(e){e?n.resume():n.suspend()}},!Health._UNLOAD_SUBSCRIBED){Health._UNLOAD_SUBSCRIBED=!0;const t=t=>e.instances.forEach(e=>e.emit(t.type));document.addEventListener("visibilitychange",e=>{"hidden"==document.visibilityState&&t(e)}),window.addEventListener("pagehide",t)}}eventInfo(e){return{event:e,media_session_id:this.media_session_id,session_id:this.session_id}}suspend(){this.suspended=!0,clearInterval(this.analyticsLoop)}resume(){this.suspended=!1,this.analyticsLoop=setInterval(()=>T(this),2e3)}init(t,v,E){!function(t){t.on(u,(function(n){t.seeking||t.networkState===t.NETWORK_LOADING&&t.readyState!==t.HAVE_NOTHING&&t.emit(e)}))}(E),E.on("health:record",({detail:e})=>{const t=k(E,this.eventInfo(e.event));Object.assign(t,e.detail||{}),A(this,t)}),[_,d,n,s,r,a,u,e].forEach(e=>{E.on(e,e=>{A(this,k(E,this.eventInfo(e.type)))})}),[l,c,f,p,h,i,o].forEach(e=>{E.on(e,e=>{A(this,k(E,this.eventInfo(e.type)))})}),E.on("volumechange",F(800,e=>{const t=k(E,this.eventInfo(e.type));A(this,U(t,{volume:parseFloat(E.volume.toFixed(2)),muted:E.muted}))})),E.on("resize",F(800,e=>{const t=k(E,this.eventInfo(e.type));A(this,U(t,{height:v.clientHeight,width:v.clientWidth}))})),E.on("qualitychange",({type:e,detail:t})=>{switch(t.kind){case"hls":return L(this,E,e,t)}});let g=Date.now()+5e3;E.on("timeupdate",e=>{if(Date.now()<g)return;g=Date.now()+5e3;const t=k(E,this.eventInfo(e.type));var n;A(this,U(t,{duration:(n=E.duration,Number.isFinite(n)?n:n===1/0?-1:void 0)}))}),E.addEventListener("error",e=>{const t=k(E,this.eventInfo(e.type)),n=e.error||E.error;if(!n)return A(this,t,!0);const i=n.code,o={error_message:n.message||j(i),error_code:i,error_stack:n.stack||""};return A(this,U(t,o),!0)}),E.on("src",e=>{var t;const n=null===(t=e.detail)||void 0===t?void 0:t.src;if("string"!=typeof n)return;if(!m(E.original_src))return;if(!m(n))return;if(n==E.original_src)return;this.media_session_id=B();A(this,k(E,this.eventInfo(e.type))),T(this)}),E.on("visibilitychange",e=>{A(this,k(E,this.eventInfo(e.type))),T(this)})}}return Health.events=t,Health._UNLOAD_SUBSCRIBED=!1,function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;"function"==typeof n?n(t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t))}(window,Health),Health}));
|