@flowplayer/player 3.2.6 → 3.2.8
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/events.d.ts +1 -1
- package/core.js +1 -1
- package/default.js +1 -1
- package/embed.js +3 -3
- package/flowplayer.css +1 -1
- package/index.d.ts +11 -3
- package/package.json +1 -1
- package/plugins/ads.js +2 -2
- package/plugins/analytics.js +1 -1
- package/plugins/asel.js +1 -1
- package/plugins/audio.js +1 -1
- package/plugins/chromecast.js +1 -1
- package/plugins/dash.js +1 -1
- package/plugins/endscreen.js +1 -1
- package/plugins/float-on-scroll.js +1 -1
- package/plugins/health.js +1 -1
- package/plugins/hls.js +1 -1
- package/plugins/ovp.js +1 -1
- package/plugins/playlist.js +1 -1
- package/plugins/qul.js +1 -1
- package/plugins/ssai.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(`${e} -- ${s}`,...i)};return s.log=s,s}function c(e,t,n){const s=function(e,t){const n=new CustomEvent(e,{detail:t,cancelable:!0});return t&&Object.defineProperty(n,"data",{get:()=>t}),n}(t,n);return e.dispatchEvent(s),e}!function(){let e=!1;try{const t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("testPassive",null,t),window.removeEventListener("testPassive",null,t)}catch(e){}}();class EndscreenInterstitial extends FlowplayerComponent{constructor(e){super(e),this.className="fp-endscreen",this.upNextEle=r(e,"flowplayer-endscreen-up-next"),this.gridEle=r(e,"flowplayer-endscreen-grid"),this.append(this.upNextEle,this.gridEle),this.addEventListener("recommendations:render",this.on_recommendations_render.bind(this)),this.upNextEle.addEventListener(n,this.on_next_cancel.bind(this)),this.upNextEle.addEventListener(t,this.on_next_end.bind(this)),this.gridEle.addEventListener(InterstitialGrid.events.SELECTION,this.on_grid_selection.bind(this))}on_recommendations_render(e){const t=e.detail;if(this.playlist=t.playlist,this.on_item_selected=t.on_item_selected,this.player.playlist)return this.gridEle.dispatchEvent(new CustomEvent(InterstitialGrid.events.RENDER,{detail:this.playlist})),this.player.root.classList.add("is-grid");this.player.root.classList.add("is-up-next"),c(this.upNextEle,s,{next:this._nextVideo(this.playlist)})}on_next_cancel(){this.player.root.classList.contains("is-endscreen")&&this.playlist&&(this.gridEle.dispatchEvent(new CustomEvent(InterstitialGrid.events.RENDER,{detail:this.playlist})),this.player.root.classList.remove("is-up-next"),this.player.root.classList.add("is-grid"))}on_next_end(){if(!this.playlist||!this.on_item_selected)return;const e=this.current_video=this._nextVideo(this.playlist);this.on_item_selected(e)}on_grid_selection(e){this.on_item_selected&&this.on_item_selected(e.detail),this.current_video=e.detail,this.gridEle.hide_navigation_buttons(!0)}_nextVideo(e){if(!this.current_video)return e[0];const t=e.indexOf(this.current_video);return[-1,e.length-1].includes(t)?e[0]:e[t+1]}}class Endscreen{constructor(e,t){this.logger=a("flowplayer/endscreen"),o(e,"flowplayer-endscreen-interstitial",EndscreenInterstitial),o(e,"flowplayer-endscreen-up-next",class extends UpNext{}),o(e,"flowplayer-endscreen-grid",class extends InterstitialGrid{})}init(t,n,s){const o=r(s,"flowplayer-endscreen-interstitial");var l;s.on("mount",()=>{var e;return null===(e=i(s,"flowplayer-ui"))||void 0===e?void 0:e.prepend(o)}),s.on("recommendationsready",e=>{const t=e.detail;this.recommendations=t,this.logger.log(`loaded ${t.playlist.length} recommendations`)}),s.on(["ended",e],(l=e=>{var i;this.recommendations&&(e.prevented_from_ads||t.loop||(null===(i=null==t?void 0:t.playlist)||void 0===i?void 0:i.loop)||"ended"==e.type&&s.playlist||(c(o,"recommendations:render",{playlist:this.recommendations.playlist.slice(0,12),on_item_selected:this._setSrc.bind(this,s)}),n.classList.add("is-endscreen")))},e=>{setTimeout((function(){if(!e.defaultPrevented)return l(e)}),0)})),s.on(["seeking","loadstart","playing"],()=>{s.root.classList.contains("is-endscreen")&&this.hide_recommendations(s)})}_setSrc(e,t){var n;if(this.hide_recommendations(e),e.playlist)return e.playlist.push(t),null===(n=e.playlist)||void 0===n?void 0:n.next();e.setSrc(t.src),e.setOpts({title:t.title}),e.once("canplay",()=>e.togglePlay(!0))}hide_recommendations(e){e.root.classList.remove("is-endscreen","is-grid","is-up-next");const t=i(e,"flowplayer-endscreen-interstitial");t&&c(t,"recommendations:hide")}}return Endscreen.events={RECOMMENDATIONS_RENDER:"recommendations:render",RECOMMENDATIONS_READY:"recommendationsready",RECOMMENDATIONS_HIDE:"recommendations:hide"},function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;return"function"==typeof n?(n(t),t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t),t)}(window,Endscreen)}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.endscreen=t())}(this,(function(){"use strict";var e="playlist:ended",t="interstitial/end",n="interstitial/cancel",s="interstitial/next_item";function i(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}const r=(e,t)=>new(((e,t)=>{const n=e.get(t);if(!n)throw new Error(`no flowplayer component with the name ${t} exists`);const s=window.customElements.get(t);if(!s)throw new Error(`no default flowplayer component with the name ${t} exists`);const i=window.customElements.get(n);return"function"!=typeof i?s:i})(e._customElements,t))(e),o=(e,t,n)=>{window.customElements.get(t)||window.customElements.define(t,n),e.customElements.get(t)||e.customElements.set(t,t)};class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}const l=(e,t)=>{const n=document.createElement("span");return n.classList.add(e),n.textContent=t,n};class InterstitialGrid extends FlowplayerComponent{constructor(e){super(e),this.classList.add("interstitial-grid"),this.addEventListener(InterstitialGrid.events.RENDER,t=>{this.prepare_endscreen(t.detail,e)}),e.on("resize",()=>{e.root.classList.contains("is-grid")&&this.items&&this.prepare_endscreen(this.items,e)}),this.previousButton=document.createElement("div"),this.previousButton.classList.add("fp-previous"),this.nextButton=document.createElement("div"),this.nextButton.classList.add("fp-next"),this.previousButton.addEventListener("click",this.navigation_buttons_listener.bind(this,!0)),this.nextButton.addEventListener("click",this.navigation_buttons_listener.bind(this,!1))}calculate_max_cells_number(e,t){const n=this.parentElement;if(!n)return;const s=window.getComputedStyle(n).padding,i=t.clientWidth-2*parseFloat(s),r=t.clientHeight-2*parseFloat(s);let o=e,l=0,d=0,a=0,c=0;e:for(;o>0;o-=1){if(1===o){l=i,d=Math.min(r,Math.max(l/1.5,l/1.8)),a=c=1;break}let e=1;for(;e<=o;e++){const t=Number.isInteger(o/e)?o/e:parseInt((o/e).toString())+1,n=i/e;let s=1.5;for(;s<=1.8;s+=.1){const i=n/s;if(i>=64&&i*t<=r&&n>=115){l=n,d=i,a=e,c=t;break e}}}}return this.style.setProperty("grid-template-columns",`repeat(${a}, ${l}px)`),this.style.setProperty("grid-template-rows",`repeat(${c}, ${d}px)`),o}prepare_endscreen(e,t){this.items=e,this.rendered_items=this.items.slice(0,this.calculate_max_cells_number(this.items.length,t)),this.populate_cells(this.rendered_items),this.hide_navigation_buttons(this.items.every((e,t)=>{var n;return e===(null===(n=this.rendered_items)||void 0===n?void 0:n[t])}))}populate_cells(e){this.innerHTML="",e.forEach(e=>{var t,n;const s=document.createElement("div");s.classList.add("grid-item"),e.poster&&(s.style.backgroundImage=`url(${e.poster})`);const i=document.createElement("div");i.classList.add("overlay");const r=l("title",null!==(t=e.title)&&void 0!==t?t:""),o=l("description",null!==(n=e.description)&&void 0!==n?n:"");i.append(r,o),s.append(i),s.addEventListener("click",()=>{const t=new CustomEvent(InterstitialGrid.events.SELECTION,{detail:e});this.dispatchEvent(t)}),this.append(s)})}hide_navigation_buttons(e){[this.previousButton,this.nextButton].forEach(t=>t.style.setProperty("display",e?"none":"block"))}connectedCallback(){var e;this.isConnected&&(null===(e=this.parentElement)||void 0===e||e.append(this.previousButton,this.nextButton))}navigation_buttons_listener(e){if(!this.rendered_items)return;const t=[];this.rendered_items.forEach(n=>{if(!this.items)return;const s=this.items.indexOf(n);if(void 0===s||-1===s)return;const i=this.calculate_index(e,s);void 0!==i&&t.push(this.items[i])}),this.rendered_items=t,this.populate_cells(this.rendered_items)}calculate_index(e,t){if(!this.items||!this.rendered_items)return;const n=this.items.length,s=this.rendered_items.length;let i=e?t-s:t+s;return i<0&&e&&(i=n+i),i>n-1&&!e&&(i-=n),i}}InterstitialGrid.events={SELECTION:"interstitial/grid/selection",RENDER:"interstitial/grid/render"};const d=["title","delay","description","poster","src"];class UpNext extends FlowplayerComponent{static get observedAttributes(){return d}constructor(e){super(e),this.classList.add("up-next"),this.addEventListener("animationend",()=>{this.dispatchEvent(new CustomEvent(t))}),this.addEventListener("animationcancel",()=>{this.classList.add("cancelled"),this.dispatchEvent(new CustomEvent(n))}),this.addEventListener(s,this._setUpNext.bind(this))}getTitle(){return this.getAttribute("title")||""}getDescription(){return this.getAttribute("description")||""}getPoster(){return this.getAttribute("poster")||""}getDelay(){return this.getAttribute("delay")||""}connectedCallback(){this.isConnected&&this._render()}attributeChangedCallback(){this._render()}_render(){var e,n;this.innerHTML="",this.classList.remove("cancelled");const s=document.createDocumentFragment(),i=document.createElement("div");i.classList.add("pane","left");const r=document.createElement("div");r.classList.add("pane","right"),s.append(i,r);const o=document.createElement("div");o.classList.add("poster"),o.style.backgroundImage="url("+this.getPoster()+")",i.append(o),o.addEventListener("click",()=>this.dispatchEvent(new CustomEvent(t)));const l=document.createElement("span");l.classList.add("fp-icon","fp-play"),o.append(l);const d=document.createElement("span");d.classList.add("title"),d.textContent=this.getTitle();const a=document.createElement("span");a.classList.add("description"),a.textContent=this.getDescription();const c=document.createElement("span");c.classList.add("countdown"),this.getDelay()&&(c.style.setProperty("--up-next-delay",this.getDelay()+"s"),c.classList.add("go"));const p=document.createElement("span");p.classList.add("cancel"),p.textContent=null!==(n=null===(e=this.player)||void 0===e?void 0:e.i18n("playlist.cancel"))&&void 0!==n?n:"cancel",p.addEventListener("click",()=>c.classList.remove("go")),r.append(d,a,p,c),this.append(s)}_setUpNext(e){var t,n,s;const i=e.detail.next,r=this.player.opt("playlist.delay",void 0)||10;this.setAttribute("title",null!==(t=i.title)&&void 0!==t?t:""),this.setAttribute("description",null!==(n=i.description)&&void 0!==n?n:""),this.setAttribute("poster",null!==(s=i.poster)&&void 0!==s?s:""),this.setAttribute("delay",r+"")}}function a(e,t){const n=function(){try{return localStorage.getItem("flowplayer/debug")}catch(e){return""}}(),s=(s,...i)=>{const r=(null==t?void 0:t.debug)||n;r&&e.match(r)&&console.log(`${e} -- ${s}`,...i)};return s.log=s,s}function c(e,t,n){const s=function(e,t){const n=new CustomEvent(e,{detail:t,cancelable:!0});return t&&Object.defineProperty(n,"data",{get:()=>t}),n}(t,n);return e.dispatchEvent(s),e}!function(){let e=!1;try{const t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("testPassive",null,t),window.removeEventListener("testPassive",null,t)}catch(e){}}();class EndscreenInterstitial extends FlowplayerComponent{constructor(e){super(e),this.className="fp-endscreen",this.upNextEle=r(e,"flowplayer-endscreen-up-next"),this.gridEle=r(e,"flowplayer-endscreen-grid"),this.append(this.upNextEle,this.gridEle),this.addEventListener("recommendations:render",this.on_recommendations_render.bind(this)),this.upNextEle.addEventListener(n,this.on_next_cancel.bind(this)),this.upNextEle.addEventListener(t,this.on_next_end.bind(this)),this.gridEle.addEventListener(InterstitialGrid.events.SELECTION,this.on_grid_selection.bind(this))}on_recommendations_render(e){const t=e.detail;if(this.playlist=t.playlist,this.on_item_selected=t.on_item_selected,this.player.playlist||!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 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.float_on_scroll=t())}(this,(function(){"use strict";const e="float:pop:in";var t=Object.freeze({__proto__:null,POP_IN:e,POP_OUT:"float:pop:out"});const
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.float_on_scroll=t())}(this,(function(){"use strict";const e="float:pop:in";var t=Object.freeze({__proto__:null,POP_IN:e,POP_OUT:"float:pop:out"});const n=(e,t)=>new(((e,t)=>{const n=e.get(t);if(!n)throw new Error(`no flowplayer component with the name ${t} exists`);const o=window.customElements.get(t);if(!o)throw new Error(`no default flowplayer component with the name ${t} exists`);const l=window.customElements.get(n);return"function"!=typeof l?o:l})(e._customElements,t))(e),o=(e,t,n)=>{window.customElements.get(t)||window.customElements.define(t,n),e.customElements.get(t)||e.customElements.set(t,t)};function l(e){return function(e){const t=e.getBoundingClientRect(),n=window.innerHeight,o=t.y;return o>n||o+t.height<0?0:t.y<0?(t.height+o)/t.height:n-t.y>t.height?1:Math.abs((n-t.y)/t.height)}(e)>.8}function s(t,n,o){0!=o.reaper&&o.floating&&i(o,n,e)}function i(t,n,o){o&&t.emit(o),setTimeout((function(){const l=n.querySelector(".fp-float-wrapper"),s=n.clientWidth/n.clientHeight;if(!l)return;l.style.height=o===e?"auto":l.clientWidth/s+"px";const i=l.querySelector(".fp-ad-container > div");i&&(i.style.position=o==e?"absolute":"static"),t.emit("resize")}))}class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}class FlowplayerIcon extends FlowplayerComponent{constructor(e,t){super(e),this.classList.add("fp-icon",t.name),t.title&&this.setAttribute("title",t.title),t.title&&this.setAttribute("aria-label",t.title),this.setAttribute("tabindex","0"),this.setAttribute("focusable","true")}}const r={translation_key:"core.mute",name:"fp-mute"},a={translation_key:"core.mute",name:"fp-unmute"},c={translation_key:"core.close",name:"fp-close"};class FloatOnScroll{constructor(e){this.flowplayer=e,o(this.flowplayer,"flowplayer-mute-icon",class extends FlowplayerIcon{constructor(e){super(e,r)}}),o(this.flowplayer,"flowplayer-unmute-icon",class extends FlowplayerIcon{constructor(e){super(e,a)}}),o(this.flowplayer,"flowplayer-close-icon",class extends FlowplayerIcon{constructor(e){super(e,c)}})}init(t,o,r){var a;if(t.multiplay||!1===t.float_on_scroll)return;if(function(){try{return window.self!==window.top}catch(e){return!0}}())return console.warn("iframe detected - floating player not supported in iframe");t.float_on_scroll="object"!=typeof t.float_on_scroll?{}:t.float_on_scroll,t.autopause&&r.setOpts({autopause:!1});const c={pop_out_container:(null===(a=t.float_on_scroll)||void 0===a?void 0:a.container)||function(e,t){const n=document.createElement("div");return n.classList.add("fp-float-wrapper"),e.appendChild(n),Array.from(e.childNodes).forEach((function(e){e instanceof Element&&(e===n||e.classList.contains("fp-ratio"))||n.appendChild(e)})),setTimeout(()=>{const t=e.querySelector("flowplayer-ad-ui");t&&n.appendChild(t)},0),t.getFullsceenTarget=()=>n,n}(o,r),was_user_toggled:!1};r.on("renderplugin",(function(e){e.preventDefault(),e.detail&&c.pop_out_container.append(e.detail)}));const u=function(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}(r,"flowplayer-header");u&&function(e,t,o,l){const i=document.createElement("div");i.classList.add("fp-exit-float"),i.append(Object.assign(n(l,"flowplayer-close-icon"),{role:"button"}));const r=()=>{t.was_user_toggled=!0,l.togglePlay(!1),s(0,o,l)};i.addEventListener("click",r),e.append(i),setTimeout(()=>{const e=o.querySelector(".fp-ad-controls");if(!e)return;const t=i.cloneNode(!0);e.append(t),t.addEventListener("click",r)},0);const a=document.createElement("div");a.classList.add("fp-mute-float"),a.append(...Object.assign([n(l,"flowplayer-mute-icon"),n(l,"flowplayer-unmute-icon")],{role:"button"})),a.addEventListener("click",(function(){l.toggleMute()})),e.append(a)}(u,c,o,r);const f=function(e,t){const n=e||60,o=Math.ceil(1e3/n);let l=Date.now(),s=-1;return function(...e){return s>-1||Date.now()<l||(s=requestAnimationFrame((function(){s=-1,t(),l=Date.now()+o}))),s}}(0,(function(){if(l(o)){if(r.hasState("is-fullscreen"))return;s(0,o,r)}})),p=function(){i(r,o)};r.on("viewleave",e=>{(function(e){return!e.paused||!(!e.ads||!e.ads.adPlaying)})(r)&&!c.was_user_toggled&&(e.preventDefault(),function(e,t,n){0==n.reaper||n.floating||i(n,t,"float:pop:out")}(0,o,r))}),r.on("viewenter",(function(){c.was_user_toggled=!1})),r.on("float:pop:out",(function(){window.addEventListener("scroll",f),r.floating=!0,r.setState("is-popped-out",!0),window.addEventListener("resize",p)})),r.on(e,(function(){window.removeEventListener("scroll",f),r.floating=!1,r.setState("is-popped-out",!1),window.removeEventListener("resize",p)}))}}return FloatOnScroll.events=t,function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;return"function"==typeof n?(n(t),t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t),t)}(window,FloatOnScroll)}));
|
package/plugins/health.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.health=t())}(this,(function(){"use strict";const e="rebuffer";var t=Object.freeze({__proto__:null,RECORD:"health:record",REBUFFER:e});const n="load",i="fullscreenenter",o="fullscreenexit",s="loadedmetadata",r="loadeddata",a="progress",d="loadstart",c="pause",l="playing",u="waiting",_="canplay",h="ended",f="seeked",p="seeking";function
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.health=t())}(this,(function(){"use strict";const e="rebuffer";var t=Object.freeze({__proto__:null,RECORD:"health:record",REBUFFER:e});const n="load",i="fullscreenenter",o="fullscreenexit",s="loadedmetadata",r="loadeddata",a="progress",d="loadstart",c="pause",l="playing",u="waiting",_="canplay",h="ended",f="seeked",p="seeking";function v(e){try{return!!new URL(e)}catch(e){return!1}}function E(e,t){const n=function(){try{return localStorage.getItem("flowplayer/debug")}catch(e){return""}}(),i=(i,...o)=>{const s=(null==t?void 0:t.debug)||n;s&&e.match(s)&&console.log(`${e} -- ${i}`,...o)};return i.log=i,i}const m=navigator;function g(e){var t,n;const i=null===(t=e.hls)||void 0===t?void 0:t.bandwidthEstimate;return i?1e-6*i:(null===(n=m.connection)||void 0===n?void 0:n.downlink)||-1}function y(e,t){return function(e,t){return"function"==typeof navigator.sendBeacon&&navigator.sendBeacon(e,t)}(e,JSON.stringify({events:t}))}const R="https://ljsp.lwcdn.com".concat("/web/public/countdown/time.json"),O=window,I=O._flowplayerTimekeeper||(O._flowplayerTimekeeper={});var w;!function(e){e[e.OFF=0]="OFF",e[e.ON=1]="ON",e[e.AUDIO_REQUIRED=2]="AUDIO_REQUIRED"}(w||(w={}));const D=e=>{switch(e){case!0:return w.ON;case!1:return w.OFF;default:return e}},N=[];function T(e){if(e.suspended)return;const t=N.slice(0);N.length=0,0!=t.length&&(e.logger.log(`:dispatch events={${t.length}}`),y("https://ihi.flowplayer.com/v1/health/events",t))}async function A(e,t,n){const i=await S();N.push(Object.assign(t,i)),e.logger.log(":enqueue",t.event,t),N.length<10&&!n||T(e)}const b=()=>{var e,t;try{const n=window;return null===(t=null===(e=null==n?void 0:n.google)||void 0===e?void 0:e.ima)||void 0===t?void 0:t.VERSION}catch(e){return}},S=async()=>{const e=Date.now();try{return{adjusted_time:e-await async function(){const e=I.cachedServerOffset;if(e)return e;const t=I.pendingRequest||(I.pendingRequest=fetch(R)),n=await t,i=parseInt(n.headers.get("age")||"0"),o=await n.json(),s=Date.now()-o.millisUtc-1e3*i;return I.cachedServerOffset=s,I.cachedServerOffset}(),client_time:e}}catch(t){return{client_time:e}}},U=(e,t)=>Object.assign(e,{detail:t}),k=(e,{event:t,media_session_id:n,session_id:i})=>({event:t,media_session_id:n,session_id:i,device_id:e.deviceId(),version:"3.2.8",commit:"7e733a5ef06816f5a96f8e27c1ef7927fc55599b",ima_sdk_version:b(),preload:e.opt("preload"),autoplay:D(e.opt("autoplay")),live:e.opt("live"),dvr:!!e.live_state.dvr,source:e.original_src,downlink_mbs:g(e),player_id:e.opt("metadata.player_id"),media_id:e.opt("metadata.media_id"),site_id:e.opt("metadata.site_id"),category_id:e.opt("metadata.category_id"),sitegroup_id:e.opt("metadata.sitegroup_id"),token:e.token,plugins:e.plugins.map(e=>e.constructor.name).sort((e,t)=>e.localeCompare(t)),current_time:e.currentTime,external_media_id:e.opt("external_media_id")}),C=e=>({bitrate:null==e?void 0:e.bitrate,resolution:null==e?void 0:e.attrs.RESOLUTION,frame_rate:null==e?void 0:e.attrs["FRAME-RATE"]});function L(e,t,n,i){const o=k(t,e.eventInfo(n)),{before:s,after:r}=i;A(e,((e,t,n)=>Object.assign(e,{state:{before:t,after:n}}))(o,C(s),C(r)))}const M=[1e7]+""+-1e3+-4e3+-8e3+-1e11,B=()=>"undefined"==typeof crypto?"":M.replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16));var x;function F(e){switch(e){case x.MEDIA_PLAYBACK_ABORTED:return"media playback was aborted";case x.MEDIA_ERR_NETWORK:return"a network error occurred";case x.MEDIA_ERR_DECODE:return"unable to decode media content";case x.MEDIA_ERR_SRC_NOT_SUPPORTED:return"unsupported media type";case x.NO_INTERNET:return"no internet connection detected";case x.MIXED_CONTENT:return"cannot load insecure content in a secure context";default:return"an unknown error occurred"}}!function(e){e[e.UNKNOWN=-1]="UNKNOWN",e[e.MEDIA_PLAYBACK_ABORTED=1]="MEDIA_PLAYBACK_ABORTED",e[e.MEDIA_ERR_NETWORK=2]="MEDIA_ERR_NETWORK",e[e.MEDIA_ERR_DECODE=3]="MEDIA_ERR_DECODE",e[e.MEDIA_ERR_SRC_NOT_SUPPORTED=4]="MEDIA_ERR_SRC_NOT_SUPPORTED",e[e.MIXED_CONTENT=1001]="MIXED_CONTENT",e[e.NO_INTERNET=1002]="NO_INTERNET"}(x||(x={}));const j=(e,t)=>{let n=null;return(...i)=>{null!==n&&(clearTimeout(n),n=null),n=setTimeout(()=>t(...i),e)}},H=B();class Health{constructor(e,t){this.session_id=H,this.suspended=!1,this.logger=E("health",t.opts),this.media_session_id=B(),this.analyticsLoop=setInterval(()=>T(this),2e3),t.on("reap",()=>clearInterval(this.analyticsLoop));const n=this;if(t.health={get media_session_id(){return n.media_session_id},set media_session_id(e){n.media_session_id=e},get session_id(){return n.session_id},set session_id(e){n.session_id=e},toggle(e){e?n.resume():n.suspend()}},!Health._UNLOAD_SUBSCRIBED){Health._UNLOAD_SUBSCRIBED=!0;const t=t=>e.instances.forEach(e=>e.emit(t.type));document.addEventListener("visibilitychange",e=>{"hidden"==document.visibilityState&&t(e)}),window.addEventListener("pagehide",t)}}eventInfo(e){return{event:e,media_session_id:this.media_session_id,session_id:this.session_id}}suspend(){this.suspended=!0,clearInterval(this.analyticsLoop)}resume(){this.suspended=!1,this.analyticsLoop=setInterval(()=>T(this),2e3)}init(t,E,m){!function(t){t.on(u,(function(n){t.seeking||t.networkState===t.NETWORK_LOADING&&t.readyState!==t.HAVE_NOTHING&&t.emit(e)}))}(m),m.on("health:record",({detail:e})=>{const t=k(m,this.eventInfo(e.event));Object.assign(t,e.detail||{}),A(this,t)}),[_,d,n,s,r,a,u,e].forEach(e=>{m.on(e,e=>{A(this,k(m,this.eventInfo(e.type)))})}),[l,c,p,f,h,i,o].forEach(e=>{m.on(e,e=>{A(this,k(m,this.eventInfo(e.type)))})}),m.on("volumechange",j(800,e=>{const t=k(m,this.eventInfo(e.type));A(this,U(t,{volume:parseFloat(m.volume.toFixed(2)),muted:m.muted}))})),m.on("resize",j(800,e=>{const t=k(m,this.eventInfo(e.type));A(this,U(t,{height:E.clientHeight,width:E.clientWidth}))})),m.on("qualitychange",({type:e,detail:t})=>{switch(t.kind){case"hls":return L(this,m,e,t)}});let g=Date.now()+5e3;m.on("timeupdate",e=>{if(Date.now()<g)return;g=Date.now()+5e3;const t=k(m,this.eventInfo(e.type));var n;A(this,U(t,{duration:(n=m.duration,Number.isFinite(n)?n:n===1/0?-1:void 0)}))}),m.addEventListener("error",e=>{const t=k(m,this.eventInfo(e.type)),n=e.error||m.error;if(!n)return A(this,t,!0);const i=n.code,o={error_message:n.message||F(i),error_code:i,error_stack:n.stack||""};return A(this,U(t,o),!0)}),m.on("src",e=>{var t;const n=null===(t=e.detail)||void 0===t?void 0:t.src;if("string"!=typeof n)return;if(!v(m.original_src))return;if(!v(n))return;if(n==m.original_src)return;this.media_session_id=B();A(this,k(m,this.eventInfo(e.type))),T(this)}),m.on("visibilitychange",e=>{A(this,k(m,this.eventInfo(e.type))),T(this)})}}return Health.events=t,Health._UNLOAD_SUBSCRIBED=!1,function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;"function"==typeof n?n(t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t))}(window,Health),Health}));
|
package/plugins/hls.js
CHANGED
|
@@ -354,4 +354,4 @@
|
|
|
354
354
|
/*!*********************************!*\
|
|
355
355
|
!*** ./src/utils/xhr-loader.ts ***!
|
|
356
356
|
\*********************************/
|
|
357
|
-
/*! exports provided: default */function(t,e,r){r.r(e);var i=r(/*! ../utils/logger */"./src/utils/logger.ts"),n=r(/*! ../loader/load-stats */"./src/loader/load-stats.ts"),s=/^age:\s*[\d.]+\s*$/m,a=function(){function t(t){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=t?t.xhrSetup:null,this.stats=new n.LoadStats,this.retryDelay=0}var e=t.prototype;return e.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},e.abortInternal=function(){var t=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),t&&(t.onreadystatechange=null,t.onprogress=null,4!==t.readyState&&(this.stats.aborted=!0,t.abort()))},e.abort=function(){var t;this.abortInternal(),null!==(t=this.callbacks)&&void 0!==t&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},e.load=function(t,e,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=t,this.config=e,this.callbacks=r,this.retryDelay=e.retryDelay,this.loadInternal()},e.loadInternal=function(){var t=this.config,e=this.context;if(t){var r=this.loader=new self.XMLHttpRequest,i=this.stats;i.loading.first=0,i.loaded=0;var n=this.xhrSetup;try{if(n)try{n(r,e.url)}catch(t){r.open("GET",e.url,!0),n(r,e.url)}r.readyState||r.open("GET",e.url,!0)}catch(t){return void this.callbacks.onError({code:r.status,text:t.message},e,r)}e.rangeEnd&&r.setRequestHeader("Range","bytes="+e.rangeStart+"-"+(e.rangeEnd-1)),r.onreadystatechange=this.readystatechange.bind(this),r.onprogress=this.loadprogress.bind(this),r.responseType=e.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),t.timeout),r.send()}},e.readystatechange=function(){var t=this.context,e=this.loader,r=this.stats;if(t&&e){var n=e.readyState,s=this.config;if(!r.aborted&&n>=2)if(self.clearTimeout(this.requestTimeout),0===r.loading.first&&(r.loading.first=Math.max(self.performance.now(),r.loading.start)),4===n){e.onreadystatechange=null,e.onprogress=null;var a=e.status;if(a>=200&&a<300){var o,l;if(r.loading.end=Math.max(self.performance.now(),r.loading.first),l="arraybuffer"===t.responseType?(o=e.response).byteLength:(o=e.responseText).length,r.loaded=r.total=l,!this.callbacks)return;var u=this.callbacks.onProgress;if(u&&u(r,t,o,e),!this.callbacks)return;var d={url:e.responseURL,data:o};this.callbacks.onSuccess(d,r,t,e)}else r.retry>=s.maxRetry||a>=400&&a<499?(i.logger.error(a+" while loading "+t.url),this.callbacks.onError({code:a,text:e.statusText},t,e)):(i.logger.warn(a+" while loading "+t.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,s.maxRetryDelay),r.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),s.timeout)}},e.loadtimeout=function(){i.logger.warn("timeout while loading "+this.context.url);var t=this.callbacks;t&&(this.abortInternal(),t.onTimeout(this.stats,this.context,this.loader))},e.loadprogress=function(t){var e=this.stats;e.loaded=t.loaded,t.lengthComputable&&(e.total=t.total)},e.getCacheAge=function(){var t=null;if(this.loader&&s.test(this.loader.getAllResponseHeaders())){var e=this.loader.getResponseHeader("age");t=e?parseFloat(e):null}return t},t}();e.default=a}}).default},t.exports=r())})));var r=Object.freeze({__proto__:null,ATTACHED:"hls:attached"});const i="com.widevine.alpha";const n="application/vnd.apple.mpegURL",s=[n,"application/x-mpegurl"],a=document.createElement("video").canPlayType(n);function o(t){const{pathname:e}=function(t){const e=document.createElement("a");return e.href=t,e}(t);return e.endsWith(".m3u8")}function l({src:t="",type:e="",drm:r},n){const l=(null==n?void 0:n.hls)||{},u="native"in l&&l.native;return(!a||!u)&&(!(r&&!Object.keys(r).find(t=>{return e=t,[i].filter((function(t){return t===e})).length;var e}))&&(!(!e||!s.includes(e))||o(t)))}var u="audio:set",d="audio:update",c="audio:tracks";const h=[e.Events.SUBTITLE_TRACKS_UPDATED,e.Events.SUBTITLE_TRACK_SWITCH,e.Events.LEVEL_SWITCHED];function f(t,e){h.forEach((function(r){t.on(r,(function(){!function(t,e){var r;const i=t.levels[t.currentLevel];if(!i||!t.subtitleTracks.length||i.attrs.SUB)return;const n=null===(r=null==i?void 0:i.attrs)||void 0===r?void 0:r.SUBTITLES;if(!n)return e.emit("tracks:text:all",[]);const s=t.subtitleTracks.filter((function(t){return t.groupId==n})).map((function(t){return e.textTracks[t.id]}));e.emit("tracks:text:all",s)}(t,e)}))}))}var g=Object.assign(Object.assign({},{404:"the video was not found",403:"access to this video was denied",410:"the video no longer exists",0:"no internet connection detected"}),{keySystemNoKeys:"no keys",keySystemNoAccess:"no access to key system",keySystemNoSession:"no session for key system",keySystemLicenseRequestFailed:"license request failed",keyLoadError:"decrypt key load failed",keyLoadTimeOut:"decrypt key load timed outs"});var v;!function(t){t[t.LOW=1]="LOW",t[t.MEDIUM=2]="MEDIUM",t[t.HIGH=4]="HIGH"}(v||(v={}));const p=function(t,e){const r=function(){try{return localStorage.getItem("flowplayer/debug")}catch(t){return""}}(),i=(i,...n)=>{const s=(null==e?void 0:e.debug)||r;s&&t.match(s)&&console.log(`${t} -- ${i}`,...n)};return i.log=i,i}("hls");function m(t,r,i){if(!t.reaper||!i.src)return;t.hls&&(t.emit("recover",{type:"hls"}),t.hls.destroy());const n="live"in r==0,s={is_audio_only:!1,fragDuration:-1};if(i.drm&&"https:"!==location.protocol&&"localhost"!==location.hostname&&"127.0.0.1"!==location.hostname)return t.emit("error",{message:"Secure page required for DRM"});const a=t.hls=new e(function(t){return Object.assign(Object.assign({autoStartLoad:!1},t.hls),{startPosition:t.start_time||-1})}(r)),o={retry_count:0,previous_url:"",previous_content:""};a.subtitleDisplay=!1,a.attachMedia(t),a.loadSource(i.src),t.emit("hls:attached",{hls:a}),function(t,r){t.on(e.Events.AUDIO_TRACKS_UPDATED,(function(t,e){r.emit(c,e.audioTracks)})),t.on(e.Events.AUDIO_TRACK_SWITCHING,(function(t,e){r.emit(d,e)})),t.on(e.Events.MANIFEST_PARSED,(function(t,e){e.audioTracks&&r.emit(c,e.audioTracks)})),t.on(e.Events.LEVEL_SWITCHED,(function(e,i){const n=t.levels[i.level];n&&r.emit(c,t.audioTracks.filter((function(t){return t.groupId&&~(n.audioGroupIds||[]).indexOf(t.groupId)})))}))}(a,t),f(a,t);const l=function(t){var e;const r=null===(e=t.data)||void 0===e?void 0:e.level;"number"==typeof r&&(a.levels[r]||-1===r?a.nextLevel=r:console.error(new Error("skipping invalid quality: "+t.data)))},h=function(t){var e;const r=null===(e=t.data)||void 0===e?void 0:e.id;"number"==typeof r&&r!=a.audioTrack&&setTimeout((function(){a.audioTrack=r}),0)};t.on("quality:set",l),t.on(u,h),t.on("src",(function(){t.hls&&t.hls.destroy(),t.off("quality:set",l),t.off(u,h)})),t.on("audioonlysource",(function(){s.is_audio_only=!0})),t.on("reap",(function(){a&&a.destroy()})),t.on("remotesession:started",()=>{t.hls&&t.hls.stopLoad()}),t.on("remotesession:ended",()=>{t.hls&&y(t)}),n&&a.on(e.Events.LEVEL_LOADED,(function(e,r){t.setOpts({live:r.details.live})})),a.on(e.Events.MANIFEST_PARSED,(function(e,i){const n=i.levels.slice(0).reduce((t,e,r)=>[...t,{level:r,text:e.name||e.width+"",width:e.width,height:e.height,videoCodec:e.videoCodec||""}],[{text:"AUTO",level:-1,width:0,height:0,videoCodec:""}]).sort((t,e)=>e.width-t.width);t.emit("qualities",n),function(t,e,r){var i,n;if(!t.hls)return;p("Initializer::maybe_start_load_with_quality (start_quality, preload): (%d, %s)",e.start_quality,e.preload),void 0!==e.start_quality&&(v.HIGH&e.start_quality&&(t.hls.startLevel=r[0].level),v.LOW&e.start_quality&&(t.hls.startLevel=r[r.length-1].level),v.MEDIUM&e.start_quality&&(t.hls.startLevel=r[Math.ceil(r.length/2)-1].level));const s=(null===(i=e.hls)||void 0===i?void 0:i.maxBufferSize)||1024,a=(null===(n=e.hls)||void 0===n?void 0:n.maxBufferLength)||30;p("Setting maxBufferSize to %d",s),t.hls.config.maxBufferSize=s,"metadata"===e.preload&&p("preload === metadata, setting maxBufferLength to 1sec");if(t.hls.config.maxBufferLength="metadata"===e.preload?1:a,t.once("playing",()=>{p("Playback started, set maxBufferLenght to %d",a),t.hls&&(t.hls.config.maxBufferLength=a)}),"none"===e.preload&&!e.autoplay)return;y(t,e.start_time||-1)}(t,r,n.slice(0,-1));const s=n.find(t=>!!t.videoCodec);s||t.emit("audioonlysource"),!t.opt("ratio")&&s&&0!=s.width&&0!=s.height&&t.setOpts({ratio:s.width+":"+s.height})})),a.on(e.Events.INIT_PTS_FOUND,(function(t,e){s.fragDuration=e.frag.duration})),a.on(e.Events.ERROR,(function(r,i){!function(t,r,i,n){if(0==t.reaper)return;if(0==r.fatal)return;switch(r.type){case e.ErrorTypes.MEDIA_ERROR:return function(t,e){var r;t.emit("error",{fatal:!0,message:"Unrecoverable error occurred while playing media"}),null===(r=t.hls)||void 0===r||r.destroy()}(t);case e.ErrorTypes.NETWORK_ERROR:return function(t,e){var r;const i=(null===(r=e.networkDetails)||void 0===r?void 0:r.status)||"";t.emit("error",{fatal:!0,code:"http:"+i.toString(),message:g[i]||"an error occurred while loading this video"})}(t,r);case e.ErrorTypes.KEY_SYSTEM_ERROR:(function(t,e){var r;t.emit("error",{fatal:!0,message:g[e.details]||"an error occurred while accessing this video"}),null===(r=t.hls)||void 0===r||r.destroy()})(t,r)}}(t,i,t.original_src,a.config)})),a.on(e.Events.LEVEL_PTS_UPDATED,(function(e,r){var i;if("video"!==r.type&&(!s.is_audio_only||"audio"!==r.type))return;const n=null===(i=null==r?void 0:r.details)||void 0===i?void 0:i.fragments;if(!n)return;const a=n[0].start||0,o=n[n.length-1].start+n[n.length-1].duration;t.emit("dvr/window",o-a)})),a.on(e.Events.LEVEL_SWITCHING,(e,r)=>{const i=a.levels[a.currentLevel],n=a.levels[r.level];t.emit("qualitychange",{before:i,after:n,kind:"hls"})}),a.on(e.Events.LEVEL_UPDATED,(t,e)=>{e.details.url!==o.previous_url&&(o.retry_count=0),o.previous_url=e.details.url;const r=o.previous_content;if(o.previous_content=e.details.m3u8,r===e.details.m3u8){if(o.retry_count++,o.retry_count<3)return;if(a.levels[e.level].url.length<2)return;a.levelController.redundantFailover(a.currentLevel)}});const m=t.opt("start_time");m&&t.once("loadedmetadata",(function(){t.currentTime=m})),"none"!==r.preload||r.autoplay||t.once("beforeplay",()=>{y(t,r.start_time||-1)})}function y(t,e){var r;t.setState("is-loading",!0),null===(r=t.hls)||void 0===r||r.startLoad(e)}class HLS{init(){}onload(t,e,r,i){m(r,t,i)}wants(t,r,i){return e.isSupported()&&l(r,i)}}return HLS.events=r,HLS.version=e.version,function(t,e){if("object"==typeof exports&&"undefined"!=typeof module)return e;"flowplayer"in t||(t.flowplayer={extensions:[]});const r=t.flowplayer;"function"==typeof r?r(e):(Array.isArray(r.extensions)||(r.extensions=[]),~r.extensions.indexOf(e)||r.extensions.push(e))}(window,HLS),HLS}));
|
|
357
|
+
/*! exports provided: default */function(t,e,r){r.r(e);var i=r(/*! ../utils/logger */"./src/utils/logger.ts"),n=r(/*! ../loader/load-stats */"./src/loader/load-stats.ts"),s=/^age:\s*[\d.]+\s*$/m,a=function(){function t(t){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=t?t.xhrSetup:null,this.stats=new n.LoadStats,this.retryDelay=0}var e=t.prototype;return e.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},e.abortInternal=function(){var t=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),t&&(t.onreadystatechange=null,t.onprogress=null,4!==t.readyState&&(this.stats.aborted=!0,t.abort()))},e.abort=function(){var t;this.abortInternal(),null!==(t=this.callbacks)&&void 0!==t&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},e.load=function(t,e,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=t,this.config=e,this.callbacks=r,this.retryDelay=e.retryDelay,this.loadInternal()},e.loadInternal=function(){var t=this.config,e=this.context;if(t){var r=this.loader=new self.XMLHttpRequest,i=this.stats;i.loading.first=0,i.loaded=0;var n=this.xhrSetup;try{if(n)try{n(r,e.url)}catch(t){r.open("GET",e.url,!0),n(r,e.url)}r.readyState||r.open("GET",e.url,!0)}catch(t){return void this.callbacks.onError({code:r.status,text:t.message},e,r)}e.rangeEnd&&r.setRequestHeader("Range","bytes="+e.rangeStart+"-"+(e.rangeEnd-1)),r.onreadystatechange=this.readystatechange.bind(this),r.onprogress=this.loadprogress.bind(this),r.responseType=e.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),t.timeout),r.send()}},e.readystatechange=function(){var t=this.context,e=this.loader,r=this.stats;if(t&&e){var n=e.readyState,s=this.config;if(!r.aborted&&n>=2)if(self.clearTimeout(this.requestTimeout),0===r.loading.first&&(r.loading.first=Math.max(self.performance.now(),r.loading.start)),4===n){e.onreadystatechange=null,e.onprogress=null;var a=e.status;if(a>=200&&a<300){var o,l;if(r.loading.end=Math.max(self.performance.now(),r.loading.first),l="arraybuffer"===t.responseType?(o=e.response).byteLength:(o=e.responseText).length,r.loaded=r.total=l,!this.callbacks)return;var u=this.callbacks.onProgress;if(u&&u(r,t,o,e),!this.callbacks)return;var d={url:e.responseURL,data:o};this.callbacks.onSuccess(d,r,t,e)}else r.retry>=s.maxRetry||a>=400&&a<499?(i.logger.error(a+" while loading "+t.url),this.callbacks.onError({code:a,text:e.statusText},t,e)):(i.logger.warn(a+" while loading "+t.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,s.maxRetryDelay),r.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),s.timeout)}},e.loadtimeout=function(){i.logger.warn("timeout while loading "+this.context.url);var t=this.callbacks;t&&(this.abortInternal(),t.onTimeout(this.stats,this.context,this.loader))},e.loadprogress=function(t){var e=this.stats;e.loaded=t.loaded,t.lengthComputable&&(e.total=t.total)},e.getCacheAge=function(){var t=null;if(this.loader&&s.test(this.loader.getAllResponseHeaders())){var e=this.loader.getResponseHeader("age");t=e?parseFloat(e):null}return t},t}();e.default=a}}).default},t.exports=r())})));var r=Object.freeze({__proto__:null,ATTACHED:"hls:attached"});const i="com.widevine.alpha";const n="application/vnd.apple.mpegURL",s=[n,"application/x-mpegurl"],a=document.createElement("video").canPlayType(n);function o(t){const{pathname:e}=function(t){const e=document.createElement("a");return e.href=t,e}(t);return e.endsWith(".m3u8")}function l({src:t="",type:e="",drm:r},n){const l=(null==n?void 0:n.hls)||{},u="native"in l&&l.native;return(!a||!u)&&(!(r&&!Object.keys(r).find(t=>{return e=t,[i].filter((function(t){return t===e})).length;var e}))&&(!(!e||!s.includes(e))||o(t)))}var u="audio:set",d="audio:update",c="audio:tracks";const h=[e.Events.SUBTITLE_TRACKS_UPDATED,e.Events.SUBTITLE_TRACK_SWITCH,e.Events.LEVEL_SWITCHED];function f(t,e){h.forEach((function(r){t.on(r,(function(){!function(t,e){var r;const i=t.levels[t.currentLevel];if(!i||!t.subtitleTracks.length||i.attrs.SUB)return;const n=null===(r=null==i?void 0:i.attrs)||void 0===r?void 0:r.SUBTITLES;if(!n)return e.emit("tracks:text:all",[]);const s=t.subtitleTracks.filter((function(t){return t.groupId==n})).map((function(t){return e.textTracks[t.id]}));e.emit("tracks:text:all",s)}(t,e)}))}))}var g=Object.assign(Object.assign({},{404:"the video was not found",403:"access to this video was denied",410:"the video no longer exists",0:"no internet connection detected"}),{keySystemNoKeys:"no keys",keySystemNoAccess:"no access to key system",keySystemNoSession:"no session for key system",keySystemLicenseRequestFailed:"license request failed",keyLoadError:"decrypt key load failed",keyLoadTimeOut:"decrypt key load timed outs"});var v;!function(t){t[t.LOW=1]="LOW",t[t.MEDIUM=2]="MEDIUM",t[t.HIGH=4]="HIGH"}(v||(v={}));const p=function(t,e){const r=function(){try{return localStorage.getItem("flowplayer/debug")}catch(t){return""}}(),i=(i,...n)=>{const s=(null==e?void 0:e.debug)||r;s&&t.match(s)&&console.log(`${t} -- ${i}`,...n)};return i.log=i,i}("hls");function m(t,r,i){if(!t.reaper||!i.src)return;t.hls&&t.hls.destroy();const n="live"in r==0,s={is_audio_only:!1,fragDuration:-1};if(i.drm&&"https:"!==location.protocol&&"localhost"!==location.hostname&&"127.0.0.1"!==location.hostname)return t.emit("error",{message:"Secure page required for DRM"});const a=t.hls=new e(function(t){return Object.assign(Object.assign({autoStartLoad:!1},t.hls),{startPosition:t.start_time||-1})}(r)),o={retry_count:0,previous_url:"",previous_content:""};a.subtitleDisplay=!1,a.attachMedia(t),a.loadSource(i.src),t.emit("hls:attached",{hls:a}),function(t,r){t.on(e.Events.AUDIO_TRACKS_UPDATED,(function(t,e){r.emit(c,e.audioTracks)})),t.on(e.Events.AUDIO_TRACK_SWITCHING,(function(t,e){r.emit(d,e)})),t.on(e.Events.MANIFEST_PARSED,(function(t,e){e.audioTracks&&r.emit(c,e.audioTracks)})),t.on(e.Events.LEVEL_SWITCHED,(function(e,i){const n=t.levels[i.level];n&&r.emit(c,t.audioTracks.filter((function(t){return t.groupId&&~(n.audioGroupIds||[]).indexOf(t.groupId)})))}))}(a,t),f(a,t);const l=function(t){var e;const r=null===(e=t.data)||void 0===e?void 0:e.level;"number"==typeof r&&(a.levels[r]||-1===r?a.nextLevel=r:console.error(new Error("skipping invalid quality: "+t.data)))},h=function(t){var e;const r=null===(e=t.data)||void 0===e?void 0:e.id;"number"==typeof r&&r!=a.audioTrack&&setTimeout((function(){a.audioTrack=r}),0)};t.on("quality:set",l),t.on(u,h),t.on("src",(function(){t.hls&&t.hls.destroy(),t.off("quality:set",l),t.off(u,h)})),t.on("audioonlysource",(function(){s.is_audio_only=!0})),t.on("reap",(function(){a&&a.destroy()})),t.on("remotesession:started",()=>{t.hls&&t.hls.stopLoad()}),t.on("remotesession:ended",()=>{t.hls&&y(t)}),n&&a.on(e.Events.LEVEL_LOADED,(function(e,r){t.setOpts({live:r.details.live})})),a.on(e.Events.MANIFEST_PARSED,(function(e,i){const n=i.levels.slice(0).reduce((t,e,r)=>[...t,{level:r,text:e.name||e.width+"",width:e.width,height:e.height,videoCodec:e.videoCodec||""}],[{text:"AUTO",level:-1,width:0,height:0,videoCodec:""}]).sort((t,e)=>e.width-t.width);t.emit("qualities",n),function(t,e,r){var i,n;if(!t.hls)return;p("Initializer::maybe_start_load_with_quality (start_quality, preload): (%d, %s)",e.start_quality,e.preload),void 0!==e.start_quality&&(v.HIGH&e.start_quality&&(t.hls.startLevel=r[0].level),v.LOW&e.start_quality&&(t.hls.startLevel=r[r.length-1].level),v.MEDIUM&e.start_quality&&(t.hls.startLevel=r[Math.ceil(r.length/2)-1].level));const s=(null===(i=e.hls)||void 0===i?void 0:i.maxBufferSize)||1024,a=(null===(n=e.hls)||void 0===n?void 0:n.maxBufferLength)||30;p("Setting maxBufferSize to %d",s),t.hls.config.maxBufferSize=s,"metadata"===e.preload&&p("preload === metadata, setting maxBufferLength to 1sec");if(t.hls.config.maxBufferLength="metadata"===e.preload?1:a,t.once("playing",()=>{p("Playback started, set maxBufferLenght to %d",a),t.hls&&(t.hls.config.maxBufferLength=a)}),"none"===e.preload&&!e.autoplay)return;y(t,e.start_time||-1)}(t,r,n.slice(0,-1));const s=n.find(t=>!!t.videoCodec);s||t.emit("audioonlysource"),!t.opt("ratio")&&s&&0!=s.width&&0!=s.height&&t.setOpts({ratio:s.width+":"+s.height})})),a.on(e.Events.INIT_PTS_FOUND,(function(t,e){s.fragDuration=e.frag.duration})),a.on(e.Events.ERROR,(function(r,i){!function(t,r,i,n){if(0==t.reaper)return;if(0==r.fatal)return;switch(r.type){case e.ErrorTypes.MEDIA_ERROR:return function(t,e){var r;t.emit("error",{fatal:!0,message:"Unrecoverable error occurred while playing media"}),null===(r=t.hls)||void 0===r||r.destroy()}(t);case e.ErrorTypes.NETWORK_ERROR:return function(t,e){var r;const i=(null===(r=e.networkDetails)||void 0===r?void 0:r.status)||"";t.emit("error",{fatal:!0,code:"http:"+i.toString(),message:g[i]||"an error occurred while loading this video"})}(t,r);case e.ErrorTypes.KEY_SYSTEM_ERROR:(function(t,e){var r;t.emit("error",{fatal:!0,message:g[e.details]||"an error occurred while accessing this video"}),null===(r=t.hls)||void 0===r||r.destroy()})(t,r)}}(t,i,t.original_src,a.config)})),a.on(e.Events.LEVEL_PTS_UPDATED,(function(e,r){var i;if("video"!==r.type&&(!s.is_audio_only||"audio"!==r.type))return;const n=null===(i=null==r?void 0:r.details)||void 0===i?void 0:i.fragments;if(!n)return;const a=n[0].start||0,o=n[n.length-1].start+n[n.length-1].duration;t.emit("dvr/window",o-a)})),a.on(e.Events.LEVEL_SWITCHING,(e,r)=>{const i=a.levels[a.currentLevel],n=a.levels[r.level];t.emit("qualitychange",{before:i,after:n,kind:"hls"})}),a.on(e.Events.LEVEL_UPDATED,(t,e)=>{e.details.url!==o.previous_url&&(o.retry_count=0),o.previous_url=e.details.url;const r=o.previous_content;if(o.previous_content=e.details.m3u8,r===e.details.m3u8){if(o.retry_count++,o.retry_count<3)return;if(a.levels[e.level].url.length<2)return;a.levelController.redundantFailover(a.currentLevel)}});const m=t.opt("start_time");m&&t.once("loadedmetadata",(function(){t.currentTime=m})),"none"!==r.preload||r.autoplay||t.once("beforeplay",()=>{t.hasState("is-casting")||y(t,r.start_time||-1)})}function y(t,e){var r;!t.hasState("is-loaded")&&t.setState("is-loading",!0),null===(r=t.hls)||void 0===r||r.startLoad(e)}class HLS{init(){}onload(t,e,r,i){m(r,t,i)}wants(t,r,i){return e.isSupported()&&l(r,i)}}return HLS.events=r,HLS.version=e.version,function(t,e){if("object"==typeof exports&&"undefined"!=typeof module)return e;"flowplayer"in t||(t.flowplayer={extensions:[]});const r=t.flowplayer;"function"==typeof r?r(e):(Array.isArray(r.extensions)||(r.extensions=[]),~r.extensions.indexOf(e)||r.extensions.push(e))}(window,HLS),HLS}));
|
package/plugins/ovp.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((t="undefined"!=typeof globalThis?globalThis:t||self).flowplayer=t.flowplayer||{},t.flowplayer.ovp=e())}(this,(function(){"use strict";const t=t=>"object"==typeof t&&null!==t&&!Array.isArray(t),e=(...n)=>n.reduce((n,o)=>t(o)?(Object.keys(o).forEach(i=>{if(t(n[i])&&t(o[i]))return n[i]=e(n[i],o[i]);n[i]=o[i]}),n):n,{});class Pipe{constructor(t){this.data=t}static of(t){return new Pipe(t)}static maybe(t,e,...n){return null==t?t:e.apply(t,[t,...n])}tap(t,...e){return t.apply(this,[this.data,...e]),new Pipe(this.data)}fmap(t,...e){const n=t.apply(this,[this.data,...e]);return new Pipe(n)}unwrap(){return this.data}}const n="https://ljsp.lwcdn.com".concat("/web/public/countdown/time.json"),o=window,i=o._flowplayerTimekeeper||(o._flowplayerTimekeeper={});function r(t){return fetch(t).then(t=>t.json())}function a(){let t=[].join.call(arguments,"/");return"/"!==t[0]&&(t="/"+t),s()+"/web/public/native/config"+t}const s=()=>"https://ljsp.lwcdn.com";function l(t){(async function(){const t=i.cachedServerOffset;if(t)return t;const e=i.pendingRequest||(i.pendingRequest=fetch(n)),o=await e,r=parseInt(o.headers.get("age")||"0"),a=await o.json(),s=Date.now()-a.millisUtc-1e3*r;return i.cachedServerOffset=s,i.cachedServerOffset})().then(e=>Object.assign(t,{server_time_offset:e}))}function c(t){return~t.indexOf("/")?t:"/media/"+t}var d={404:"media not found",402:"invalid subscription",400:"bad request",415:"unsupported media type"};function u(t){const e=t.ima,n=t.duration;if(!e||!n)return t;const o=null==e?void 0:e.ads;return Array.isArray(o)&&(e.ads=o.map((function(t){return"number"==typeof t.percentage&&(t.time=t.percentage*n),t}))),t}function p(t,n){var o,i;n="object"==typeof n?n:{};const r={title:null===(o=null==t?void 0:t.metadata)||void 0===o?void 0:o.title,description:null===(i=null==t?void 0:t.metadata)||void 0===i?void 0:i.description},a={ima:{parameters:function({media_id:t,duration:e,title:n,tags:o,category_name:i,ad_keywords:r}){return{ad_keywords:r||"",media_id:t||"",category:i||"",media_name:n||"",media_tags:o||"",media_duration:e||-1}}((null==t?void 0:t.metadata)||{})}},s=n.embed||{};return delete s.src,e(a,r,t,(delete(l=n).src,delete l.metadata,delete l.title,delete l.description,delete l.duration,delete l.poster,l),s);var l}const m=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/;function f(t){return"object"==typeof t&&"ovp/base64"==t.type}function v(t,e){return function(t,e){return!t.startsWith("blob:")&&(!(~t.indexOf(".")||!m.test(t))&&(e.type="video/ovp",!0))}(t,e)||f(e)}function y(t){try{return function(t){return null===t?{}:JSON.parse(t)}(decodeURIComponent(atob(t).split("").map((function(t){return"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2)})).join("")))}catch(t){return{err:t.message}}}function h(t){const e=t.split(/[^0-9]/).map(t=>parseInt(t,10));return Date.UTC(e[0],e[1]-1,e[2],e[3],e[4],e[5])}function w(t){return t.live}var _=Object.freeze({__proto__:null,OVP_ERROR:"ovp:error",OVP_MEDIA_REQUEST_START:"ovp:request:start",OVP_MEDIA_REQUEST_COMPLETE:"ovp:request:media:complete",OVP_PLAYLIST_REQUEST_COMPLETE:"ovp:request:playlist:complete",LIVE_COUNTDOWN_TICK:"ovp:live:countdown:tick",LIVE_COUNTDOWN_START:"ovp:live:countdown:start",LIVE_COUNTDOWN_COMPLETE:"ovp:live:countdown:complete",OVP_MEDIA_CHANGED:"ovp:media:changed",OVP_REALTIME_MESSAGE:"ovp:message:realtime"});function g(t,e){const n=null==e?void 0:e.src;if(f(e))return function(t,e){const n=y(e.src||"");if(function(t){return"string"==typeof t.err}(n))return console.error(n.err);b(t,n)}(t,e);n&&Pipe.of(n).fmap(c).fmap(a).fmap(t=>fetch(t)).fmap(e=>e.then(t=>Promise.all([t.status,t.json()])).then(([e,n])=>200==e?b(t,n):E(t,n)))}function b(t,n){return t.emit("ovp:media:changed",n),function(t){return Array.isArray(t.playlist)}(n)?function(t,n){if("function"!=typeof window.flowplayer.playlist)return console.warn("OVP responded with Playlist media but the playlist plugin does not exist"),E(t,{status:415});t.emit("ovp:request:playlist:complete",function(t,n){const o=Object.assign({},t),i=(null==t?void 0:t.playlist)||{},r=e(n,i),a=((null==r?void 0:r.playlist)||[]).map(t=>p(t,o));return Object.assign(r,{playlist:a})}(t.opts,n))}(t,n):w(n)?function(t,e){var n,o;const i=(null===(n=null==e?void 0:e.metadata)||void 0===n?void 0:n.live_start_time)||(null===(o=null==e?void 0:e.metadata)||void 0===o?void 0:o.starttime);i&&(e.live_start_time=Pipe.of(i).fmap(h).unwrap());t.emit("ovp:live:countdown:start",Pipe.of(e).fmap(p,t.opts).fmap(u).unwrap())}(t,n):function(t,e){t.emit("ovp:request:media:complete",Pipe.of(e).fmap(p,t.opts).fmap(u).unwrap())}(t,n)}function E(t,e){return e.message?t.emit("ovp:error",e):e.status?t.emit("ovp:error",new Error(d[e.status])):t.emit("ovp:error",e)}const O={};function P(t,e,n){"object"!=typeof O[e]&&(O[e]=n);const o=t.opts,i=(null==o?void 0:o.metadata)||{};i.player_id=e,o.metadata=i,n.title&&delete n.title,n.description&&delete n.description;const r=Object.assign(o,n);t.setOpts(r),n.autoplay&&t.togglePlay(!0)}let j=!1;function A(t,e,n){T()||Pipe.of("recommendation").fmap(a,e,n).fmap(r).fmap(e=>e.then(e=>function(t,e){const n=e.playlist;if(t.opts.recommendations=n,!n.length)return;t.emit("recommendationsready",{playlist:n.map((function(t){var e;return{poster:t.poster,src:t.src,title:null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.title,metadata:t.metadata||{}}}))})}(t,e)).catch(L))}function T(){return j}function L(t){j=!0,console.error("Failed to load recommendations: %j",t)}function C(t){const e="number"==typeof t?t:parseInt(t,10);return(e>9?"":"0")+e}function x(t,e){const n=t._customElements.get(e);return n&&t.root.querySelector(n)||void 0}const S="flowplayer-live-countdown";function M(t){return t&&t.live_start_time&&t.live_start_time-Date.now()>0}function D(t,e){let n=0;function o(){return function(t,e){const n=Date.now()-e;return Math.floor((t-n)/1e3)}(e.live_start_time||0,e.server_time_offset||0)}function i(){const i=o();if(i<0||isNaN(i)||0===t.reaper)return clearInterval(n),function(t,e){t.emit("ovp:live:countdown:complete");const n=x(t,S);n&&n.remove(),t.root.classList.remove("is-livecountdown"),t.emit("ovp:request:media:complete",e)}(t,e);var r,a,s;r=t,a=t.root,s=i,a.classList.add("is-livecountdown"),r.emit("ovp:live:countdown:tick",{remaining_time:I(s+1)}),r.hasState("is-starting")||r.setState("is-starting",!0)}l(e),i(),n=setInterval(i,250)}function I(t){const e=function(t){"number"!=typeof t&&(t=parseInt(t,10)),t=Math.round(t);const e=Math.floor(t/86400);t-=86400*e;const n=Math.floor(t/3600);t-=3600*n;const o=Math.floor(t/60);return{days:e,hours:n,minutes:o,seconds:t-=60*o}}(t);let n="";return e.days&&(n+=e.days+":"),n+C(e.hours)+":"+C(e.minutes)+":"+C(e.seconds)}class WebsocketBridge{constructor(t){this.manualDisconnect=!1,this.video=t,this.onClose=this.onClose.bind(this),this.onMessage=this.onMessage.bind(this)}static of(t){return new WebsocketBridge(t)}connect(t){this.client=new WebSocket("wss://player.ws.flowplayer.com?mediaId="+t),this.current_media_id=t,this.wireup()}onClose(){this.manualDisconnect?this.manualDisconnect=!1:this.current_media_id&&this.reconnect(this.current_media_id)}onMessage(t){JSON.parse(t.data).forEach(t=>{this.video.emit("ovp:message:realtime",t)})}reconnect(t){this.cleanup(),this.connect(t)}wireup(){this.client&&(this.client.addEventListener("message",this.onMessage),this.client.addEventListener("close",this.onClose))}cleanup(){this.client&&(this.client.removeEventListener("message",this.onMessage),this.client.removeEventListener("close",this.onClose),this.client=void 0)}disconnect(){this.client&&(this.manualDisconnect=!0,this.client.close())}}const k=(t,e)=>new(((t,e)=>{const n=t.get(e);if(!n)throw new Error(`no flowplayer component with the name ${e} exists`);const o=window.customElements.get(e);if(!o)throw new Error(`no default flowplayer component with the name ${e} exists`);const i=window.customElements.get(n);return"function"!=typeof i?o:i})(t._customElements,e))(t);class FlowplayerComponent extends HTMLElement{constructor(t){super(),this.player=t}}class FlowplayerLiveCountdown extends FlowplayerComponent{constructor(t){super(t),this.classList.add("fp-livecountdown");const e=function(...t){const e=document.createElement("div");return 0==t.length||e.classList.add(...t),e}("fp-inner");this.append(e);const n=document.createElement("p");n.innerText=t.i18n("ovp.starting_in"),e.append(n);const o=document.createElement("p");o.classList.add("fp-countdown"),e.append(o),t.on("ovp:live:countdown:tick",e=>{const n=e.detail.remaining_time;t.root.classList.add("is-livecountdown"),o.innerText=n})}}const q=["*.lwcdn.com","*.flowplayer.com"];function V(){try{return window.location.hostname!==window.parent.location.hostname?function(t){const e=document.createElement("a");return e.href=t,e}(document.referrer).hostname:document.location.hostname}catch(t){return window.location.hostname}}class OVP{constructor(t){((t,e,n)=>{window.customElements.get(e)||window.customElements.define(e,n),t.customElements.get(e)||t.customElements.set(e,e)})(t,S,FlowplayerLiveCountdown)}onload(t,e,n,o){if("string"==typeof o.src)return"string"!=typeof t.player_id||0===o.src.indexOf(t.player_id)||f(o)||(o.src=[t.player_id,o.src].join("/")),g(n,o)}wants(t,e,n){return v(t,e)}init(t,n,o){const i=new WebsocketBridge(o);let s=Object.assign({},t);const l=function(t){if(!s)return t;delete s.src;const n=e(t,s);return s=!1,n};o.on("ovp:error",(function(t){o.emit("error",t.data)})),o.on("ovp:request:start",(function(){o.setState("is-waiting",!0),t.recommendations&&(t.recommendations=!1)})),o.on("ovp:media:changed",(function({data:t}){var e;const n=null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.media_id;(null==t?void 0:t.live)&&n&&(i.disconnect(),i.connect(n))})),o.on("ovp:message:realtime",(function({data:e}){var n;const i=null==e?void 0:e.event,r=null==e?void 0:e.value,a=o.opt("metadata",{live_start_time:""});switch(i){case"METADATA":{const e=Object.assign(a,r),i=Object.assign(t,{metadata:e});i.live&&(null===(n=null==i?void 0:i.metadata)||void 0===n?void 0:n.live_start_time)&&(i.live_start_time=h(i.metadata.live_start_time)),o.setOpts(i);break}}})),o.on("beforeplay",(function(e){const n=t;if(w(n)){if(R(n))return;e.preventDefault()}})),o.on("ovp:request:media:complete",(function(t){const e=t.data;if(!e)return;if(0==o.reaper||"object"!=typeof t.data||M(t.data))return;const n=l(e);o.setOpts(n),o.setAttrs(n),n.src&&o.setSrc(n.src),n.autoplay&&o.togglePlay(!0)})),o.on("config",(function({data:e}){var i,s;if("string"==typeof t.src&&v(t.src,{}))return;if(t.src&&N(t.src))return;if((null==e?void 0:e.domains)&&(null==e?void 0:e.domains.length)&&!((t,e)=>{const n=t.split(".").reverse();return e.concat(q).some(t=>{const e=t.split(".").reverse(),o="*"===e[e.length-1];return o&&e.pop(),(o||e.length===n.length)&&e.every((t,e)=>n[e]===t)})})(V(),e.domains))return function({root:t,video:e,data:n}){e&&e.destroy(),console.error(new Error(n.details||n.reason)),t.innerHTML="",t.classList.remove("flowplayer"),t.classList.add("flowplayer-fatal"),t.style.removeProperty("background-image");const o=document.createElement("h2");o.textContent="Playback Error";const i=document.createElement("p");i.textContent="Are you the site owner?";const r=document.createElement("a");r.classList.add("troubleshoot"),r.target="_blank",r.href="https://docs.flowplayer.com/troubleshooting/player#"+n.reason,r.textContent="Troubleshoot?";const a=document.createElement("img");a.src="https://flowplayer.com/user/pages/images/logo-white.png",t.append(o,i,r,a)}({root:n,video:o,data:{details:`Hostname ${window.location.hostname} is not allowed to load player ${null===(i=e.metadata)||void 0===i?void 0:i.player_id}.`,reason:"domain"}});const l=null==e?void 0:e.brand_color;return l&&o.root.style.setProperty("--fp-brand-color","#"==l[0]?l:"#"+l),"string"==typeof t.player_id&&(null===(s=null==t?void 0:t.metadata)||void 0===s?void 0:s.player_id)!==t.player_id?function(t,e){if("object"==typeof O[e])return console.debug("using Cache(%s)",e),P(t,e,O[e]);Pipe.of(e).fmap(a).fmap(r).fmap(n=>n.then(n=>P(t,e,n)).catch(console.error))}(o,t.player_id):void 0})),o.on("ovp:request:playlist:complete",(function(t){const e=t.data;if(!e||0==o.reaper)return;const{playlist:n}=e,i=function(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(t);i<o.length;i++)e.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(t,o[i])&&(n[o[i]]=t[o[i]])}return n}(e,["playlist"]),r=l({playlist:i});Array.isArray(r.playlist)&&(r.playlist=i),o.setOpts(r);const a={type:"flowplayer/playlist",items:n};o.setSrc(a)})),o.on("ovp:live:countdown:start",(function(e){const i=e.data;if(!i||0==o.reaper)return;const r=l(i);if(o.setOpts(r),o.setAttrs(r),!M(i))return o.emit("ovp:request:media:complete",i);x(o,S)||(n.appendChild(k(o,S)),D(o,t))})),o.on("timeupdate",(function(){var e,n,i;const r=t;w(r)?R(r)||(o.togglePlay(!1),o.emit("ended")):t.recommendations&&(null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.media_id)&&(Array.isArray(t.recommendations)||o.currentTime/o.duration<.8||T()||(null===(n=null==t?void 0:t.metadata)||void 0===n?void 0:n.media_id)&&(null===(i=null==t?void 0:t.metadata)||void 0===i?void 0:i.player_id)&&A(o,t.metadata.media_id,t.metadata.player_id))})),o.on("reap",(function(){i.disconnect()}))}}function R(t){var e,n;const o=null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.live_stop_time;if(!o)return!0;return!!(null===(n=null==t?void 0:t.metadata)||void 0===n?void 0:n.allow_after_stop_time)||h(o)>Date.now()}OVP.events=_;const N=t=>{var e;if(t&&Array.isArray(t))return"object"==typeof t[0]&&"ovp/base64"===(null===(e=t[0])||void 0===e?void 0:e.type)};return function(t,e){if("object"==typeof exports&&"undefined"!=typeof module)return e;"flowplayer"in t||(t.flowplayer={extensions:[]});const n=t.flowplayer;"function"==typeof n?n(e):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(e)||n.extensions.push(e))}(window,OVP),OVP}));
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((t="undefined"!=typeof globalThis?globalThis:t||self).flowplayer=t.flowplayer||{},t.flowplayer.ovp=e())}(this,(function(){"use strict";const t=t=>"object"==typeof t&&null!==t&&!Array.isArray(t),e=(...n)=>n.reduce((n,o)=>t(o)?(Object.keys(o).forEach(i=>{if(t(n[i])&&t(o[i]))return n[i]=e(n[i],o[i]);n[i]=o[i]}),n):n,{});class Pipe{constructor(t){this.data=t}static of(t){return new Pipe(t)}static maybe(t,e,...n){return null==t?t:e.apply(t,[t,...n])}tap(t,...e){return t.apply(this,[this.data,...e]),new Pipe(this.data)}fmap(t,...e){const n=t.apply(this,[this.data,...e]);return new Pipe(n)}unwrap(){return this.data}}const n="https://ljsp.lwcdn.com".concat("/web/public/countdown/time.json"),o=window,i=o._flowplayerTimekeeper||(o._flowplayerTimekeeper={});function r(t){return fetch(t).then(t=>t.json())}function s(){let t=[].join.call(arguments,"/");return"/"!==t[0]&&(t="/"+t),a()+"/web/public/native/config"+t}const a=()=>"https://ljsp.lwcdn.com";function l(t){(async function(){const t=i.cachedServerOffset;if(t)return t;const e=i.pendingRequest||(i.pendingRequest=fetch(n)),o=await e,r=parseInt(o.headers.get("age")||"0"),s=await o.json(),a=Date.now()-s.millisUtc-1e3*r;return i.cachedServerOffset=a,i.cachedServerOffset})().then(e=>Object.assign(t,{server_time_offset:e}))}function c(t){return~t.indexOf("/")?t:"/media/"+t}var d={404:"media not found",402:"invalid subscription",400:"bad request",415:"unsupported media type"};function u(t){const e=t.ima,n=t.duration;if(!e||!n)return t;const o=null==e?void 0:e.ads;return Array.isArray(o)&&(e.ads=o.map((function(t){return"number"==typeof t.percentage&&(t.time=t.percentage*n),t}))),t}function p(t,n){var o,i;n="object"==typeof n?n:{};const r={title:null===(o=null==t?void 0:t.metadata)||void 0===o?void 0:o.title,description:null===(i=null==t?void 0:t.metadata)||void 0===i?void 0:i.description},s={ima:{parameters:function({media_id:t,duration:e,title:n,tags:o,category_name:i,ad_keywords:r}){return{ad_keywords:r||"",media_id:t||"",category:i||"",media_name:n||"",media_tags:o||"",media_duration:e||-1}}((null==t?void 0:t.metadata)||{})}},a=n.embed||{};return delete a.src,e(s,r,t,(delete(l=n).src,delete l.metadata,delete l.title,delete l.description,delete l.duration,delete l.poster,l),a);var l}const m=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/;function f(t){return"object"==typeof t&&"ovp/base64"==t.type}function v(t,e){return function(t,e){return!t.startsWith("blob:")&&(!(~t.indexOf(".")||!m.test(t))&&(e.type="video/ovp",!0))}(t,e)||f(e)}function y(t){try{return function(t){return null===t?{}:JSON.parse(t)}(decodeURIComponent(atob(t).split("").map((function(t){return"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2)})).join("")))}catch(t){return{err:t.message}}}function h(t){const e=t.split(/[^0-9]/).map(t=>parseInt(t,10));return Date.UTC(e[0],e[1]-1,e[2],e[3],e[4],e[5])}function w(t){return t.live}var _=Object.freeze({__proto__:null,OVP_ERROR:"ovp:error",OVP_MEDIA_REQUEST_START:"ovp:request:start",OVP_MEDIA_REQUEST_COMPLETE:"ovp:request:media:complete",OVP_PLAYLIST_REQUEST_COMPLETE:"ovp:request:playlist:complete",LIVE_COUNTDOWN_TICK:"ovp:live:countdown:tick",LIVE_COUNTDOWN_START:"ovp:live:countdown:start",LIVE_COUNTDOWN_COMPLETE:"ovp:live:countdown:complete",OVP_MEDIA_CHANGED:"ovp:media:changed",OVP_REALTIME_MESSAGE:"ovp:message:realtime"});function g(t,e){const n=null==e?void 0:e.src;if(f(e))return function(t,e){const n=y(e.src||"");if(function(t){return"string"==typeof t.err}(n))return console.error(n.err);b(t,n)}(t,e);n&&Pipe.of(n).fmap(c).fmap(s).fmap(t=>fetch(t)).fmap(e=>e.then(t=>Promise.all([t.status,t.json()])).then(([e,n])=>200==e?b(t,n):E(t,n)))}function b(t,n){return t.emit("ovp:media:changed",n),function(t){return Array.isArray(t.playlist)}(n)?function(t,n){if("function"!=typeof window.flowplayer.playlist)return console.warn("OVP responded with Playlist media but the playlist plugin does not exist"),E(t,{status:415});t.emit("ovp:request:playlist:complete",function(t,n){const o=Object.assign({},t),i=(null==t?void 0:t.playlist)||{},r=e(n,i),s=((null==r?void 0:r.playlist)||[]).map(t=>p(t,o));return Object.assign(r,{playlist:s})}(t.opts,n))}(t,n):w(n)?function(t,e){var n,o;const i=(null===(n=null==e?void 0:e.metadata)||void 0===n?void 0:n.live_start_time)||(null===(o=null==e?void 0:e.metadata)||void 0===o?void 0:o.starttime);i&&(e.live_start_time=Pipe.of(i).fmap(h).unwrap());t.emit("ovp:live:countdown:start",Pipe.of(e).fmap(p,t.opts).fmap(u).unwrap())}(t,n):function(t,e){t.emit("ovp:request:media:complete",Pipe.of(e).fmap(p,t.opts).fmap(u).unwrap())}(t,n)}function E(t,e){return e.message?t.emit("ovp:error",e):e.status?t.emit("ovp:error",new Error(d[e.status])):t.emit("ovp:error",e)}const O={};function P(t,e,n){"object"!=typeof O[e]&&(O[e]=n);const o=t.opts,i=(null==o?void 0:o.metadata)||{};i.player_id=e,o.metadata=i,n.title&&delete n.title,n.description&&delete n.description;const r=Object.assign(o,n);t.setOpts(r),n.autoplay&&t.togglePlay(!0)}let j=!1;function A(t,e,n){T()||Pipe.of("recommendation").fmap(s,e,n).fmap(r).fmap(e=>e.then(e=>function(t,e){const n=e.playlist;if(t.opts.recommendations=n,!n.length)return;t.emit("recommendationsready",{playlist:n.map((function(t){var e;return{poster:t.poster,src:t.src,title:null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.title,metadata:t.metadata||{}}}))})}(t,e)).catch(L))}function T(){return j}function L(t){j=!0,console.error("Failed to load recommendations: %j",t)}function C(t){const e="number"==typeof t?t:parseInt(t,10);return(e>9?"":"0")+e}function x(t,e){const n=t._customElements.get(e);return n&&t.root.querySelector(n)||void 0}const S="flowplayer-live-countdown";function M(t){const e=Date.now()-(t.server_time_offset||0);return Math.floor(((t.live_start_time||0)-e)/1e3)}function I(t,e){let n=0;function o(){const o=M(e);if(o<0||isNaN(o)||0===t.reaper)return clearInterval(n),function(t,e){t.emit("ovp:live:countdown:complete");const n=x(t,S);n&&n.remove(),t.root.classList.remove("is-livecountdown"),t.emit("ovp:request:media:complete",e)}(t,e);var i,r,s;i=t,r=t.root,s=o,r.classList.add("is-livecountdown"),i.emit("ovp:live:countdown:tick",{remaining_time:D(s+1)}),i.hasState("is-starting")||i.setState("is-starting",!0)}l(e),o(),n=setInterval(o,250)}function D(t){const e=function(t){"number"!=typeof t&&(t=parseInt(t,10)),t=Math.round(t);const e=Math.floor(t/86400);t-=86400*e;const n=Math.floor(t/3600);t-=3600*n;const o=Math.floor(t/60);return{days:e,hours:n,minutes:o,seconds:t-=60*o}}(t);let n="";return e.days&&(n+=e.days+":"),n+C(e.hours)+":"+C(e.minutes)+":"+C(e.seconds)}class WebsocketBridge{constructor(t){this.manualDisconnect=!1,this.video=t,this.onClose=this.onClose.bind(this),this.onMessage=this.onMessage.bind(this)}static of(t){return new WebsocketBridge(t)}connect(t){this.client=new WebSocket("wss://player.ws.flowplayer.com?mediaId="+t),this.current_media_id=t,this.wireup()}onClose(){this.manualDisconnect?this.manualDisconnect=!1:this.current_media_id&&this.reconnect(this.current_media_id)}onMessage(t){JSON.parse(t.data).forEach(t=>{this.video.emit("ovp:message:realtime",t)})}reconnect(t){this.cleanup(),this.connect(t)}wireup(){this.client&&(this.client.addEventListener("message",this.onMessage),this.client.addEventListener("close",this.onClose))}cleanup(){this.client&&(this.client.removeEventListener("message",this.onMessage),this.client.removeEventListener("close",this.onClose),this.client=void 0)}disconnect(){this.client&&(this.manualDisconnect=!0,this.client.close())}}const k=(t,e)=>new(((t,e)=>{const n=t.get(e);if(!n)throw new Error(`no flowplayer component with the name ${e} exists`);const o=window.customElements.get(e);if(!o)throw new Error(`no default flowplayer component with the name ${e} exists`);const i=window.customElements.get(n);return"function"!=typeof i?o:i})(t._customElements,e))(t);class FlowplayerComponent extends HTMLElement{constructor(t){super(),this.player=t}}class FlowplayerLiveCountdown extends FlowplayerComponent{constructor(t){super(t),this.classList.add("fp-livecountdown");const e=function(...t){const e=document.createElement("div");return 0==t.length||e.classList.add(...t),e}("fp-inner");this.append(e);const n=document.createElement("p");n.innerText=t.i18n("ovp.starting_in"),e.append(n);const o=document.createElement("p");o.classList.add("fp-countdown"),e.append(o),t.on("ovp:live:countdown:tick",e=>{const n=e.detail.remaining_time;t.root.classList.add("is-livecountdown"),o.innerText=n})}}const q=["*.lwcdn.com","*.flowplayer.com"];function V(){try{return window.location.hostname!==window.parent.location.hostname?function(t){const e=document.createElement("a");return e.href=t,e}(document.referrer).hostname:document.location.hostname}catch(t){return window.location.hostname}}class OVP{constructor(t){((t,e,n)=>{window.customElements.get(e)||window.customElements.define(e,n),t.customElements.get(e)||t.customElements.set(e,e)})(t,S,FlowplayerLiveCountdown)}onload(t,e,n,o){if("string"==typeof o.src)return"string"!=typeof t.player_id||0===o.src.indexOf(t.player_id)||f(o)||(o.src=[t.player_id,o.src].join("/")),g(n,o)}wants(t,e,n){return v(t,e)}init(t,n,o){const i=new WebsocketBridge(o);let a=Object.assign({},t);const l=function(t){if(!a)return t;delete a.src;const n=e(t,a);return a=!1,n};o.on("ovp:error",(function(t){o.emit("error",t.data)})),o.on("ovp:request:start",(function(){o.setState("is-waiting",!0),t.recommendations&&(t.recommendations=!1)})),o.on("ovp:media:changed",(function({data:t}){var e;const n=null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.media_id;(null==t?void 0:t.live)&&n&&(i.disconnect(),i.connect(n))})),o.on("ovp:message:realtime",(function({data:e}){var n;const i=null==e?void 0:e.event,r=null==e?void 0:e.value,s=o.opt("metadata",{live_start_time:""});switch(i){case"METADATA":{const e=Object.assign(s,r),i=Object.assign(t,{metadata:e});i.live&&(null===(n=null==i?void 0:i.metadata)||void 0===n?void 0:n.live_start_time)&&(i.live_start_time=h(i.metadata.live_start_time)),o.setOpts(i);break}}})),o.on("beforeplay",(function(e){const n=t;if(w(n)){if(R(n))return;e.preventDefault()}})),o.on("ovp:request:media:complete",(function(t){const e=t.data;if(!e)return;if(0==o.reaper||"object"!=typeof e||M(e)>0)return;const n=l(e);o.setOpts(n),o.setAttrs(n),n.src&&o.setSrc(n.src)})),o.on("config",(function({data:e}){var i,a;if("string"==typeof t.src&&v(t.src,{}))return;if(t.src&&N(t.src))return;if((null==e?void 0:e.domains)&&(null==e?void 0:e.domains.length)&&!((t,e)=>{const n=t.split(".").reverse();return e.concat(q).some(t=>{const e=t.split(".").reverse(),o="*"===e[e.length-1];return o&&e.pop(),(o||e.length===n.length)&&e.every((t,e)=>n[e]===t)})})(V(),e.domains))return function({root:t,video:e,data:n}){e&&e.destroy(),console.error(new Error(n.details||n.reason)),t.innerHTML="",t.classList.remove("flowplayer"),t.classList.add("flowplayer-fatal"),t.style.removeProperty("background-image");const o=document.createElement("h2");o.textContent="Playback Error";const i=document.createElement("p");i.textContent="Are you the site owner?";const r=document.createElement("a");r.classList.add("troubleshoot"),r.target="_blank",r.href="https://docs.flowplayer.com/troubleshooting/player#"+n.reason,r.textContent="Troubleshoot?";const s=document.createElement("img");s.src="https://flowplayer.com/user/pages/images/logo-white.png",t.append(o,i,r,s)}({root:n,video:o,data:{details:`Hostname ${window.location.hostname} is not allowed to load player ${null===(i=e.metadata)||void 0===i?void 0:i.player_id}.`,reason:"domain"}});const l=null==e?void 0:e.brand_color;return l&&o.root.style.setProperty("--fp-brand-color","#"==l[0]?l:"#"+l),"string"==typeof t.player_id&&(null===(a=null==t?void 0:t.metadata)||void 0===a?void 0:a.player_id)!==t.player_id?function(t,e){if("object"==typeof O[e])return console.debug("using Cache(%s)",e),P(t,e,O[e]);Pipe.of(e).fmap(s).fmap(r).fmap(n=>n.then(n=>P(t,e,n)).catch(console.error))}(o,t.player_id):void 0})),o.on("ovp:request:playlist:complete",(function(t){const e=t.data;if(!e||0==o.reaper)return;const{playlist:n}=e,i=function(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(t);i<o.length;i++)e.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(t,o[i])&&(n[o[i]]=t[o[i]])}return n}(e,["playlist"]),r=l({playlist:i});Array.isArray(r.playlist)&&(r.playlist=i),o.setOpts(r);const s={type:"flowplayer/playlist",items:n};o.setSrc(s)})),o.on("ovp:live:countdown:start",(function(e){const i=e.data;if(!i||0==o.reaper)return;const r=l(i);if(o.setOpts(r),o.setAttrs(r),M(i)<=0)return o.emit("ovp:request:media:complete",i);x(o,S)||(n.appendChild(k(o,S)),I(o,t))})),o.on("timeupdate",(function(){var e,n,i;const r=t;w(r)?R(r)||(o.togglePlay(!1),o.emit("ended")):t.recommendations&&(null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.media_id)&&(Array.isArray(t.recommendations)||o.currentTime/o.duration<.8||T()||(null===(n=null==t?void 0:t.metadata)||void 0===n?void 0:n.media_id)&&(null===(i=null==t?void 0:t.metadata)||void 0===i?void 0:i.player_id)&&A(o,t.metadata.media_id,t.metadata.player_id))})),o.on("reap",(function(){i.disconnect()}))}}function R(t){var e,n;const o=null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.live_stop_time;if(!o)return!0;return!!(null===(n=null==t?void 0:t.metadata)||void 0===n?void 0:n.allow_after_stop_time)||h(o)>Date.now()}OVP.events=_;const N=t=>{var e;if(t&&Array.isArray(t))return"object"==typeof t[0]&&"ovp/base64"===(null===(e=t[0])||void 0===e?void 0:e.type)};return function(t,e){if("object"==typeof exports&&"undefined"!=typeof module)return e;"flowplayer"in t||(t.flowplayer={extensions:[]});const n=t.flowplayer;"function"==typeof n?n(e):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(e)||n.extensions.push(e))}(window,OVP),OVP}));
|
package/plugins/playlist.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((t="undefined"!=typeof globalThis?globalThis:t||self).flowplayer=t.flowplayer||{},t.flowplayer.playlist=e())}(this,(function(){"use strict";var t={PLAYLIST_NEXT:"playlist:next",PLAYLIST_PREVIOUS:"playlist:previous",PLAYLIST_SELECTION:"playlist:selection",PLAYLIST_LOOP:"playlist:loop",PLAYLIST_ENDED:"playlist:ended",PLAYLIST_READY:"playlist:ready",PLAYLIST_ADD:"playlist:add",PLAYLIST_REMOVE:"playlist:remove",INTERSTITIAL_END:"interstitial/end",INTERSTITIAL_CANCEL:"interstitial/cancel",INTERSTITIAL_NEXT_ITEM:"interstitial/next_item"};const e={translation_key:"core.skip-next",name:"fp-skip-next"},n={translation_key:"core.skip-prev",name:"fp-skip-prev"};class Pipe{constructor(t){this.data=t}static of(t){return new Pipe(t)}static maybe(t,e,...n){return null==t?t:e.apply(t,[t,...n])}tap(t,...e){return t.apply(this,[this.data,...e]),new Pipe(this.data)}fmap(t,...e){const n=t.apply(this,[this.data,...e]);return new Pipe(n)}unwrap(){return this.data}}function i(t,e){if(!e)throw new Error(t)}function s(t){return"invalid playlist configuration\ndetails: "+t+"\n\tmust match Object of shape:\n"+["\t\t{ controls?: Selector|HTMLElement","player: Selector|HTMLElement","playlist: PlaylistId|Array(MediaId|PlayerConfig)","shuffle?: Boolean|false","loop?: Boolean|false","advance?: Boolean|true","delay?: Milliseconds|5000"].join("\n\t\t, ")+"\n\t\t}"}function o(t,e){Pipe.of(t).fmap(s).fmap(i,e)}function l(t){return void 0!==t}function r(t){return"string"==typeof t}function a(t){return"object"==typeof t}function c(t){return t instanceof HTMLElement}function u(t){var e;o("Config must be an Object",l(t)&&a(t)),o("property `playlist` is required",l(t.playlist)),o("property `playlist` was not a String(MediaId)",r(t.playlist)||(e=t.playlist,o("playlist property was not of type PlaylistId|Array(MediaId|PlayConfig)",Array.isArray(e)),o("playlist property cannot be an empty Array",e.length>0),!e.forEach((function(t,e){o("item at playlist["+e+"] was not valid",r(t)||a(t))})))),"loop shuffle".split(" ").forEach((function(e){l(t[e])&&o(e+" must be a boolean value if present","boolean"==typeof t[e])})),l(t.delay)&&o("property `delay` must be a Number (Milliseconds)","number"==typeof t.delay)}function p(t){try{u(t)}catch(t){return!1}return!0}class FlowplayerComponent extends HTMLElement{constructor(t){super(),this.player=t}}class FlowplayerIcon extends FlowplayerComponent{constructor(t,e){super(t),this.classList.add("fp-icon",e.name),e.title&&this.setAttribute("title",e.title),e.title&&this.setAttribute("aria-label",e.title),this.setAttribute("tabindex","0"),this.setAttribute("focusable","true")}}const d=["title","delay","description","poster","src"];class UpNext extends FlowplayerComponent{static get observedAttributes(){return d}constructor(e){super(e),this.classList.add("up-next"),this.addEventListener("animationend",()=>{this.dispatchEvent(new CustomEvent(t.INTERSTITIAL_END))}),this.addEventListener("animationcancel",()=>{this.classList.add("cancelled"),this.dispatchEvent(new CustomEvent(t.INTERSTITIAL_CANCEL))}),this.addEventListener(t.INTERSTITIAL_NEXT_ITEM,this._setUpNext.bind(this))}getTitle(){return this.getAttribute("title")||""}getDescription(){return this.getAttribute("description")||""}getPoster(){return this.getAttribute("poster")||""}getDelay(){return this.getAttribute("delay")||""}connectedCallback(){this.isConnected&&this._render()}attributeChangedCallback(){this._render()}_render(){var e,n;this.innerHTML="",this.classList.remove("cancelled");const i=document.createDocumentFragment(),s=document.createElement("div");s.classList.add("pane","left");const o=document.createElement("div");o.classList.add("pane","right"),i.append(s,o);const l=document.createElement("div");l.classList.add("poster"),l.style.backgroundImage="url("+this.getPoster()+")",s.append(l),l.addEventListener("click",()=>this.dispatchEvent(new CustomEvent(t.INTERSTITIAL_END)));const r=document.createElement("span");r.classList.add("fp-icon","fp-play"),l.append(r);const a=document.createElement("span");a.classList.add("title"),a.textContent=this.getTitle();const c=document.createElement("span");c.classList.add("description"),c.textContent=this.getDescription();const u=document.createElement("span");u.classList.add("countdown"),this.getDelay()&&(u.style.setProperty("--up-next-delay",this.getDelay()+"s"),u.classList.add("go"));const p=document.createElement("span");p.classList.add("cancel"),p.textContent=null!==(n=null===(e=this.player)||void 0===e?void 0:e.i18n("playlist.cancel"))&&void 0!==n?n:"cancel",p.addEventListener("click",()=>u.classList.remove("go")),o.append(a,c,p,u),this.append(i)}_setUpNext(t){var e,n,i;const s=t.detail.next,o=this.player.opt("playlist.delay",void 0)||10;this.setAttribute("title",null!==(e=s.title)&&void 0!==e?e:""),this.setAttribute("description",null!==(n=s.description)&&void 0!==n?n:""),this.setAttribute("poster",null!==(i=s.poster)&&void 0!==i?i:""),this.setAttribute("delay",o+"")}}const y=(t,e)=>new(((t,e)=>{const n=t.get(e);if(!n)throw new Error(`no flowplayer component with the name ${e} exists`);const i=window.customElements.get(e);if(!i)throw new Error(`no default flowplayer component with the name ${e} exists`);const s=window.customElements.get(n);return"function"!=typeof s?i:s})(t._customElements,e))(t),f=(t,e,n)=>{window.customElements.get(e)||window.customElements.define(e,n),t.customElements.get(e)||t.customElements.set(e,e)};function m(t,e){const n=t._customElements.get(e);return n&&t.root.querySelector(n)||void 0}function h(t,e,n){return t.setAttribute(e,n),t}function v(t,e){return t.classList.add(...e.split(" ")),t}function L(t,e,n){return e.split(" ").forEach(e=>t.classList.toggle(e,n)),t}function E(...t){const e=document.createElement("div");return 0==t.length||e.classList.add(...t),e}function w(t,e,n){const i=function(t){return Array.isArray(t)?t.slice(0):t.split(".")}(e);for(;i.length;){if(null==t)return n;const e=i.shift();if("string"!=typeof e)return n;t=t[e]}return null==t?n:t}function x(t,e){if(!e[t])return;const n=document.createElement("span");n.innerText=e[t];const i=E(t);return i.append(n),i}class FlowplayerPlaylistControls extends FlowplayerComponent{constructor(e){super(e),e.on(t.PLAYLIST_READY,t=>{const n=w(t,"data.queue",w(e,"playlist.queue"));n&&this.list(n,e)}),e.on(t.PLAYLIST_NEXT,()=>{var t;(null===(t=e.playlist)||void 0===t?void 0:t.queue)&&Array.from(this.querySelectorAll("li")).forEach((t,n)=>{var i;n===(null===(i=e.playlist)||void 0===i?void 0:i.queue.idx)?t.className="is-current":t.className="is-queued"})}),e.on(["playing","pause"],t=>{const e=this.querySelector(".is-current");e&&(e.classList.toggle("is-playing","playing"===t.type),e.classList.toggle("is-paused","flowplayer-pause-icon"===t.type))}),e.on(t.PLAYLIST_ADD,t=>{var n;const i=null===(n=e.playlist)||void 0===n?void 0:n.queue;if(!t.data||!i)return;t.data.members.forEach(t=>{const n=this.videoRow(t,e);n&&this.append(n)})}),e.on(t.PLAYLIST_REMOVE,t=>{if(!t.data)return;const e=Array.from(this.querySelectorAll("li"))[t.data.index];e&&this.removeChild(e)})}list(t,e){this.innerHTML="",v(this,"fp-playlist"),t.members.forEach(t=>{const n=this.videoRow(t,e);n&&this.append(n)})}videoRow(t,e){if(!t.title)return;const n=document.createElement("li");var i,s;return n.classList.add("is-queued"),n.onclick=this.videoRow_onclick.bind(this,n,t,e),i=n,s=[E("fp-color"),this.videoInfo(t),this.buttons(t,e)],i.append(...s),n}videoRow_onclick(t,e,n){var i;if(t.classList.contains("is-current"))return n.togglePlay(!n.playerState["is-playing"]);const s=Array.from(this.querySelectorAll("li")).indexOf(t);-1!==s&&(null===(i=n.playlist)||void 0===i||i.play(s))}videoInfo(t){const e=E("video-info"),n=x("title",t);n&&e.append(n);const i=x("description",t);return i&&e.append(i),e}buttons(t,e){const n=E("video-buttons"),i=y(e,"flowplayer-play-icon"),s=y(e,"flowplayer-pause-icon");return n.append(i,s),t.poster&&(n.style.backgroundImage=["url(",t.poster,")"].join("")),n}}var b;function g(t,e){var n,i;const s=e.sort||I,o=null!==(n=e.mode)&&void 0!==n?n:b.FIFO;return t=s(t.slice(0),o),{mode:o,sort:s,members:t,last_idx:t.length-1,plays:null!==(i=e.plays)&&void 0!==i?i:0,idx:-1}}function A(t){return t.idx==t.last_idx}function I(t,e){return(e&b.SHUFFLE)==b.SHUFFLE?t.sort((function(){return Math.random()-Math.random()})):t.slice(0)}function T(t){return g(t.members,{mode:t.mode,plays:t.plays+1,sort:t.sort})}!function(t){t[t.SHUFFLE=1]="SHUFFLE",t[t.FIFO=2]="FIFO",t[t.LOOP=4]="LOOP"}(b||(b={}));!function(){let t=!1;try{const e=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("testPassive",null,e),window.removeEventListener("testPassive",null,e)}catch(t){}}();const _=["touchstart","touchmove"];function P(t,e,n){const i=function(t,e){const n=new CustomEvent(t,{detail:e,cancelable:!0});return e&&Object.defineProperty(n,"data",{get:()=>e}),n}(e,n);return t.dispatchEvent(i),t}function S(t,e,n,i){Array.isArray(e)?e.forEach(e=>q(t,e,n,i)):q(t,e,n,i)}function q(t,e,n,i){if(s=e,!~_.indexOf(s))return t.addEventListener(e,n,i),t;var s;const o=Object.assign(i||{},{passive:!0});return t.addEventListener(e,n,o),t}function O(e,n,i){const s=n.idx+n.plays<0;return function(t,e,n){"object"==typeof e&&t.setOpts(Object.assign(Object.assign({},e),{playlist:n}));N(t,{should_play:n.should_play})}(e,function(t,e,n){return t.idx=e&&"number"==typeof n&&n>=0&&n<=t.last_idx?n:t.idx+1,t.members[t.idx]}(n,s,i.start_index),i),s&&i.autoplay?e.togglePlay(!0):s?e.setState("is-starting",!0):i.delay?void function(e,n){var i;const s=m(e,"flowplayer-playlist-interstitial");if(!s||!(null===(i=e.playlist)||void 0===i?void 0:i.queue)||!n.delay)return;e.root.classList.add("is-interstitial");const o=function(t){return-1==t.idx?t.members[0]:t.members[t.idx]}(e.playlist.queue);P(s,t.INTERSTITIAL_NEXT_ITEM,{next:o})}(e,i):e.togglePlay(!0)}function N(e,n){var i,s;const o=null===(i=e.playlist)||void 0===i?void 0:i.queue;if(!o)return;const l=o.idx,r=o.members[l];return r.src&&e.setSrc(r.src),e.emit(t.PLAYLIST_NEXT,{next_index:l}),null!==(s=n.should_play)&&void 0!==s&&s?e.togglePlay(!0):void 0}function C(e,n){return{queue:n,events:t,play:function(t){t<0||t>=n.members.length||(this.queue.idx=t,N(e,{should_play:!0}))},next:function(){this.queue.idx!==this.queue.last_idx&&this.play(this.queue.idx+1)},prev:function(){this.queue.idx&&this.play(this.queue.idx-1)},remove:function(n){const i=this.queue;return i.members[n]?i.idx===n?console.warn("operation failed: you cannot remove current playlist item"):(i.members.splice(n,1),i.last_idx=i.members.length-1,n<i.idx&&--i.idx,void e.emit(t.PLAYLIST_REMOVE,{index:n})):console.warn("there is no playlist item at this index")},push:function(...n){const i=e.root;if(0==this.queue.idx&&i.classList.contains("is-interstitial"))return console.warn("new items cannot be added when playlist has ended.");const s=this.queue.members;s.push(...n),this.queue.last_idx=s.length-1,e.emit(t.PLAYLIST_ADD,{members:n})},clear:function(){this.queue.members=[],this.queue.plays--,function(e,n){e.playlist&&(n=e.playlist.queue=T(n),e.emit(t.PLAYLIST_READY,{queue:n,should_play:!1}))}(e,this.queue)}}}function k(e){const n=y(e,"flowplayer-skip-previous-icon");h(n,"role","button"),S(n,"click",(function(){e.playlist&&e.playlist.prev()}));const i=y(e,"flowplayer-skip-next-icon");h(i,"role","button"),S(i,"click",(function(){e.playlist&&e.playlist.next()}));const s=E("fp-playlist-prev-preview"),o=E("fp-playlist-next-preview"),l=m(e,"flowplayer-control-buttons");return l&&(l.prepend(n),l.append(i),l.append(s),l.append(o)),e.on("reap",(function(){e.skip_controls=void 0})),e.on([t.PLAYLIST_NEXT,t.PLAYLIST_ADD,t.PLAYLIST_REMOVE],(function(t){const n=w(t,"data.queue",w(e,"playlist.queue"));if(!n||!l||!e.skip_controls)return;L(l,"is-prev-button-disabled",!n.idx),L(l,"is-next-button-disabled",n.idx===n.last_idx);const i=n.idx<n.last_idx?function(t){if(!A(t)||0!=(t.mode&b.LOOP))return t.members[function(t){const e=t.idx+1;return e>t.last_idx?0:e}(t)]}(n):null,r=n.idx>0?function(t){if(0!==t.idx||0!=(t.mode&b.LOOP))return t.members[function(t){const e=t.idx-1;return e<0?t.last_idx:e}(t)]}(n):null;o.style.backgroundImage=["url(",i?i.poster:null,")"].join(""),s.style.backgroundImage=["url(",r?r.poster:null,")"].join("")})),{prevButton:n,nextButton:i,prevPreview:s,nextPreview:o}}function F(t,e){if(!e)return;e.skip_controls&&(t.skip_controls=k(t));const n=function(t){let e=null;if(n=t.controls,!r(n)&&!c(n))return;var n;c(t.controls)?e=t.controls:r(t.controls)&&(e=document.querySelector(t.controls));return i("Could not find controls by Selector["+t.controls+"]",c(e)),e}(e);if(!n)return;const s=y(t,"flowplayer-playlist-controls");if(n.append(s),!(s instanceof FlowplayerPlaylistControls))return;v(n,"fp-playlist-controls "+(t.opt("playlist",{}).theme||"fp-dark"));const o=t.root.className.split(" ").filter((function(t){return t.match(/^use-play/)})).pop();o&&v(n,o)}function Y(t,e,n){if(Array.isArray(e))return n(function(t,e){let n=e.shuffle?b.SHUFFLE:b.FIFO;return e.loop&&(n|=b.LOOP),g(t,{mode:n,sort:e.sort})}(e,t));throw new Error("config.playlist must be an Array")}function D(e){var n;e.on(t.PLAYLIST_READY,(function(t){var n,i;const s=e.opt("playlist",{}),o=null===(n=t.detail)||void 0===n?void 0:n.queue,l=null===(i=t.detail)||void 0===i?void 0:i.should_play;o&&s&&(e.playlist=C(e,o),l&&O(e,o,s))})),e.on("ended",(n=n=>{if(n.prevented_from_ads)return;const i=e.opt("playlist");return e.playlist&&i?A(e.playlist.queue)?function(e,n){if(e.emit(t.PLAYLIST_ENDED),!n.loop)return;if(!e.playlist)return;const i=e.playlist.queue=T(e.playlist.queue);e.emit(t.PLAYLIST_LOOP),O(e,i,n)}(e,i):void(i.advance&&O(e,e.playlist.queue,i)):void 0},t=>{setTimeout((function(){if(!t.defaultPrevented)return n(t)}),0)})),e.on(["playing","waiting","seeking"],(function(){if(!e.root.classList.contains("is-interstitial"))return;const n=m(e,"flowplayer-playlist-interstitial");n&&P(n,t.INTERSTITIAL_CANCEL)}))}class Playlist{constructor(t){f(t,"flowplayer-playlist-controls",FlowplayerPlaylistControls),f(t,"flowplayer-playlist-interstitial",class extends UpNext{constructor(t){super(t),this.classList.add("fp-interstitial")}}),f(t,"flowplayer-skip-next-icon",class extends FlowplayerIcon{constructor(t){super(t,e)}}),f(t,"flowplayer-skip-previous-icon",class extends FlowplayerIcon{constructor(t){super(t,n)}})}init(e,n,i){const s=e.playlist||{};s.delay="number"==typeof s.delay?s.delay:0,i.setOpts(Object.assign(Object.assign({},e),{playlist:s})),F(i,e.playlist),function(e){var n;const i=y(e,"flowplayer-playlist-interstitial");i.addEventListener(t.INTERSTITIAL_CANCEL,()=>e.root.classList.remove("is-interstitial")),i.addEventListener(t.INTERSTITIAL_END,()=>{e.root.classList.remove("is-interstitial"),e.togglePlay(!0)}),null===(n=m(e,"flowplayer-ui"))||void 0===n||n.prepend(i)}(i),D(i)}onload(e,n,i,s){Y(e.playlist||{},s.items,(function(e){i.setState("is-playlist",!0),i.emit(t.PLAYLIST_READY,{queue:e,should_play:0===i.currentSrc.length})}))}wants(t,e,n){return"flowplayer/playlist"==e.type&&!!e.items&&p(Object.assign(Object.assign({},n),{playlist:e.items}))}}return Playlist.events=t,function(t,e){if("object"==typeof exports&&"undefined"!=typeof module)return e;"flowplayer"in t||(t.flowplayer={extensions:[]});const n=t.flowplayer;"function"==typeof n?n(e):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(e)||n.extensions.push(e))}(window,Playlist),Playlist}));
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((t="undefined"!=typeof globalThis?globalThis:t||self).flowplayer=t.flowplayer||{},t.flowplayer.playlist=e())}(this,(function(){"use strict";var t={PLAYLIST_NEXT:"playlist:next",PLAYLIST_PREVIOUS:"playlist:previous",PLAYLIST_SELECTION:"playlist:selection",PLAYLIST_LOOP:"playlist:loop",PLAYLIST_ENDED:"playlist:ended",PLAYLIST_READY:"playlist:ready",PLAYLIST_ADD:"playlist:add",PLAYLIST_REMOVE:"playlist:remove",INTERSTITIAL_END:"interstitial/end",INTERSTITIAL_CANCEL:"interstitial/cancel",INTERSTITIAL_NEXT_ITEM:"interstitial/next_item"};const e={translation_key:"core.skip-next",name:"fp-skip-next"},n={translation_key:"core.skip-prev",name:"fp-skip-prev"};class Pipe{constructor(t){this.data=t}static of(t){return new Pipe(t)}static maybe(t,e,...n){return null==t?t:e.apply(t,[t,...n])}tap(t,...e){return t.apply(this,[this.data,...e]),new Pipe(this.data)}fmap(t,...e){const n=t.apply(this,[this.data,...e]);return new Pipe(n)}unwrap(){return this.data}}function i(t,e){if(!e)throw new Error(t)}function s(t){return"invalid playlist configuration\ndetails: "+t+"\n\tmust match Object of shape:\n"+["\t\t{ controls?: Selector|HTMLElement","player: Selector|HTMLElement","playlist: PlaylistId|Array(MediaId|PlayerConfig)","shuffle?: Boolean|false","loop?: Boolean|false","advance?: Boolean|true","delay?: Milliseconds|5000"].join("\n\t\t, ")+"\n\t\t}"}function o(t,e){Pipe.of(t).fmap(s).fmap(i,e)}function l(t){return void 0!==t}function r(t){return"string"==typeof t}function a(t){return"object"==typeof t}function c(t){return t instanceof HTMLElement}function u(t){var e;o("Config must be an Object",l(t)&&a(t)),o("property `playlist` is required",l(t.playlist)),o("property `playlist` was not a String(MediaId)",r(t.playlist)||(e=t.playlist,o("playlist property was not of type PlaylistId|Array(MediaId|PlayConfig)",Array.isArray(e)),o("playlist property cannot be an empty Array",e.length>0),!e.forEach((function(t,e){o("item at playlist["+e+"] was not valid",r(t)||a(t))})))),"loop shuffle".split(" ").forEach((function(e){l(t[e])&&o(e+" must be a boolean value if present","boolean"==typeof t[e])})),l(t.delay)&&o("property `delay` must be a Number (Milliseconds)","number"==typeof t.delay)}function p(t){try{u(t)}catch(t){return!1}return!0}class FlowplayerComponent extends HTMLElement{constructor(t){super(),this.player=t}}class FlowplayerIcon extends FlowplayerComponent{constructor(t,e){super(t),this.classList.add("fp-icon",e.name),e.title&&this.setAttribute("title",e.title),e.title&&this.setAttribute("aria-label",e.title),this.setAttribute("tabindex","0"),this.setAttribute("focusable","true")}}const d=["title","delay","description","poster","src"];class UpNext extends FlowplayerComponent{static get observedAttributes(){return d}constructor(e){super(e),this.classList.add("up-next"),this.addEventListener("animationend",()=>{this.dispatchEvent(new CustomEvent(t.INTERSTITIAL_END))}),this.addEventListener("animationcancel",()=>{this.classList.add("cancelled"),this.dispatchEvent(new CustomEvent(t.INTERSTITIAL_CANCEL))}),this.addEventListener(t.INTERSTITIAL_NEXT_ITEM,this._setUpNext.bind(this))}getTitle(){return this.getAttribute("title")||""}getDescription(){return this.getAttribute("description")||""}getPoster(){return this.getAttribute("poster")||""}getDelay(){return this.getAttribute("delay")||""}connectedCallback(){this.isConnected&&this._render()}attributeChangedCallback(){this._render()}_render(){var e,n;this.innerHTML="",this.classList.remove("cancelled");const i=document.createDocumentFragment(),s=document.createElement("div");s.classList.add("pane","left");const o=document.createElement("div");o.classList.add("pane","right"),i.append(s,o);const l=document.createElement("div");l.classList.add("poster"),l.style.backgroundImage="url("+this.getPoster()+")",s.append(l),l.addEventListener("click",()=>this.dispatchEvent(new CustomEvent(t.INTERSTITIAL_END)));const r=document.createElement("span");r.classList.add("fp-icon","fp-play"),l.append(r);const a=document.createElement("span");a.classList.add("title"),a.textContent=this.getTitle();const c=document.createElement("span");c.classList.add("description"),c.textContent=this.getDescription();const u=document.createElement("span");u.classList.add("countdown"),this.getDelay()&&(u.style.setProperty("--up-next-delay",this.getDelay()+"s"),u.classList.add("go"));const p=document.createElement("span");p.classList.add("cancel"),p.textContent=null!==(n=null===(e=this.player)||void 0===e?void 0:e.i18n("playlist.cancel"))&&void 0!==n?n:"cancel",p.addEventListener("click",()=>u.classList.remove("go")),o.append(a,c,p,u),this.append(i)}_setUpNext(t){var e,n,i;const s=t.detail.next,o=this.player.opt("playlist.delay",void 0)||10;this.setAttribute("title",null!==(e=s.title)&&void 0!==e?e:""),this.setAttribute("description",null!==(n=s.description)&&void 0!==n?n:""),this.setAttribute("poster",null!==(i=s.poster)&&void 0!==i?i:""),this.setAttribute("delay",o+"")}}const y=(t,e)=>new(((t,e)=>{const n=t.get(e);if(!n)throw new Error(`no flowplayer component with the name ${e} exists`);const i=window.customElements.get(e);if(!i)throw new Error(`no default flowplayer component with the name ${e} exists`);const s=window.customElements.get(n);return"function"!=typeof s?i:s})(t._customElements,e))(t),f=(t,e,n)=>{window.customElements.get(e)||window.customElements.define(e,n),t.customElements.get(e)||t.customElements.set(e,e)};function m(t,e){const n=t._customElements.get(e);return n&&t.root.querySelector(n)||void 0}function h(t,e,n){return t.setAttribute(e,n),t}function v(t,e){return t.classList.add(...e.split(" ")),t}function L(t,e,n){return e.split(" ").forEach(e=>t.classList.toggle(e,n)),t}function E(...t){const e=document.createElement("div");return 0==t.length||e.classList.add(...t),e}function w(t,e,n){const i=function(t){return Array.isArray(t)?t.slice(0):t.split(".")}(e);for(;i.length;){if(null==t)return n;const e=i.shift();if("string"!=typeof e)return n;t=t[e]}return null==t?n:t}function x(t,e){if(!e[t])return;const n=document.createElement("span");n.innerText=e[t];const i=E(t);return i.append(n),i}class FlowplayerPlaylistControls extends FlowplayerComponent{constructor(e){super(e),e.on(t.PLAYLIST_READY,t=>{const n=w(t,"data.queue",w(e,"playlist.queue"));n&&this.list(n,e)}),e.on(t.PLAYLIST_NEXT,()=>{var t;(null===(t=e.playlist)||void 0===t?void 0:t.queue)&&Array.from(this.querySelectorAll("li")).forEach((t,n)=>{var i;n===(null===(i=e.playlist)||void 0===i?void 0:i.queue.idx)?t.className="is-current":t.className="is-queued"})}),e.on(["playing","pause"],t=>{const e=this.querySelector(".is-current");e&&(e.classList.toggle("is-playing","playing"===t.type),e.classList.toggle("is-paused","flowplayer-pause-icon"===t.type))}),e.on(t.PLAYLIST_ADD,t=>{var n;const i=null===(n=e.playlist)||void 0===n?void 0:n.queue;if(!t.data||!i)return;t.data.members.forEach(t=>{const n=this.videoRow(t,e);n&&this.append(n)})}),e.on(t.PLAYLIST_REMOVE,t=>{if(!t.data)return;const e=Array.from(this.querySelectorAll("li"))[t.data.index];e&&this.removeChild(e)})}list(t,e){this.innerHTML="",v(this,"fp-playlist"),t.members.forEach(t=>{const n=this.videoRow(t,e);n&&this.append(n)})}videoRow(t,e){if(!t.title)return;const n=document.createElement("li");var i,s;return n.classList.add("is-queued"),n.onclick=this.videoRow_onclick.bind(this,n,t,e),i=n,s=[E("fp-color"),this.videoInfo(t),this.buttons(t,e)],i.append(...s),n}videoRow_onclick(t,e,n){var i;if(t.classList.contains("is-current"))return n.togglePlay(!n.playerState["is-playing"]);const s=Array.from(this.querySelectorAll("li")).indexOf(t);-1!==s&&(null===(i=n.playlist)||void 0===i||i.play(s))}videoInfo(t){const e=E("video-info"),n=x("title",t);n&&e.append(n);const i=x("description",t);return i&&e.append(i),e}buttons(t,e){const n=E("video-buttons"),i=y(e,"flowplayer-play-icon"),s=y(e,"flowplayer-pause-icon");return n.append(i,s),t.poster&&(n.style.backgroundImage=["url(",t.poster,")"].join("")),n}}var b;function g(t,e){var n,i;const s=e.sort||I,o=null!==(n=e.mode)&&void 0!==n?n:b.FIFO;return t=s(t.slice(0),o),{mode:o,sort:s,members:t,last_idx:t.length-1,plays:null!==(i=e.plays)&&void 0!==i?i:0,idx:-1}}function A(t){return t.idx==t.last_idx}function I(t,e){return(e&b.SHUFFLE)==b.SHUFFLE?t.sort((function(){return Math.random()-Math.random()})):t.slice(0)}function T(t){return g(t.members,{mode:t.mode,plays:t.plays+1,sort:t.sort})}!function(t){t[t.SHUFFLE=1]="SHUFFLE",t[t.FIFO=2]="FIFO",t[t.LOOP=4]="LOOP"}(b||(b={}));!function(){let t=!1;try{const e=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("testPassive",null,e),window.removeEventListener("testPassive",null,e)}catch(t){}}();const _=["touchstart","touchmove"];function P(t,e,n){const i=function(t,e){const n=new CustomEvent(t,{detail:e,cancelable:!0});return e&&Object.defineProperty(n,"data",{get:()=>e}),n}(e,n);return t.dispatchEvent(i),t}function S(t,e,n,i){Array.isArray(e)?e.forEach(e=>q(t,e,n,i)):q(t,e,n,i)}function q(t,e,n,i){if(s=e,!~_.indexOf(s))return t.addEventListener(e,n,i),t;var s;const o=Object.assign(i||{},{passive:!0});return t.addEventListener(e,n,o),t}function O(e,n,i){const s=n.idx+n.plays<0;return N(e,function(t,e,n){return t.idx=e&&"number"==typeof n&&n>=0&&n<=t.last_idx?n:t.idx+1,t.members[t.idx]}(n,s,i.start_index),i),s&&i.autoplay?e.togglePlay(!0):s?e.setState("is-starting",!0):i.delay?void function(e,n){var i;const s=m(e,"flowplayer-playlist-interstitial");if(!s||!(null===(i=e.playlist)||void 0===i?void 0:i.queue)||!n.delay)return;e.root.classList.add("is-interstitial");const o=function(t){return-1==t.idx?t.members[0]:t.members[t.idx]}(e.playlist.queue);P(s,t.INTERSTITIAL_NEXT_ITEM,{next:o})}(e,i):e.togglePlay(!0)}function N(e,n,i){"object"==typeof n&&e.setOpts(n),function(e,n){var i,s;const o=null===(i=e.playlist)||void 0===i?void 0:i.queue;if(!o)return;const l=o.idx,r=o.members[l];if(r.src&&e.setSrc(r.src),e.emit(t.PLAYLIST_NEXT,{next_index:l}),null!==(s=n.should_play)&&void 0!==s&&s)e.togglePlay(!0)}(e,{should_play:i.should_play})}function C(e,n){return{queue:n,events:t,play:function(t){t<0||t>=n.members.length||(this.queue.idx=t,N(e,n.members[t],Object.assign({should_play:!0},e.opt("playlist"))))},next:function(){this.queue.idx!==this.queue.last_idx&&this.play(this.queue.idx+1)},prev:function(){this.queue.idx&&this.play(this.queue.idx-1)},remove:function(n){const i=this.queue;return i.members[n]?i.idx===n?console.warn("operation failed: you cannot remove current playlist item"):(i.members.splice(n,1),i.last_idx=i.members.length-1,n<i.idx&&--i.idx,void e.emit(t.PLAYLIST_REMOVE,{index:n})):console.warn("there is no playlist item at this index")},push:function(...n){const i=e.root;if(0==this.queue.idx&&i.classList.contains("is-interstitial"))return console.warn("new items cannot be added when playlist has ended.");const s=this.queue.members;s.push(...n),this.queue.last_idx=s.length-1,e.emit(t.PLAYLIST_ADD,{members:n})},clear:function(){this.queue.members=[],this.queue.plays--,function(e,n){e.playlist&&(n=e.playlist.queue=T(n),e.emit(t.PLAYLIST_READY,{queue:n,should_play:!1}))}(e,this.queue)}}}function k(e){const n=y(e,"flowplayer-skip-previous-icon");h(n,"role","button"),S(n,"click",(function(){e.playlist&&e.playlist.prev()}));const i=y(e,"flowplayer-skip-next-icon");h(i,"role","button"),S(i,"click",(function(){e.playlist&&e.playlist.next()}));const s=E("fp-playlist-prev-preview"),o=E("fp-playlist-next-preview"),l=m(e,"flowplayer-control-buttons");return l&&(l.prepend(n),l.append(i),l.append(s),l.append(o)),e.on("reap",(function(){e.skip_controls=void 0})),e.on([t.PLAYLIST_NEXT,t.PLAYLIST_ADD,t.PLAYLIST_REMOVE],(function(t){const n=w(t,"data.queue",w(e,"playlist.queue"));if(!n||!l||!e.skip_controls)return;L(l,"is-prev-button-disabled",!n.idx),L(l,"is-next-button-disabled",n.idx===n.last_idx);const i=n.idx<n.last_idx?function(t){if(!A(t)||0!=(t.mode&b.LOOP))return t.members[function(t){const e=t.idx+1;return e>t.last_idx?0:e}(t)]}(n):null,r=n.idx>0?function(t){if(0!==t.idx||0!=(t.mode&b.LOOP))return t.members[function(t){const e=t.idx-1;return e<0?t.last_idx:e}(t)]}(n):null;o.style.backgroundImage=["url(",i?i.poster:null,")"].join(""),s.style.backgroundImage=["url(",r?r.poster:null,")"].join("")})),{prevButton:n,nextButton:i,prevPreview:s,nextPreview:o}}function F(t,e){if(!e)return;e.skip_controls&&(t.skip_controls=k(t));const n=function(t){let e=null;if(n=t.controls,!r(n)&&!c(n))return;var n;c(t.controls)?e=t.controls:r(t.controls)&&(e=document.querySelector(t.controls));return i("Could not find controls by Selector["+t.controls+"]",c(e)),e}(e);if(!n)return;const s=y(t,"flowplayer-playlist-controls");if(n.append(s),!(s instanceof FlowplayerPlaylistControls))return;v(n,"fp-playlist-controls "+(t.opt("playlist",{}).theme||"fp-dark"));const o=t.root.className.split(" ").filter((function(t){return t.match(/^use-play/)})).pop();o&&v(n,o)}function Y(t,e,n){if(Array.isArray(e))return n(function(t,e){let n=e.shuffle?b.SHUFFLE:b.FIFO;return e.loop&&(n|=b.LOOP),g(t,{mode:n,sort:e.sort})}(e,t));throw new Error("config.playlist must be an Array")}function D(e){var n;e.on(t.PLAYLIST_READY,(function(t){var n,i;const s=e.opt("playlist",{}),o=null===(n=t.detail)||void 0===n?void 0:n.queue,l=null===(i=t.detail)||void 0===i?void 0:i.should_play;o&&s&&(e.playlist=C(e,o),l&&O(e,o,s))})),e.on("ended",(n=n=>{if(n.prevented_from_ads)return;const i=e.opt("playlist");return e.playlist&&i?A(e.playlist.queue)?function(e,n){if(e.emit(t.PLAYLIST_ENDED),!n.loop)return;if(!e.playlist)return;const i=e.playlist.queue=T(e.playlist.queue);e.emit(t.PLAYLIST_LOOP),O(e,i,n)}(e,i):void(i.advance&&O(e,e.playlist.queue,i)):void 0},t=>{setTimeout((function(){if(!t.defaultPrevented)return n(t)}),0)})),e.on(["playing","waiting","seeking"],(function(){if(!e.root.classList.contains("is-interstitial"))return;const n=m(e,"flowplayer-playlist-interstitial");n&&P(n,t.INTERSTITIAL_CANCEL)}))}class Playlist{constructor(t){f(t,"flowplayer-playlist-controls",FlowplayerPlaylistControls),f(t,"flowplayer-playlist-interstitial",class extends UpNext{constructor(t){super(t),this.classList.add("fp-interstitial")}}),f(t,"flowplayer-skip-next-icon",class extends FlowplayerIcon{constructor(t){super(t,e)}}),f(t,"flowplayer-skip-previous-icon",class extends FlowplayerIcon{constructor(t){super(t,n)}})}init(e,n,i){const s=e.playlist||{};s.delay="number"==typeof s.delay?s.delay:0,i.setOpts(Object.assign(Object.assign({},e),{playlist:s})),F(i,e.playlist),function(e){var n;const i=y(e,"flowplayer-playlist-interstitial");i.addEventListener(t.INTERSTITIAL_CANCEL,()=>e.root.classList.remove("is-interstitial")),i.addEventListener(t.INTERSTITIAL_END,()=>{e.root.classList.remove("is-interstitial"),e.togglePlay(!0)}),null===(n=m(e,"flowplayer-ui"))||void 0===n||n.prepend(i)}(i),D(i)}onload(e,n,i,s){Y(e.playlist||{},s.items,(function(e){i.setState("is-playlist",!0),i.emit(t.PLAYLIST_READY,{queue:e,should_play:0===i.currentSrc.length})}))}wants(t,e,n){return"flowplayer/playlist"==e.type&&!!e.items&&p(Object.assign(Object.assign({},n),{playlist:e.items}))}}return Playlist.events=t,function(t,e){if("object"==typeof exports&&"undefined"!=typeof module)return e;"flowplayer"in t||(t.flowplayer={extensions:[]});const n=t.flowplayer;"function"==typeof n?n(e):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(e)||n.extensions.push(e))}(window,Playlist),Playlist}));
|
package/plugins/qul.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.qul=n())}(this,(function(){"use strict";
|
|
1
|
+
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.qul=n())}(this,(function(){"use strict";const e="application/vnd.apple.mpegURL";document.createElement("video").canPlayType(e);function n(n){var t;return void 0===window.MediaSource&&void 0===window.WebKitMediaSource||function(){const e="undefined"!=typeof document&&"undefined"!=typeof window,n=e?navigator.userAgent:"",t=/iP(hone|od)/i.test(n)&&!/iPad/.test(n)&&!/IEMobile/i.test(n),o=/Android/.test(n)&&!/Firefox/.test(n),i=/^((?!chrome|android).)*safari/i.test(n),r=/SamsungBrowser/.test(n),d=r&&/SMART-TV/.test(n);return{controls:!t,video:function(n){return e&&document.createElement("video").canPlayType(n)},lang:e&&window.navigator.language,android:o,iphone:t,safari:i,ios:e&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,samsung:r,samsung_tv:r&&d,touch:!!("ontouchstart"in window)}}().video(e)&&(null===(t=null==n?void 0:n.hls)||void 0===t?void 0:t.native)}function t(e,n){n.id&&clearInterval(n.id)}function o(e,n){i(e.original_src,(o,i,r)=>{if(200!=i)return t(0,n),o?e.emit("error",o):e.emit("error",{code:i,resp:r})})}function i(e,n){const t=new XMLHttpRequest;t.onload=function(){if(200==t.status)return n(void 0,t.status);try{const e=JSON.parse(t.responseText);n(void 0,"qul:"+t.status,e)}catch(e){n(e)}},t.open("GET",function(e){const n=document.createElement("a");n.href=e;const t="bust="+Date.now();return[n.protocol,"//",n.hostname,n.pathname,n.search,n.search.length?"&":"?",t].join("")}(e)),t.send()}function r(e,n){const t=new CustomEvent(e,{detail:n,cancelable:!0});return n&&Object.defineProperty(t,"data",{get:()=>n}),t}!function(){let e=!1;try{const n=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("testPassive",null,n),window.removeEventListener("testPassive",null,n)}catch(e){}}();function d(e,n,t){const o=document.createElement("a");o.href=e;let i=encodeURIComponent(n);return t&&(i+="/dId:"+encodeURIComponent(t)),[o.protocol,"//",o.hostname,o.pathname.replace(a(o.pathname,0),i+"/"+a(o.pathname,0))].join("")}class QULPlugin{init(e,r,a){var u,l,c;const v=(null===(u=e.qul)||void 0===u?void 0:u.device_id)||(null===(l=e.qul)||void 0===l?void 0:l.dId)||a.deviceId();let f,p=null===(c=e.qul)||void 0===c?void 0:c.token;const m={};a.on("src",(function(i){var r;i.data&&(f=null===(r=i.data)||void 0===r?void 0:r.src,t(0,m),"string"==typeof f&&f.match(/\.m3u8$/)&&p&&(i.data.src=d(f,p,v),n(e)&&Object.assign(m,function(e,n){var i;const r=(null===(i=null==n?void 0:n.qul)||void 0===i?void 0:i.interval)||2e4,d={interval:Math.min(2e4,r)};return e.once("reap",(function(){t(0,d)})),d.id=setInterval(o,d.interval,e,d),setTimeout(o,0,e,d),d}(a,a.opts))))})),a.on("config",(function(e){var n,t,o,i,r,s;const u=null===(t=null===(n=e.data)||void 0===n?void 0:n.qul)||void 0===t?void 0:t.token,l=(null===(i=null===(o=e.data)||void 0===o?void 0:o.qul)||void 0===i?void 0:i.device_id)||(null===(s=null===(r=e.data)||void 0===r?void 0:r.qul)||void 0===s?void 0:s.dId);u&&u!==p&&function(e,n){p=e,a.setSrc({type:"application/x-mpegurl",src:d(f,p,n)})}(u,l)})),a.on("error",(function(e){var n,o;const r=((null===(n=e.data)||void 0===n?void 0:n.code)||"").toString();if(!r.match(/^(qul|http)/))return;t(0,m),e.preventDefault();const d=null===(o=e.data)||void 0===o?void 0:o.resp;if(d)return s(a,d,r);i(a.original_src,(e,n,t)=>{if(e)return a.emit("error",e);!isNaN(Number(n))&&Number(n)<400||s(a,t,null==n?void 0:n.toString())})}))}}function s(e,n,t){const o=(null==n?void 0:n.message)||"an error occurred during this session",i=(null==n?void 0:n.key)?e.i18n(n.key,o):o;e.pause();const d=r("qul:error",{code:t,resp:n});if(e.dispatchEvent(d),d.defaultPrevented)return;const s=window.customElements.get("flowplayer-error"),a=function(e,n){const t=e._customElements.get(n);return t&&e.root.querySelector(t)||void 0}(e,"flowplayer-ui");if(a&&s){if(e.setState("is-error",!0),!e.root.querySelector("#qul_error")){const n=new s(e);n.id="qul_error",a.append(n)}!function(e,n,t){const o=r(n,t);e.dispatchEvent(o)}(e.root.querySelector("#qul_error"),"error",{formatted_data:{message:i}})}}function a(e,n){return e.split("/").reverse().slice(0,n+1).reverse().join("/")}return QULPlugin.events={QUL_ERROR:"qul:error"},function(e,n){if("object"==typeof exports&&"undefined"!=typeof module)return n;"flowplayer"in e||(e.flowplayer={extensions:[]});const t=e.flowplayer;return"function"==typeof t?(t(n),n):(Array.isArray(t.extensions)||(t.extensions=[]),~t.extensions.indexOf(n)||t.extensions.push(n),n)}(window,QULPlugin)}));
|
package/plugins/ssai.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.ssai=t())}(this,(function(){"use strict";function e(e,t){const n=document.createElement("div");n.classList.add("ad-ui","ssai");const i=function(e){const t=document.createElement("div");return t.classList.add("skippable-button","disabled"),e.append(t),t}(n),r=function(e){const t=document.createElement("div");return t.classList.add("timeline"),e.append(t),t}(n),s=function(e,t){const n=document.createElement("div");return n.classList.add("resume"),e.append(n),n.addEventListener("click",e=>t.togglePlay(!0)),n}(n,t);return e.append(n),{container:n,timeline:r,resume:s,skippable:i}}const t="function"==typeof HTMLMediaElement&&Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype,"currentTime");function n(e){var n;if(t)return null===(n=null==t?void 0:t.get)||void 0===n?void 0:n.call(e)}function i(e,n){var i;if(t)return null===(i=null==t?void 0:t.set)||void 0===i?void 0:i.call(e,n)}const r="function"==typeof HTMLMediaElement&&Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype,"duration");function s(e){var t;if(r)return null===(t=null==r?void 0:r.get)||void 0===t?void 0:t.call(e)}var a;function o(e,t){var n;const i=null===(n=e.ssai)||void 0===n?void 0:n.state;return i?{ok:t(i)}:{err:a.NotAvailable}}!function(e){e[e.NotAvailable=0]="NotAvailable"}(a||(a={}));var c=Object.freeze({__proto__:null,SSAI_AD_START:"ssai:ad:start",SSAI_AD_END:"ssai:ad:end",SSAI_AD_PROGRESS:"ssai:ad:progress"});function u(e,t){e.setState("ssai-ad-active",!0),e.emit("ssai:ad:start"),o(e,e=>e.adProgress={currentTime:0,duration:t}),p(e)}function d(e,t){e.ssai&&(o(e,e=>e.adProgress=t),function(e,{currentTime:t,duration:n}){if(void 0===n)return;const{timeline:i}=e,r=t/n*100,s=i.style.getPropertyValue("--ssai-percent-complete");i.classList.remove("go"),i.style.setProperty("--ssai-percent-previous",s),i.style.setProperty("--ssai-percent-complete",r.toFixed(3)),i.classList.add("go")}(e.ssai.ui,t),e.emit("ssai:ad:progress",t))}function l(e){if(!e.ssai)return;const{state:t,ui:n}=e.ssai;e.setState("ssai-ad-active",!1),function(e){const{timeline:t}=e;t.classList.remove("go"),"--ssai-percent-complete --ssai-percent-previous".split(" ").forEach(e=>t.style.setProperty(e,"0"))}(n),o(e,e=>delete e.adProgress),e.emit("ssai:ad:end"),p(e),"number"==typeof t.snapbackTime&&(i(e,t.snapbackTime),delete t.snapbackTime)}function p(e){e.videoHeight&&e.videoWidth&&e.setOpts({ratio:e.videoHeight/e.videoWidth})}function f(e){const t=e.ssai.ui,r=new google.ima.dai.api.StreamManager(function(e){const t=document.createElement("video");return Object.defineProperty(t,"currentTime",{get:function(){return n(e)},set:function(t){return i(e,t)}}),Object.defineProperty(t,"duration",{get:function(){return s(e)},set:function(){}}),t.addEventListener=function(t,n){e.addEventListener(t,n)},t}(e),t.container);return r.addEventListener([google.ima.dai.api.StreamEvent.Type.LOADED,google.ima.dai.api.StreamEvent.Type.ERROR,google.ima.dai.api.StreamEvent.Type.AD_BREAK_STARTED,google.ima.dai.api.StreamEvent.Type.AD_PROGRESS,google.ima.dai.api.StreamEvent.Type.AD_BREAK_ENDED,google.ima.dai.api.StreamEvent.Type.CLICK],t=>{!function(e,t,n,i){switch(i.type){case google.ima.dai.api.StreamEvent.Type.LOADED:return function(e,t){const n=t.getStreamData();if(e.
|
|
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.ssai=t())}(this,(function(){"use strict";function e(e,t){const n=document.createElement("div");n.classList.add("ad-ui","ssai");const i=function(e){const t=document.createElement("div");return t.classList.add("skippable-button","disabled"),e.append(t),t}(n),r=function(e){const t=document.createElement("div");return t.classList.add("timeline"),e.append(t),t}(n),s=function(e,t){const n=document.createElement("div");return n.classList.add("resume"),e.append(n),n.addEventListener("click",e=>t.togglePlay(!0)),n}(n,t);return e.append(n),{container:n,timeline:r,resume:s,skippable:i}}const t="function"==typeof HTMLMediaElement&&Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype,"currentTime");function n(e){var n;if(t)return null===(n=null==t?void 0:t.get)||void 0===n?void 0:n.call(e)}function i(e,n){var i;if(t)return null===(i=null==t?void 0:t.set)||void 0===i?void 0:i.call(e,n)}const r="function"==typeof HTMLMediaElement&&Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype,"duration");function s(e){var t;if(r)return null===(t=null==r?void 0:r.get)||void 0===t?void 0:t.call(e)}var a;function o(e,t){var n;const i=null===(n=e.ssai)||void 0===n?void 0:n.state;return i?{ok:t(i)}:{err:a.NotAvailable}}!function(e){e[e.NotAvailable=0]="NotAvailable"}(a||(a={}));var c=Object.freeze({__proto__:null,SSAI_AD_START:"ssai:ad:start",SSAI_AD_END:"ssai:ad:end",SSAI_AD_PROGRESS:"ssai:ad:progress"});function u(e,t){e.setState("ssai-ad-active",!0),e.emit("ssai:ad:start"),o(e,e=>e.adProgress={currentTime:0,duration:t}),p(e)}function d(e,t){e.ssai&&(o(e,e=>e.adProgress=t),function(e,{currentTime:t,duration:n}){if(void 0===n)return;const{timeline:i}=e,r=t/n*100,s=i.style.getPropertyValue("--ssai-percent-complete");i.classList.remove("go"),i.style.setProperty("--ssai-percent-previous",s),i.style.setProperty("--ssai-percent-complete",r.toFixed(3)),i.classList.add("go")}(e.ssai.ui,t),e.emit("ssai:ad:progress",t))}function l(e){if(!e.ssai)return;const{state:t,ui:n}=e.ssai;e.setState("ssai-ad-active",!1),function(e){const{timeline:t}=e;t.classList.remove("go"),"--ssai-percent-complete --ssai-percent-previous".split(" ").forEach(e=>t.style.setProperty(e,"0"))}(n),o(e,e=>delete e.adProgress),e.emit("ssai:ad:end"),p(e),"number"==typeof t.snapbackTime&&(i(e,t.snapbackTime),delete t.snapbackTime)}function p(e){e.videoHeight&&e.videoWidth&&e.setOpts({ratio:e.videoHeight/e.videoWidth})}function f(e){const t=e.ssai.ui,r=new google.ima.dai.api.StreamManager(function(e){const t=document.createElement("video");return Object.defineProperty(t,"currentTime",{get:function(){return n(e)},set:function(t){return i(e,t)}}),Object.defineProperty(t,"duration",{get:function(){return s(e)},set:function(){}}),t.addEventListener=function(t,n){e.addEventListener(t,n)},t}(e),t.container);return r.addEventListener([google.ima.dai.api.StreamEvent.Type.LOADED,google.ima.dai.api.StreamEvent.Type.ERROR,google.ima.dai.api.StreamEvent.Type.AD_BREAK_STARTED,google.ima.dai.api.StreamEvent.Type.AD_PROGRESS,google.ima.dai.api.StreamEvent.Type.AD_BREAK_ENDED,google.ima.dai.api.StreamEvent.Type.CLICK],t=>{!function(e,t,n,i){switch(i.type){case google.ima.dai.api.StreamEvent.Type.LOADED:return function(e,t){const n=t.getStreamData();if(e.live_state.dvr=!1,n.url)return e.setSrc(n.url);if(n.errorMessage)return e.emit("error",{message:n.errorMessage});return e.emit("error",{message:"dai content was unavailable"})}(e,i);case google.ima.dai.api.StreamEvent.Type.ERROR:return function(e,t,n){if(n)return e.setSrc(n);e.emit("error",{message:"error loading stream"})}(e,0,e.opt("dai.backup"));case google.ima.dai.api.StreamEvent.Type.AD_BREAK_STARTED:return u(e);case google.ima.dai.api.StreamEvent.Type.AD_BREAK_ENDED:return l(e);case google.ima.dai.api.StreamEvent.Type.AD_PROGRESS:{const t=i.getStreamData();return t.adProgressData&&d(e,t.adProgressData)}case google.ima.dai.api.StreamEvent.Type.CLICK:return function(e,t,n){if(e.paused)return e.play();e.pause()}(e);default:console.warn("[flowplayer.dai] unhandled event=%s\n%o",i.type,i)}}(e,0,0,t)},!1),e.on("ID3",({data:e})=>{e&&Array.isArray(e.cues)&&e.cues.forEach(e=>{const t={},n=e.value;t[n.key]=n.data,r.onTimedMetadata(t)})}),{streamManager:r}}function m(e,t){return"string"==typeof t.assetKey?function(e,t){const n=new google.ima.dai.api.LiveStreamRequest;n.assetKey=t.assetKey||"",n.apiKey=t.apiKey||"",e.requestStream(n)}(e,t):function(e,t){const n=new google.ima.dai.api.VODStreamRequest;n.contentSourceId=t.contentSrcId||"",n.videoId=t.videoId||"",n.apiKey=t.apiKey||"",e.requestStream(n)}(e,t)}var v=Object.freeze({__proto__:null,exists:function(){var e,t;return!!(null===(t=null===(e=window.google)||void 0===e?void 0:e.ima)||void 0===t?void 0:t.dai)},init:function(e,t){t.ssai&&Object.assign(t.ssai,f(t))},srcIsValid:function(e){return"google/dai"==e.type&&!!(e.videoId||e.contentSrcId||e.assetKey)},onload:function(e,t){var n;(null===(n=e.ssai)||void 0===n?void 0:n.streamManager)&&m(e.ssai.streamManager,t)},getContentCurrentTime:function(e){const t=e.ssai.streamManager,i=n(e);return t?t.contentTimeForStreamTime(i):i},setContentCurrentTime:function(e,t){if(.1==t)return;const n=e.ssai.streamManager;return i(e,n?n.streamTimeForContentTime(t):t)},getContentDuration:function(e){const t=e.ssai.streamManager,n=s(e);return t?t.contentTimeForStreamTime(n):n},getPreviousActiveAdStart:function(e,t){const n=e.ssai.streamManager.previousCuePointForStreamTime(t);if(n&&!n.played)return n.start}});const g=window.YospaceAdManagement||{AnalyticEventObserver:null};class EventObserver extends g.AnalyticEventObserver{constructor(e){super(),this.video=e}onAdvertBreakStart(e){const t=e.getDuration();if(!e.isActive()&&t){const e=n(this.video);i(this.video,e+t/1e3)}u(this.video,e.getStart())}onAdvertBreakEnd(){l(this.video)}onAdvertStart(e){}onAdvertEnd(){}onTrackingEvent(e){}}function y(e,t){YospaceAdManagement.SessionVOD.create(e,t.ssai.properties,e=>{const i=e.getPayload();if(i.getSessionResult()===YospaceAdManagement.SessionResult.INITIALISED){t.ssai.session=i;const e=new EventObserver(t);i.addAnalyticObserver(e),t.setSrc({src:i.getPlaybackUrl()}),setInterval(()=>{const e=1e3*n(t);i.onPlayheadUpdate(e),function(e,t,n){const i=e.getCurrentAdBreak();if(!i)return;const r={currentTime:n-i.getStart(),duration:i.getDuration()};d(t,r)}(i,t,e)},250)}else console.warn("YoSpace Failed to initialise session. ResultCode = "+i.getResultCode())})}const S=[v,Object.freeze({__proto__:null,exists:function(){return!!window.YospaceAdManagement},init:function(e,t){t.ssai&&Object.assign(t.ssai,function(){const e=new YospaceAdManagement.SessionProperties;return e.setUserAgent(navigator.userAgent),{properties:e}}())},srcIsValid:function(e){return"yospace"==e.type},onload:function(e,t){t&&t.src&&y(t.src,e)},getContentCurrentTime:function(e){const t=n(e),i=e.ssai.session;return i?i.getContentPositionForPlayhead(1e3*t)/1e3:t},setContentCurrentTime:function(e,t){const n=e.ssai.session;return i(e,n?n.getPlayheadForContentPosition(1e3*t)/1e3:t)},getContentDuration:function(e){const t=e.ssai.session,n=s(e);return t?t.getContentPositionForPlayhead(t.getDuration())/1e3:n},getPreviousActiveAdStart:function(e,t){const n=e.ssai.session;if(!n)return;const i=n.getAdBreaks();let r;const s=1e3*t;return i.forEach(e=>{void 0===r&&e.getStart()<s&&e.isActive()&&(r=e)}),void 0!==r?r.getStart()/1e3:void 0}})];class Ssai{init(t,r,a){S.forEach(t=>{!a.ssai&&t.exists()&&(a.ssai={provider:t,ui:e(r,a),state:{snapback:!1}},t.init(r,a),function(e){Object.defineProperty(e,"currentTime",{get:function(){if(e.ssai){const t=e.ssai.state.adProgress;return t?t.currentTime:e.ssai.provider.getContentCurrentTime(e)}return n(e)},set:function(t){if(e.ssai){if(e.ssai.state.adProgress)return;return e.ssai.provider.setContentCurrentTime(e,t)}}}),Object.defineProperty(e,"duration",{get:function(){if(e.ssai){const t=e.ssai.state.adProgress;return t?t.duration:e.ssai.provider.getContentDuration(e)}return s(e)},set:function(){}})}(a),a.on("seeked",()=>function(e){if(e.opt("live"))return;if(!e.ssai)return;const{provider:t,state:r}=e.ssai;if(r.snapback)return r.snapback=!1;const s=n(e),a=t.getPreviousActiveAdStart(e,s);void 0!==a&&(r.snapback=!0,r.snapbackTime=s,i(e,a))}(a)))})}onload(e,t,n,i){var r;(null===(r=n.ssai)||void 0===r?void 0:r.provider)&&n.ssai.provider.onload(n,i)}wants(e,t,n){let i=!1;return S.forEach(e=>{if(!i&&e.exists()&&e.srcIsValid(t))return i=!0}),i}}return Ssai.events=c,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,Ssai),Ssai}));
|