@flowplayer/player 3.7.1 → 3.7.2-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/events.d.ts +1 -1
- package/core/events.js +2 -2
- package/core.js +1 -1
- package/default.js +1 -1
- package/embed.js +3 -3
- package/index.d.ts +9 -0
- package/package.json +2 -1
- package/plugins/ads.js +1 -1
- package/plugins/analytics.js +1 -1
- package/plugins/health.js +1 -1
- package/plugins/hls.js +1 -1
- package/plugins/qsel.js +1 -1
- package/plugins/rts.js +1 -1
- package/plugins/vtsel.js +1 -0
package/plugins/vtsel.js
ADDED
|
@@ -0,0 +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.vtsel=t())}(this,(function(){"use strict";const e=(e,t)=>new(((e,t)=>{const n=e.get(t);if(!n)throw new Error(`no flowplayer component with the name ${t} exists`);const s=window.customElements.get(t);if(!s)throw new Error(`no default flowplayer component with the name ${t} exists`);const i=window.customElements.get(n);return"function"!=typeof i?s:i})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}const t="fp-on",n="fp-invis";class FlowplayerMenu extends FlowplayerComponent{constructor(e){super(e),this.player=e,this.menuContainer=document.createElement("details"),this.summaryEle=document.createElement("summary"),this.olEle=document.createElement("ol"),this.olEle.id=i(),this.menu=document.createElement("div"),this.closeEle=document.createElement("span"),this.menu.classList.add("fp-menu"),this.menu.append(this.closeEle,this.olEle),this.closeEle.classList.add("fp-close"),this.closeEle.textContent="×",this.menuContainer.append(this.summaryEle,this.menu),this.menuContainer.addEventListener("click",t=>{t.preventDefault();const n=this.menuContainer.open;n||(s(),document.active_menu=this.menuContainer),this.menuContainer.open=!n,e.root.classList.toggle("has-menu-opened",!n),this.olEle.setAttribute("aria-expanded",n?"false":"true")}),this.append(this.menuContainer),this.summaryEle.setAttribute("aria-haspopup","true"),this.summaryEle.setAttribute("aria-controls",this.olEle.id),this.summaryEle.setAttribute("tabindex","0"),this.summaryEle.setAttribute("role","button")}get options(){return this.olEle.querySelectorAll("li")}setMenuAttrs(t){if(this.summaryEle.id||(this.summaryEle.id=t.id||i()),this.className=t.class,this.menuContainer.classList.add("fp-menu-container"),this.toggle_visibility(!0),this.olEle.setAttribute("aria-labelledby",this.summaryEle.id),this.olEle.setAttribute("role","menu"),this.summaryEle.setAttribute("aria-label",t.menuTitle||"Menu"),t.summaryTitle&&(this.summaryEle.textContent=t.summaryTitle),t.summaryIcon){const n=e(this.player,t.summaryIcon);n.setAttribute("tabindex",""),this.summaryEle.append(n)}if(t.menuTitle){const e=document.createElement("h3");e.textContent=t.menuTitle,this.menu.prepend(e)}this.menu.classList.toggle("fp-icons",!!t.icons),this.addEventListener(t.options_event,e=>{this.render(e.data)}),t.item_selected_event&&this.addEventListener(t.item_selected_event,e=>{void 0!==e.data&&this.select_item(e.data.selected_index)})}render(e){this.olEle&&(this.olEle.innerHTML="",e&&e.forEach(this.menuOption,this),this.toggle_visibility(!(null==e?void 0:e.length)))}menuOption(e,t){const n=document.createElement("li");n.setAttribute("role","menuitem"),n.setAttribute("tabindex","0"),e.icon&&n.append(e.icon);const s=document.createElement("span");s.textContent=e.text,n.append(s),n.addEventListener("click",()=>{this.select_item(t),"function"==typeof e.onclick&&e.onclick()}),this.olEle.appendChild(n)}select_item(e){this.options.forEach((n,s)=>{n.classList.toggle(t,s===e&&("flowplayer-subtitles-menu"!==this.localName||!n.classList.contains(t)))})}unselect_item(){this.options.forEach(e=>{e.classList.remove(t)})}toggle_visibility(e){this.classList.toggle(n,e),this.menu.style.setProperty("display",e?"none":"block")}}function s(){Array.from(document.querySelectorAll(".fp-engine")).forEach(e=>{var t;const n=e.root.querySelector("details[open].fp-menu-container");n&&(n.open=!1,null===(t=n.querySelector("summary"))||void 0===t||t.removeAttribute("aria-expanded"),e.root.classList.toggle("has-menu-opened",!1))})}function i(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}document.addEventListener("click",(function(e){this.active_menu&&!e.composedPath().includes(this.active_menu)&&(s(),this.active_menu=void 0)}));function r(e,t,n){const s=function(e,t){const n=new CustomEvent(e,{detail:t,cancelable:!0});return t&&Object.defineProperty(n,"data",{get:()=>t}),n}(t,n);return e.dispatchEvent(s),e}var o;!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){}}(),function(e){e[e.Err=0]="Err",e[e.Idle=1]="Idle",e[e.Receiving=2]="Receiving",e[e.Broadcasting=3]="Broadcasting"}(o||(o={}));var l=function(e){var t={exports:{}};return e(t,t.exports),t.exports}((function(e,t){var n,s,i,r,o;n=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,s=/^(?=([^\/?#]*))\1([^]*)$/,i=/(?:\/|^)\.(?=\/)/g,r=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(e,t,n){if(n=n||{},e=e.trim(),!(t=t.trim())){if(!n.alwaysNormalize)return e;var i=o.parseURL(e);if(!i)throw new Error("Error trying to parse base URL.");return i.path=o.normalizePath(i.path),o.buildURLFromParts(i)}var r=o.parseURL(t);if(!r)throw new Error("Error trying to parse relative URL.");if(r.scheme)return n.alwaysNormalize?(r.path=o.normalizePath(r.path),o.buildURLFromParts(r)):t;var l=o.parseURL(e);if(!l)throw new Error("Error trying to parse base URL.");if(!l.netLoc&&l.path&&"/"!==l.path[0]){var a=s.exec(l.path);l.netLoc=a[1],l.path=a[2]}l.netLoc&&!l.path&&(l.path="/");var c={scheme:l.scheme,netLoc:r.netLoc,path:null,params:r.params,query:r.query,fragment:r.fragment};if(!r.netLoc&&(c.netLoc=l.netLoc,"/"!==r.path[0]))if(r.path){var u=l.path,d=u.substring(0,u.lastIndexOf("/")+1)+r.path;c.path=o.normalizePath(d)}else c.path=l.path,r.params||(c.params=l.params,r.query||(c.query=l.query));return null===c.path&&(c.path=n.alwaysNormalize?o.normalizePath(r.path):r.path),o.buildURLFromParts(c)},parseURL:function(e){var t=n.exec(e);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(i,"");e.length!==(e=e.replace(r,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}},e.exports=o}));const a=/#EXT-X-MEDIA:(.*)/g,c=/(.+?)=(".*?"|.*?)(?:,|$)/g;function u(e,t,n,s){let i=n;const r={name:e,default:n,data:s||[]};return Object.defineProperty(r,"selected",{get:()=>i,set(e){var n;"boolean"==typeof e&&i!==e&&(i&&1===(null===(n=t.tracks)||void 0===n?void 0:n.filter(e=>e.selected).length)||(i=e,e&&t.emit("tracks:video:select",{track:r})))}})}class AttrList{constructor(e){"string"==typeof e&&(e=AttrList.parseAttrList(e)),Object.keys(e).forEach(t=>{e.hasOwnProperty(t)&&("X-"===t.substring(0,2)&&(this.clientAttrs=this.clientAttrs||[],this.clientAttrs.push(t)),this[t]=e[t])})}bool(e){return"YES"===this[e]}static parseAttrList(e){let t;const n={};for(c.lastIndex=0;null!==(t=c.exec(e));){let e=t[2];0===e.indexOf('"')&&e.lastIndexOf('"')===e.length-1&&(e=e.slice(1,-1));n[t[1].trim()]=e}return n}}class Vtsel{constructor(e){((e,t,n)=>{window.customElements.get(t)||window.customElements.define(t,n),e.customElements.get(t)||e.customElements.set(t,t)})(e,"flowplayer-video-menu",FlowplayerMenu)}init(t,n,s){const i=e(s,"flowplayer-video-menu");i instanceof FlowplayerMenu&&i.setMenuAttrs({summaryTitle:s.i18n("vtsel.button_txt","Video"),menuTitle:s.i18n("vtsel.menu_title","Video Track"),class:"fp-vsel",options_event:Vtsel.events.TRACKS,item_selected_event:Vtsel.events.SWITCH}),s.on("parse:video:tracks",e=>{const t=e.detail;t&&function(e,t,n){var s,i,r,o;let c,d=0;for(a.lastIndex=0;null!==(c=a.exec(t));){const t=new AttrList(c[1]);if("VIDEO"===t.TYPE){let a=null===(s=e.tracks)||void 0===s?void 0:s.find(e=>e.name===(t.NAME||t.LANGUAGE||"Track "+d));if(a||(a=u(t.NAME||t.LANGUAGE||d+++"",e,t.bool("DEFAULT")),t.bool("DEFAULT")&&(a.data=null===(i=e.hls)||void 0===i?void 0:i.levels.slice(0)),null===(r=e.tracks)||void 0===r||r.push(a)),t.bool("DEFAULT"))continue;const c={details:void 0,audioGroupIds:null===(o=e.hls)||void 0===o?void 0:o.levels[0].audioGroupIds,attrs:{},urlId:0,url:[t.URI?l.buildAbsoluteURL(n,t.URI,{alwaysNormalize:!0}):""],uri:t.URI?l.buildAbsoluteURL(n,t.URI,{alwaysNormalize:!0}):"",level:a.data.length,name:"level "+a.data.length};a.data.push(c)}}}(s,t.manifest,t.url)}),s.on("loadeddata",()=>{if(s.tracks&&s.tracks.length)return s.emit("videoTracks",s.tracks);s.tracks=s.videoTracks?Array.from(s.videoTracks).map((e,t)=>u(e.label?e.label:"track "+t,s,e.selected)):[u("default",s,!0)],s.emit("videoTracks",s.tracks)}),s.on("mount",(function(){var e;null===(e=function(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}(s,s.hasState("is-tv")?"flowplayer-tv-menu":"flowplayer-control"))||void 0===e||e.append(i)})),s.on("src",()=>{s.tracks=[],r(i,Vtsel.events.TRACKS,[])}),s.on("videoTracks",()=>{const e=s.tracks;e&&Array.isArray(e)&&(r(i,Vtsel.events.TRACKS,e.map(e=>({text:e.name,onclick:()=>e.selected=!0}))),r(i,Vtsel.events.SWITCH,{selected_index:e.findIndex(e=>e.default)}),i instanceof FlowplayerMenu&&i.toggle_visibility((null==e?void 0:e.length)<2))}),s.on("tracks:video:select",e=>{const t=e.detail.track,n=s.tracks;if(!t||!n||!Array.isArray(n))return;if(r(i,Vtsel.events.SWITCH,{selected_index:n.indexOf(t)}),!s.opts.is_native||!s.videoTracks)return;s.videoTracks[n.indexOf(t)].selected=!0;const o=n.find(e=>e.selected&&e!==t);o&&(o.selected=!1,s.videoTracks[n.indexOf(o)].selected=!1)}),s.on("rts/status",e=>{var t;const n=e.detail.status,l=e.detail.data;if(n===o.Idle)return r(i,Vtsel.events.TRACKS,[]),s.tracks=[];n===o.Receiving&&(null===(t=null==s?void 0:s.tracks)||void 0===t||t.push(u((null==l?void 0:l.sourceId)||"Main",s,!(null==l?void 0:l.sourceId),l)))})}}return Vtsel.events={TRACKS:"video:tracks",SWITCH:"video:update"},function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;if(null===document.currentScript)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,Vtsel),Vtsel}));
|