@flowplayer/player 3.4.3 → 3.4.4-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core.js +1 -1
- package/default.js +1 -1
- package/embed.js +101 -194
- package/flowplayer.css +1 -1
- package/package.json +3 -2
- package/plugins/ads.js +2 -2
- package/plugins/analytics.js +1 -1
- package/plugins/audio.js +1 -1
- package/plugins/dash.js +4 -4
- package/plugins/endscreen.js +1 -1
- package/plugins/health.js +1 -1
- package/plugins/hls.js +100 -193
- package/plugins/id3.js +1 -1
- package/plugins/millicast.js +1 -0
- package/plugins/share.js +1 -1
package/plugins/endscreen.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.endscreen=t())}(this,(function(){"use strict";var e="playlist:ended",t="interstitial/end",n="interstitial/cancel",s="interstitial/next_item";function i(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}const r=(e,t)=>new(((e,t)=>{const n=e.get(t);if(!n)throw new Error(`no flowplayer component with the name ${t} exists`);const s=window.customElements.get(t);if(!s)throw new Error(`no default flowplayer component with the name ${t} exists`);const i=window.customElements.get(n);return"function"!=typeof i?s:i})(e._customElements,t))(e),o=(e,t,n)=>{window.customElements.get(t)||window.customElements.define(t,n),e.customElements.get(t)||e.customElements.set(t,t)};class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}const l=(e,t)=>{const n=document.createElement("span");return n.classList.add(e),n.textContent=t,n};class InterstitialGrid extends FlowplayerComponent{constructor(e){super(e),this.classList.add("interstitial-grid"),this.addEventListener(InterstitialGrid.events.RENDER,t=>{this.prepare_endscreen(t.detail,e)}),e.on("resize",()=>{e.root.classList.contains("is-grid")&&this.items&&this.prepare_endscreen(this.items,e)}),this.previousButton=document.createElement("div"),this.previousButton.classList.add("fp-previous"),this.nextButton=document.createElement("div"),this.nextButton.classList.add("fp-next"),this.previousButton.addEventListener("click",this.navigation_buttons_listener.bind(this,!0)),this.nextButton.addEventListener("click",this.navigation_buttons_listener.bind(this,!1))}calculate_max_cells_number(e,t){const n=this.parentElement;if(!n)return;const s=window.getComputedStyle(n).padding,i=t.clientWidth-2*parseFloat(s),r=t.clientHeight-2*parseFloat(s);let o=e,l=0,d=0,a=0,c=0;e:for(;o>0;o-=1){if(1===o){l=i,d=Math.min(r,Math.max(l/1.5,l/1.8)),a=c=1;break}let e=1;for(;e<=o;e++){const t=Number.isInteger(o/e)?o/e:parseInt((o/e).toString())+1,n=i/e;let s=1.5;for(;s<=1.8;s+=.1){const i=n/s;if(i>=64&&i*t<=r&&n>=115){l=n,d=i,a=e,c=t;break e}}}}return this.style.setProperty("grid-template-columns",`repeat(${a}, ${l}px)`),this.style.setProperty("grid-template-rows",`repeat(${c}, ${d}px)`),o}prepare_endscreen(e,t){this.items=e,this.rendered_items=this.items.slice(0,this.calculate_max_cells_number(this.items.length,t)),this.populate_cells(this.rendered_items),this.hide_navigation_buttons(this.items.every((e,t)=>{var n;return e===(null===(n=this.rendered_items)||void 0===n?void 0:n[t])}))}populate_cells(e){this.innerHTML="",e.forEach(e=>{var t,n;const s=document.createElement("div");s.classList.add("grid-item"),e.poster&&(s.style.backgroundImage=`url(${e.poster})`);const i=document.createElement("div");i.classList.add("overlay");const r=l("title",null!==(t=e.title)&&void 0!==t?t:""),o=l("description",null!==(n=e.description)&&void 0!==n?n:"");i.append(r,o),s.append(i),s.addEventListener("click",()=>{const t=new CustomEvent(InterstitialGrid.events.SELECTION,{detail:e});this.dispatchEvent(t)}),this.append(s)})}hide_navigation_buttons(e){[this.previousButton,this.nextButton].forEach(t=>t.style.setProperty("display",e?"none":"block"))}connectedCallback(){var e;this.isConnected&&(null===(e=this.parentElement)||void 0===e||e.append(this.previousButton,this.nextButton))}navigation_buttons_listener(e){if(!this.rendered_items)return;const t=[];this.rendered_items.forEach(n=>{if(!this.items)return;const s=this.items.indexOf(n);if(void 0===s||-1===s)return;const i=this.calculate_index(e,s);void 0!==i&&t.push(this.items[i])}),this.rendered_items=t,this.populate_cells(this.rendered_items)}calculate_index(e,t){if(!this.items||!this.rendered_items)return;const n=this.items.length,s=this.rendered_items.length;let i=e?t-s:t+s;return i<0&&e&&(i=n+i),i>n-1&&!e&&(i-=n),i}}InterstitialGrid.events={SELECTION:"interstitial/grid/selection",RENDER:"interstitial/grid/render"};const d=["title","delay","description","poster","src"];class UpNext extends FlowplayerComponent{static get observedAttributes(){return d}constructor(e){super(e),this.classList.add("up-next"),this.addEventListener("animationend",()=>{this.dispatchEvent(new CustomEvent(t))}),this.addEventListener("animationcancel",()=>{this.classList.add("cancelled"),this.dispatchEvent(new CustomEvent(n))}),this.addEventListener(s,this._setUpNext.bind(this))}getTitle(){return this.getAttribute("title")||""}getDescription(){return this.getAttribute("description")||""}getPoster(){return this.getAttribute("poster")||""}getDelay(){return this.getAttribute("delay")||""}connectedCallback(){this.isConnected&&this._render()}attributeChangedCallback(){this._render()}_render(){var e,n;this.innerHTML="",this.classList.remove("cancelled");const s=document.createDocumentFragment(),i=document.createElement("div");i.classList.add("pane","left");const r=document.createElement("div");r.classList.add("pane","right"),s.append(i,r);const o=document.createElement("div");o.classList.add("poster"),o.style.backgroundImage="url("+this.getPoster()+")",i.append(o),o.addEventListener("click",()=>this.dispatchEvent(new CustomEvent(t)));const l=document.createElement("span");l.classList.add("fp-icon","fp-play"),o.append(l);const d=document.createElement("span");d.classList.add("title"),d.textContent=this.getTitle();const a=document.createElement("span");a.classList.add("description"),a.textContent=this.getDescription();const c=document.createElement("span");c.classList.add("countdown"),this.getDelay()&&(c.style.setProperty("--up-next-delay",this.getDelay()+"s"),c.classList.add("go"));const p=document.createElement("span");p.classList.add("cancel"),p.textContent=null!==(n=null===(e=this.player)||void 0===e?void 0:e.i18n("playlist.cancel"))&&void 0!==n?n:"cancel",p.addEventListener("click",()=>c.classList.remove("go")),r.append(d,a,p,c),this.append(s)}_setUpNext(e){var t,n,s;const i=e.detail.next,r=this.player.opt("playlist.delay",void 0)||10;this.setAttribute("title",null!==(t=i.title)&&void 0!==t?t:""),this.setAttribute("description",null!==(n=i.description)&&void 0!==n?n:""),this.setAttribute("poster",null!==(s=i.poster)&&void 0!==s?s:""),this.setAttribute("delay",r+"")}}function a(e,t){const n=function(){try{return localStorage.getItem("flowplayer/debug")}catch(e){return""}}(),s=(s,...i)=>{const r=(null==t?void 0:t.debug)||n;r&&e.match(r)&&console.log(`flowplayer/${e} -- ${s}`,...i)};return s.log=s,s}function c(e,t,n){const s=function(e,t){const n=new CustomEvent(e,{detail:t,cancelable:!0});return t&&Object.defineProperty(n,"data",{get:()=>t}),n}(t,n);return e.dispatchEvent(s),e}!function(){let e=!1;try{const t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("testPassive",null,t),window.removeEventListener("testPassive",null,t)}catch(e){}}();class EndscreenInterstitial extends FlowplayerComponent{constructor(e){super(e),this.className="fp-endscreen",this.upNextEle=r(e,"flowplayer-endscreen-up-next"),this.gridEle=r(e,"flowplayer-endscreen-grid"),this.append(this.upNextEle,this.gridEle),this.addEventListener("recommendations:render",this.on_recommendations_render.bind(this)),this.upNextEle.addEventListener(n,this.on_next_cancel.bind(this)),this.upNextEle.addEventListener(t,this.on_next_end.bind(this)),this.gridEle.addEventListener(InterstitialGrid.events.SELECTION,this.on_grid_selection.bind(this))}on_recommendations_render(e){const t=e.detail;if(this.playlist=t.playlist,this.on_item_selected=t.on_item_selected,this.player.playlist||!1===this.player.opt("endscreen.auto_advance"))return this.gridEle.dispatchEvent(new CustomEvent(InterstitialGrid.events.RENDER,{detail:this.playlist})),this.player.root.classList.add("is-grid");this.gridEle.hide_navigation_buttons(!0),this.player.root.classList.add("is-up-next"),c(this.upNextEle,s,{next:this._nextVideo(this.playlist)})}on_next_cancel(){this.player.root.classList.contains("is-endscreen")&&this.playlist&&(this.gridEle.dispatchEvent(new CustomEvent(InterstitialGrid.events.RENDER,{detail:this.playlist})),this.player.root.classList.remove("is-up-next"),this.player.root.classList.add("is-grid"))}on_next_end(){if(!this.playlist||!this.on_item_selected)return;const e=this.current_video=this._nextVideo(this.playlist);this.on_item_selected(e)}on_grid_selection(e){this.on_item_selected&&this.on_item_selected(e.detail),this.current_video=e.detail,this.gridEle.hide_navigation_buttons(!0)}_nextVideo(e){if(!this.current_video)return e[0];const t=e.indexOf(this.current_video);return[-1,e.length-1].includes(t)?e[0]:e[t+1]}}class Endscreen{constructor(e,t){this.logger=a("flowplayer/endscreen"),o(e,"flowplayer-endscreen-interstitial",EndscreenInterstitial),o(e,"flowplayer-endscreen-up-next",class extends UpNext{}),o(e,"flowplayer-endscreen-grid",class extends InterstitialGrid{})}init(t,n,s){const o=r(s,"flowplayer-endscreen-interstitial");var l;s.on("mount",()=>{var e;return null===(e=i(s,"flowplayer-ui"))||void 0===e?void 0:e.prepend(o)}),s.on("recommendationsready",e=>{const t=e.detail;this.recommendations=t,this.logger.log(`loaded ${t.playlist.length} recommendations`)}),s.on(["ended",e],(l=e=>{var i;this.recommendations&&(e.prevented_from_ads||t.loop||(null===(i=null==t?void 0:t.playlist)||void 0===i?void 0:i.loop)||"ended"==e.type&&s.playlist||(c(o,"recommendations:render",{playlist:this.recommendations.playlist.slice(0,12),on_item_selected:this._setSrc.bind(this,s)}),n.classList.add("is-endscreen")))},e=>{setTimeout((function(){if(!e.defaultPrevented)return l(e)}),0)})),s.on(["seeking","loadstart","playing"],()=>{s.root.classList.contains("is-endscreen")&&this.hide_recommendations(s)})}_setSrc(e,t){var n;if(this.hide_recommendations(e),e.playlist)return e.playlist.push(t),null===(n=e.playlist)||void 0===n?void 0:n.next();e.setSrc(t.src),e.setOpts({title:t.title}),e.once("canplay",()=>e.togglePlay(!0))}hide_recommendations(e){e.root.classList.remove("is-endscreen","is-grid","is-up-next");const t=i(e,"flowplayer-endscreen-interstitial");t&&c(t,"recommendations:hide")}}return Endscreen.events={RECOMMENDATIONS_RENDER:"recommendations:render",RECOMMENDATIONS_READY:"recommendationsready",RECOMMENDATIONS_HIDE:"recommendations:hide"},function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;return"function"==typeof n?(n(t),t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t),t)}(window,Endscreen)}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.endscreen=t())}(this,(function(){"use strict";var e="playlist:ended",t="interstitial/end",n="interstitial/cancel",s="interstitial/next_item";function i(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}const r=(e,t)=>new(((e,t)=>{const n=e.get(t);if(!n)throw new Error(`no flowplayer component with the name ${t} exists`);const s=window.customElements.get(t);if(!s)throw new Error(`no default flowplayer component with the name ${t} exists`);const i=window.customElements.get(n);return"function"!=typeof i?s:i})(e._customElements,t))(e),o=(e,t,n)=>{window.customElements.get(t)||window.customElements.define(t,n),e.customElements.get(t)||e.customElements.set(t,t)};class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}const l=(e,t)=>{const n=document.createElement("span");return n.classList.add(e),n.textContent=t,n};class InterstitialGrid extends FlowplayerComponent{constructor(e){super(e),this.classList.add("interstitial-grid"),this.addEventListener(InterstitialGrid.events.RENDER,t=>{this.prepare_endscreen(t.detail,e)}),e.on("resize",()=>{e.root.classList.contains("is-grid")&&this.items&&this.prepare_endscreen(this.items,e)}),this.previousButton=document.createElement("div"),this.previousButton.classList.add("fp-previous"),this.nextButton=document.createElement("div"),this.nextButton.classList.add("fp-next"),this.previousButton.addEventListener("click",this.navigation_buttons_listener.bind(this,!0)),this.nextButton.addEventListener("click",this.navigation_buttons_listener.bind(this,!1))}calculate_max_cells_number(e,t){const n=this.parentElement;if(!n)return;const s=window.getComputedStyle(n).padding,i=t.clientWidth-2*parseFloat(s),r=t.clientHeight-2*parseFloat(s);let o=e,l=0,d=0,a=0,c=0;e:for(;o>0;o-=1){if(1===o){l=i,d=Math.min(r,Math.max(l/1.5,l/1.8)),a=c=1;break}let e=1;for(;e<=o;e++){const t=Number.isInteger(o/e)?o/e:parseInt((o/e).toString())+1,n=i/e;let s=1.5;for(;s<=1.8;s+=.1){const i=n/s;if(i>=64&&i*t<=r&&n>=115){l=n,d=i,a=e,c=t;break e}}}}return this.style.setProperty("grid-template-columns",`repeat(${a}, ${l}px)`),this.style.setProperty("grid-template-rows",`repeat(${c}, ${d}px)`),o}prepare_endscreen(e,t){this.items=e,this.rendered_items=this.items.slice(0,this.calculate_max_cells_number(this.items.length,t)),this.populate_cells(this.rendered_items),this.hide_navigation_buttons(this.items.every((e,t)=>{var n;return e===(null===(n=this.rendered_items)||void 0===n?void 0:n[t])}))}populate_cells(e){this.innerHTML="",e.forEach(e=>{var t,n;const s=document.createElement("div");s.classList.add("grid-item"),e.poster&&(s.style.backgroundImage=`url(${e.poster})`);const i=document.createElement("div");i.classList.add("overlay");const r=l("title",null!==(t=e.title)&&void 0!==t?t:""),o=l("description",null!==(n=e.description)&&void 0!==n?n:"");i.append(r,o),s.append(i),s.addEventListener("click",()=>{const t=new CustomEvent(InterstitialGrid.events.SELECTION,{detail:e});this.dispatchEvent(t)}),this.append(s)})}hide_navigation_buttons(e){[this.previousButton,this.nextButton].forEach(t=>t.style.setProperty("display",e?"none":"block"))}connectedCallback(){var e;this.isConnected&&(null===(e=this.parentElement)||void 0===e||e.append(this.previousButton,this.nextButton))}navigation_buttons_listener(e){if(!this.rendered_items)return;const t=[];this.rendered_items.forEach(n=>{if(!this.items)return;const s=this.items.indexOf(n);if(void 0===s||-1===s)return;const i=this.calculate_index(e,s);void 0!==i&&t.push(this.items[i])}),this.rendered_items=t,this.populate_cells(this.rendered_items)}calculate_index(e,t){if(!this.items||!this.rendered_items)return;const n=this.items.length,s=this.rendered_items.length;let i=e?t-s:t+s;return i<0&&e&&(i=n+i),i>n-1&&!e&&(i-=n),i}}InterstitialGrid.events={SELECTION:"interstitial/grid/selection",RENDER:"interstitial/grid/render"};const d=["title","delay","description","poster","src"];class UpNext extends FlowplayerComponent{static get observedAttributes(){return d}constructor(e){super(e),this.classList.add("up-next"),this.addEventListener("animationend",()=>{this.dispatchEvent(new CustomEvent(t))}),this.addEventListener("animationcancel",()=>{this.classList.add("cancelled"),this.dispatchEvent(new CustomEvent(n))}),this.addEventListener(s,this._setUpNext.bind(this))}getTitle(){return this.getAttribute("title")||""}getDescription(){return this.getAttribute("description")||""}getPoster(){return this.getAttribute("poster")||""}getDelay(){return this.getAttribute("delay")||""}connectedCallback(){this.isConnected&&this._render()}attributeChangedCallback(){this._render()}_render(){var e,n;this.innerHTML="",this.classList.remove("cancelled");const s=document.createDocumentFragment(),i=document.createElement("div");i.classList.add("pane","left");const r=document.createElement("div");r.classList.add("pane","right"),s.append(i,r);const o=document.createElement("div");o.classList.add("poster"),o.style.backgroundImage="url("+this.getPoster()+")",i.append(o),o.addEventListener("click",()=>this.dispatchEvent(new CustomEvent(t)));const l=document.createElement("span");l.classList.add("fp-icon","fp-play"),o.append(l);const d=document.createElement("span");d.classList.add("title"),d.textContent=this.getTitle();const a=document.createElement("span");a.classList.add("description"),a.textContent=this.getDescription();const c=document.createElement("span");c.classList.add("countdown"),this.getDelay()&&(c.style.setProperty("--up-next-delay",this.getDelay()+"s"),c.classList.add("go"));const p=document.createElement("span");p.classList.add("cancel"),p.textContent=null!==(n=null===(e=this.player)||void 0===e?void 0:e.i18n("playlist.cancel"))&&void 0!==n?n:"cancel",p.addEventListener("click",()=>c.classList.remove("go")),r.append(d,a,p,c),this.append(s)}_setUpNext(e){var t,n,s;const i=e.detail.next,r=this.player.opt("playlist.delay",void 0)||10;this.setAttribute("title",null!==(t=i.title)&&void 0!==t?t:""),this.setAttribute("description",null!==(n=i.description)&&void 0!==n?n:""),this.setAttribute("poster",null!==(s=i.poster)&&void 0!==s?s:""),this.setAttribute("delay",r+"")}}function a(e,t){const n=function(){try{return localStorage.getItem("flowplayer/debug")}catch(e){return""}}(),s=(s,...i)=>{try{const r=(null==t?void 0:t.debug)||n;r&&e.match(r)&&console.log(`flowplayer/${e} -- ${s}`,...i)}catch(e){console.warn(e)}};return s.log=s,s}function c(e,t,n){const s=function(e,t){const n=new CustomEvent(e,{detail:t,cancelable:!0});return t&&Object.defineProperty(n,"data",{get:()=>t}),n}(t,n);return e.dispatchEvent(s),e}!function(){let e=!1;try{const t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("testPassive",null,t),window.removeEventListener("testPassive",null,t)}catch(e){}}();class EndscreenInterstitial extends FlowplayerComponent{constructor(e){super(e),this.className="fp-endscreen",this.upNextEle=r(e,"flowplayer-endscreen-up-next"),this.gridEle=r(e,"flowplayer-endscreen-grid"),this.append(this.upNextEle,this.gridEle),this.addEventListener("recommendations:render",this.on_recommendations_render.bind(this)),this.upNextEle.addEventListener(n,this.on_next_cancel.bind(this)),this.upNextEle.addEventListener(t,this.on_next_end.bind(this)),this.gridEle.addEventListener(InterstitialGrid.events.SELECTION,this.on_grid_selection.bind(this))}on_recommendations_render(e){const t=e.detail;if(this.playlist=t.playlist,this.on_item_selected=t.on_item_selected,this.player.playlist||!1===this.player.opt("endscreen.auto_advance"))return this.gridEle.dispatchEvent(new CustomEvent(InterstitialGrid.events.RENDER,{detail:this.playlist})),this.player.root.classList.add("is-grid");this.gridEle.hide_navigation_buttons(!0),this.player.root.classList.add("is-up-next"),c(this.upNextEle,s,{next:this._nextVideo(this.playlist)})}on_next_cancel(){this.player.root.classList.contains("is-endscreen")&&this.playlist&&(this.gridEle.dispatchEvent(new CustomEvent(InterstitialGrid.events.RENDER,{detail:this.playlist})),this.player.root.classList.remove("is-up-next"),this.player.root.classList.add("is-grid"))}on_next_end(){if(!this.playlist||!this.on_item_selected)return;const e=this.current_video=this._nextVideo(this.playlist);this.on_item_selected(e)}on_grid_selection(e){this.on_item_selected&&this.on_item_selected(e.detail),this.current_video=e.detail,this.gridEle.hide_navigation_buttons(!0)}_nextVideo(e){if(!this.current_video)return e[0];const t=e.indexOf(this.current_video);return[-1,e.length-1].includes(t)?e[0]:e[t+1]}}class Endscreen{constructor(e,t){this.logger=a("flowplayer/endscreen"),o(e,"flowplayer-endscreen-interstitial",EndscreenInterstitial),o(e,"flowplayer-endscreen-up-next",class extends UpNext{}),o(e,"flowplayer-endscreen-grid",class extends InterstitialGrid{})}init(t,n,s){const o=r(s,"flowplayer-endscreen-interstitial");var l;s.on("mount",()=>{var e;return null===(e=i(s,"flowplayer-ui"))||void 0===e?void 0:e.prepend(o)}),s.on("recommendationsready",e=>{const t=e.detail;this.recommendations=t,this.logger.log(`loaded ${t.playlist.length} recommendations`)}),s.on(["ended",e],(l=e=>{var i;this.recommendations&&(e.prevented_from_ads||t.loop||(null===(i=null==t?void 0:t.playlist)||void 0===i?void 0:i.loop)||"ended"==e.type&&s.playlist||(c(o,"recommendations:render",{playlist:this.recommendations.playlist.slice(0,12),on_item_selected:this._setSrc.bind(this,s)}),n.classList.add("is-endscreen")))},e=>{setTimeout((function(){if(!e.defaultPrevented)return l(e)}),0)})),s.on(["seeking","loadstart","playing"],()=>{s.root.classList.contains("is-endscreen")&&this.hide_recommendations(s)})}_setSrc(e,t){var n;if(this.hide_recommendations(e),e.playlist)return e.playlist.push(t),null===(n=e.playlist)||void 0===n?void 0:n.next();e.setSrc(t.src),e.setOpts({title:t.title}),e.once("canplay",()=>e.togglePlay(!0))}hide_recommendations(e){e.root.classList.remove("is-endscreen","is-grid","is-up-next");const t=i(e,"flowplayer-endscreen-interstitial");t&&c(t,"recommendations:hide")}}return Endscreen.events={RECOMMENDATIONS_RENDER:"recommendations:render",RECOMMENDATIONS_READY:"recommendationsready",RECOMMENDATIONS_HIDE:"recommendations:hide"},function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;return"function"==typeof n?(n(t),t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t),t)}(window,Endscreen)}));
|
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,DISPLAY:"display"});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 m(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 E=navigator;function y(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 g(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,
|
|
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,DISPLAY:"display"});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 m(e,t){const n=function(){try{return localStorage.getItem("flowplayer/debug")}catch(e){return""}}(),i=(i,...o)=>{try{const s=(null==t?void 0:t.debug)||n;s&&e.match(s)&&console.log(`flowplayer/${e} -- ${i}`,...o)}catch(e){console.warn(e)}};return i.log=i,i}const E=navigator;function y(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 g(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,w=O._flowplayerTimekeeper||(O._flowplayerTimekeeper={});var I;!function(e){e[e.OFF=0]="OFF",e[e.ON=1]="ON",e[e.AUDIO_REQUIRED=2]="AUDIO_REQUIRED"}(I||(I={}));const D=e=>{switch(e){case!0:return I.ON;case!1:return I.OFF;default:return e}};function N(){try{return window.location!==window.parent.location?document.referrer:document.location.href}catch(e){return!1}}const T=[];function A(e){if(e.suspended)return;const t=T.slice(0);T.length=0,0!=t.length&&(e.logger.log(`:dispatch events={${t.length}}`),g("https://ihi.flowplayer.com/v1/health/events",t))}async function b(e,t,n){const i=await U();T.push(Object.assign(t,i)),e.logger.log(":enqueue",t.event,t),T.length<10&&!n||A(e)}const S=()=>{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}},U=async()=>{const e=Date.now();try{return{adjusted_time:e-await async function(){const e=w.cachedServerOffset;if(e)return e;const t=w.pendingRequest||(w.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 w.cachedServerOffset=s,w.cachedServerOffset}(),client_time:e}}catch(t){return{client_time:e}}},k=(e,t)=>Object.assign(e,{detail:t}),C=(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.4-rc.1",commit:"82b4d4edc60f60197f8565dd0ebbd05d306df762",ima_sdk_version:S(),preload:e.opt("preload"),autoplay:D(e.opt("autoplay")),live:e.opt("live"),dvr:!!e.live_state.dvr,source:e.original_src,downlink_mbs:y(e),page_url:N(),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")}),L=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 M(e,t,n,i){const o=C(t,e.eventInfo(n)),{before:s,after:r}=i;b(e,((e,t,n)=>Object.assign(e,{state:{before:t,after:n}}))(o,L(s),L(r)))}const B=[1e7]+""+-1e3+-4e3+-8e3+-1e11,x=()=>"undefined"==typeof crypto?"":B.replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16));var F;function j(e){switch(e){case F.MEDIA_PLAYBACK_ABORTED:return"media playback was aborted";case F.MEDIA_ERR_NETWORK:return"a network error occurred";case F.MEDIA_ERR_DECODE:return"unable to decode media content";case F.MEDIA_ERR_SRC_NOT_SUPPORTED:return"unsupported media type";case F.NO_INTERNET:return"no internet connection detected";case F.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"}(F||(F={}));const H=(e,t)=>{let n=null;return(...i)=>{null!==n&&(clearTimeout(n),n=null),n=setTimeout(()=>t(...i),e)}},P=x();class Health{constructor(e,t){this.session_id=P,this.suspended=!1,this.logger=m("health",t.opts),this.media_session_id=x(),this.analyticsLoop=setInterval(()=>A(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(()=>A(this),2e3)}init(t,m,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("display",e=>{b(this,C(E,this.eventInfo(e.type)),!0)}),E.on("health:record",({detail:e})=>{const t=C(E,this.eventInfo(e.event));Object.assign(t,e.detail||{}),b(this,t)}),[_,d,n,s,r,a,u,e].forEach(e=>{E.on(e,e=>{b(this,C(E,this.eventInfo(e.type)))})}),[l,c,p,f,h,i,o].forEach(e=>{E.on(e,e=>{b(this,C(E,this.eventInfo(e.type)))})}),E.on("volumechange",H(800,e=>{const t=C(E,this.eventInfo(e.type));b(this,k(t,{volume:parseFloat(E.volume.toFixed(2)),muted:E.muted}))})),E.on("resize",H(800,e=>{const t=C(E,this.eventInfo(e.type));b(this,k(t,{height:m.clientHeight,width:m.clientWidth}))})),E.on("hls/failover",e=>{const t=C(E,this.eventInfo(e.type)),n=e.detail,{reason:i,from:o}=n;b(this,k(t,{reason:i,from:o}))}),E.on("qualitychange",({type:e,detail:t})=>{switch(t.kind){case"hls":return M(this,E,e,t)}});let y=Date.now()+5e3;E.on("timeupdate",e=>{if(Date.now()<y)return;y=Date.now()+5e3;const t=C(E,this.eventInfo(e.type));var n;b(this,k(t,{duration:(n=E.duration,Number.isFinite(n)?n:n===1/0?-1:void 0)}))}),E.addEventListener("error",e=>{const t=C(E,this.eventInfo(e.type)),n=e.error||E.error;if(!n)return b(this,t,!0);const i=n.code,o={error_message:n.message||j(i),error_code:i,error_stack:n.stack||""};return b(this,k(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(!v(E.original_src))return;if(!v(n))return;if(n==E.original_src)return;this.media_session_id=x();b(this,C(E,this.eventInfo(e.type))),A(this)}),E.on("visibilitychange",e=>{b(this,C(E,this.eventInfo(e.type))),A(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}));
|