@flowplayer/player 3.0.7-rc.0 → 3.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core.js +2 -2
- package/default.js +2 -2
- package/embed.js +2 -2
- package/flowplayer.css +1 -1
- package/index.d.ts +41 -4
- package/package.json +1 -1
- package/plugins/asel.js +1 -1
- package/plugins/chromecast.js +1 -1
- package/plugins/health.js +2 -2
- package/plugins/qsel.js +1 -1
- package/plugins/share.js +1 -1
- package/plugins/speed.js +1 -1
- package/plugins/subtitles.js +1 -1
- package/plugins/thumbnails.js +1 -1
package/plugins/subtitles.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.subtitles=t())}(this,(function(){"use strict";function e(e,t,n){const o=function(e){return Array.isArray(e)?e.slice(0):e.split(".")}(t);for(;o.length;){if(null==e)return n;const t=o.shift();if("string"!=typeof t)return n;e=e[t]}return null==e?n:e}function t(e,t){e.innerHTML="",t.forEach((function(t){const n=document.createElement("pre");n.classList.add("fp-cue"),function(e,t){const n=e.style,o=t.size;n.setProperty("--caption-size",o.toString());const i=t.position;i&&"auto"!==i&&t?n.setProperty("--caption-position",i.toString()):n.removeProperty("--caption-position");const s="captions-align-"+t.align;Array.from(e.classList).forEach((function(n){n!=s&&("captions-vertical"==n&&t.vertical||n.startsWith("captions")&&e.classList.remove(n))})),e.classList.add(s),e.classList.toggle("captions-vertical",!!t.vertical)}(e,t),n.appendChild(t.getCueAsHTML()),e.appendChild(n)}))}var n;function o(e,t){if(function(e){return Object.values(n).includes(e)}(t=t||n.Anonymous))return"crossOrigin"in e?e.crossOrigin=t:e.setAttribute("crossorigin",t),e}function i(e){const t=document.createElement("a");return t.href=e,t.origin}function s(e,t){const n=document.createElement("track");n.className="fp-track renderable",n.kind=t.kind||"captions",n.id=["fp",t.lang].join("-");const s=n.track;return"string"!=typeof t.crossorigin&&function(e,t){try{return e.src.startsWith("blob:"),i(e.src)!==i(t)}catch(e){return console.error(e),!0}}(e,t.src)&&(o(e),t.crossorigin=e.getAttribute("crossorigin")),"crossorigin"in t&&o(e,t.crossorigin),Object.keys(t).forEach(e=>{n[e]=t[e]}),s.mode=t.default?"showing":t.mode||"disabled",n.onload=function(){},s.oncuechange=function(t){e.emit(t.type,{track:t.target})},e.appendChild(n),n}!function(e){e.Anonymous="anonymous",e.UseCredentials="use-credentials",e.Empty=""}(n||(n={}));function r(e){(function(){const e="undefined"!=typeof document&&"undefined"!=typeof window,t=e?navigator.userAgent:"",n=/iP(hone|od)/i.test(t)&&!/iPad/.test(t)&&!/IEMobile/i.test(t),o=/Android/.test(t)&&!/Firefox/.test(t),i=/^((?!chrome|android).)*safari/i.test(t),s=/SamsungBrowser/.test(t),r=s&&/SMART-TV/.test(t);return{controls:!n,video:function(t){return e&&document.createElement("video").canPlayType(t)},lang:e&&window.navigator.language,android:o,iphone:n,safari:i,ios:e&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,samsung:s,samsung_tv:s&&r,touch:!!("ontouchstart"in window)}})().ios&&(e.on("fullscreenenter",(function(){Array.from(e.textTracks).forEach((function(e){e.mode="hidden"===e.mode?"showing":"disabled"}))})),e.on("fullscreenexit",(function(){Array.from(e.textTracks).forEach((function(e){e.mode="showing"===e.mode?"hidden":"disabled"}))})))}const c=(e,t)=>new(((e,t)=>{const n=e.get(t);if(!n)throw new Error(`no flowplayer component with the name ${t} exists`);const o=window.customElements.get(t);if(!o)throw new Error(`no default flowplayer component with the name ${t} exists`);const i=window.customElements.get(n);return"function"!=typeof i?o:i})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}const l="flowplayer-subtitles-menu",a="fp-on",u="fp-invis";class FlowplayerMenu extends FlowplayerComponent{constructor(e){super(e),this.player=e,this.menuContainer=document.createElement("details"),this.summaryEle=document.createElement("summary"),this.olEle=document.createElement("ol"),this.menu=document.createElement("div"),this.closeEle=document.createElement("span"),this.menu.classList.add("fp-menu"),this.menu.append(this.closeEle,this.olEle),this.closeEle.classList.add("fp-close"),this.closeEle.textContent="
|
|
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.subtitles=t())}(this,(function(){"use strict";function e(e,t,n){const o=function(e){return Array.isArray(e)?e.slice(0):e.split(".")}(t);for(;o.length;){if(null==e)return n;const t=o.shift();if("string"!=typeof t)return n;e=e[t]}return null==e?n:e}function t(e,t){e.innerHTML="",t.forEach((function(t){const n=document.createElement("pre");n.classList.add("fp-cue"),function(e,t){const n=e.style,o=t.size;n.setProperty("--caption-size",o.toString());const i=t.position;i&&"auto"!==i&&t?n.setProperty("--caption-position",i.toString()):n.removeProperty("--caption-position");const s="captions-align-"+t.align;Array.from(e.classList).forEach((function(n){n!=s&&("captions-vertical"==n&&t.vertical||n.startsWith("captions")&&e.classList.remove(n))})),e.classList.add(s),e.classList.toggle("captions-vertical",!!t.vertical)}(e,t),n.appendChild(t.getCueAsHTML()),e.appendChild(n)}))}var n;function o(e,t){if(function(e){return Object.values(n).includes(e)}(t=t||n.Anonymous))return"crossOrigin"in e?e.crossOrigin=t:e.setAttribute("crossorigin",t),e}function i(e){const t=document.createElement("a");return t.href=e,t.origin}function s(e,t){const n=document.createElement("track");n.className="fp-track renderable",n.kind=t.kind||"captions",n.id=["fp",t.lang].join("-");const s=n.track;return"string"!=typeof t.crossorigin&&function(e,t){try{return e.src.startsWith("blob:"),i(e.src)!==i(t)}catch(e){return console.error(e),!0}}(e,t.src)&&(o(e),t.crossorigin=e.getAttribute("crossorigin")),"crossorigin"in t&&o(e,t.crossorigin),Object.keys(t).forEach(e=>{n[e]=t[e]}),s.mode=t.default?"showing":t.mode||"disabled",n.onload=function(){},s.oncuechange=function(t){e.emit(t.type,{track:t.target})},e.appendChild(n),n}!function(e){e.Anonymous="anonymous",e.UseCredentials="use-credentials",e.Empty=""}(n||(n={}));function r(e){(function(){const e="undefined"!=typeof document&&"undefined"!=typeof window,t=e?navigator.userAgent:"",n=/iP(hone|od)/i.test(t)&&!/iPad/.test(t)&&!/IEMobile/i.test(t),o=/Android/.test(t)&&!/Firefox/.test(t),i=/^((?!chrome|android).)*safari/i.test(t),s=/SamsungBrowser/.test(t),r=s&&/SMART-TV/.test(t);return{controls:!n,video:function(t){return e&&document.createElement("video").canPlayType(t)},lang:e&&window.navigator.language,android:o,iphone:n,safari:i,ios:e&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,samsung:s,samsung_tv:s&&r,touch:!!("ontouchstart"in window)}})().ios&&(e.on("fullscreenenter",(function(){Array.from(e.textTracks).forEach((function(e){e.mode="hidden"===e.mode?"showing":"disabled"}))})),e.on("fullscreenexit",(function(){Array.from(e.textTracks).forEach((function(e){e.mode="showing"===e.mode?"hidden":"disabled"}))})))}const c=(e,t)=>new(((e,t)=>{const n=e.get(t);if(!n)throw new Error(`no flowplayer component with the name ${t} exists`);const o=window.customElements.get(t);if(!o)throw new Error(`no default flowplayer component with the name ${t} exists`);const i=window.customElements.get(n);return"function"!=typeof i?o:i})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}const l="flowplayer-subtitles-menu",a="fp-on",u="fp-invis";class FlowplayerMenu extends FlowplayerComponent{constructor(e){super(e),this.player=e,this.menuContainer=document.createElement("details"),this.summaryEle=document.createElement("summary"),this.olEle=document.createElement("ol"),this.menu=document.createElement("div"),this.closeEle=document.createElement("span"),this.menu.classList.add("fp-menu"),this.menu.append(this.closeEle,this.olEle),this.closeEle.classList.add("fp-close"),this.closeEle.textContent="×",this.menuContainer.append(this.summaryEle,this.menu),this.menuContainer.addEventListener("click",(function(t){t.preventDefault();const n=this.open;n||(d(),document.active_menu=this),this.open=!n,e.root.classList.toggle("has-menu-opened",!n)})),this.append(this.menuContainer)}get options(){return this.olEle.querySelectorAll("li")}setMenuAttrs(e){if(this.className=`${e.class} ${u}`,this.menuContainer.classList.add("fp-menu-container"),this.menuContainer.setAttribute("aria-controls",e.id||Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)),this.menuContainer.setAttribute("aria-label",e.menuTitle||""),e.summaryTitle&&(this.summaryEle.textContent=e.summaryTitle),e.summaryIcon){const t=c(this.player,e.summaryIcon);t.setAttribute("tabindex",""),this.summaryEle.append(t)}if(e.menuTitle){const t=document.createElement("h3");t.textContent=e.menuTitle,this.menu.prepend(t)}this.menu.classList.toggle("fp-icons",!!e.icons),this.addEventListener(e.options_event,e=>{this.render(e.data)}),e.item_selected_event&&this.addEventListener(e.item_selected_event,e=>{void 0!==e.data&&this.select_item(e.data.selected_index)})}render(e){this.olEle&&(this.olEle.innerHTML="",e&&e.forEach(this.menuOption,this),this.classList.toggle(u,!(null==e?void 0:e.length)))}menuOption(e,t){const n=document.createElement("li");n.setAttribute("tabindex","0"),n.setAttribute("role","menuitem"),e.icon&&n.append(e.icon);const o=document.createElement("span");o.textContent=e.text,n.append(o),n.addEventListener("click",()=>{this.select_item(t),"function"==typeof e.onclick&&e.onclick()}),this.olEle.appendChild(n)}select_item(e){this.options.forEach((t,n)=>{t.classList.toggle(a,n===e&&(this.localName!==l||!t.classList.contains(a)))})}unselect_item(){this.options.forEach(e=>{e.classList.remove(a)})}}function d(){Array.from(document.querySelectorAll(".fp-engine")).forEach(e=>{const t=e.root.querySelector("details[open].fp-menu-container");t&&(t.open=!1,e.root.classList.toggle("has-menu-opened",!1))})}function m(e,t,n){const o=function(e,t){const n=new CustomEvent(e,{detail:t,cancelable:!0});return t&&Object.defineProperty(n,"data",{get:()=>t}),n}(t,n);return e.dispatchEvent(o),e}function f(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}document.addEventListener("click",(function(e){this.active_menu&&!e.composedPath().includes(this.active_menu)&&(d(),this.active_menu=void 0)})),function(){let e=!1;try{const t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("testPassive",null,t),window.removeEventListener("testPassive",null,t)}catch(e){}}();class Subtitles{constructor(e){((e,t,n)=>{window.customElements.get(t)||window.customElements.define(t,n),e.customElements.get(t)||e.customElements.set(t,t)})(e,l,FlowplayerMenu)}init(n,o,i){const a=c(i,l);a instanceof FlowplayerMenu&&a.setMenuAttrs({class:"fp-cc",summaryTitle:i.i18n("cc.button","CC"),menuTitle:i.i18n("cc.menu_title","Subtitles"),options_event:Subtitles.events.TRACKS,item_selected_event:Subtitles.events.SWITCH});const u=function(e){const t=document.createElement("div");return t.classList.add("fp-captions"),t.ontouchend=t=>e.emit(t.type),t.onclick=t=>e.emit(t.type),t}(i);let d,p=[],h=[];function y(e){var t;if(e==d)return v();v(),null===(t=i.root.querySelector(l))||void 0===t||t.summaryEle.classList.add("fp-color-text"),e.mode="hidden",d=e,i.emit("cuechange",{track:e}),i.emit("tracks:text:updated",d)}function v(){var e;d&&(i.emit("tracks:text:updated"),null===(e=i.root.querySelector(l))||void 0===e||e.summaryEle.classList.remove("fp-color-text"),d.mode="disabled",d=void 0,t(u,[]))}i.on("mount",(function(){var e;const t=f(i,"flowplayer-control");if(!t)return null===(e=f(i,"flowplayer-ui"))||void 0===e?void 0:e.appendChild(u);t.insertAdjacentElement("beforebegin",u),t.append(a),a instanceof FlowplayerMenu&&a.menuContainer.addEventListener("click",()=>{var e;1===h.length&&(null===(e=a.querySelector("li"))||void 0===e||e.click())})})),i.on("config",(function(e){var t,n;const o=null===(n=null===(t=e.data)||void 0===t?void 0:t.subtitles)||void 0===n?void 0:n.tracks;o&&p!==o&&(p=o,0===p.length&&(m(a,Subtitles.events.TRACKS,[]),v(),h=[]),Array.from(i.querySelectorAll(".fp-track")).forEach(e=>{i.removeChild(e)}),p.forEach(e=>s(i,e)))})),i.textTracks.addEventListener("addtrack",()=>{const t=Array.from(i.textTracks).filter((function(e){return~["captions","subtitles","descriptions"].indexOf(e.kind)}));if(h.length===t.length&&h.every((e,n)=>e===t[n]))return;let o;t.map((function(e){return~["showing","hidden"].indexOf(e.mode)&&(o=e,e.mode="disabled"),e.oncuechange=e.oncuechange||function(e){i.emit(e.type,{track:e.target})},e})),m(a,Subtitles.events.TRACKS,t.map((function(e){return{text:e.label,onclick:y.bind(0,e)}}))),h=t.slice();const s=e(n,"subtitles.show");if(o=(!1!==s?o:void 0)||h.find(e=>e.label===(null==d?void 0:d.label)),!o)return v();y(o),m(a,Subtitles.events.SWITCH,{selected_index:h.indexOf(o)})}),i.on("cuechange",(function(n){var o;const i=null===(o=n.data)||void 0===o?void 0:o.track,s=Array.from(e(i,"activeCues",[])).filter((e,t,n)=>t===n.findIndex(t=>e.id===t.id)).sort((e,t)=>"number"!=typeof e.line||"number"!=typeof t.line?0:e.line-t.line);t(u,s)})),r(i)}}return Subtitles.events={TRACKS:"subs:tracks",SWITCH:"subs:change"},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,Subtitles),Subtitles}));
|
package/plugins/thumbnails.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.thumbnails=t())}(this,(function(){"use strict";var e;function t(t,n){if(function(t){return Object.values(e).includes(t)}(n=n||e.Anonymous))return"crossOrigin"in t?t.crossOrigin=n:t.setAttribute("crossorigin",n),t}function n(e){const t=document.createElement("a");return t.href=e,t.origin}!function(e){e.Anonymous="anonymous",e.UseCredentials="use-credentials",e.Empty=""}(e||(e={}));function r(e,t){return e.querySelector("track[id='"+t+"']")}function o(e,r){const o=document.createElement("track");return o.src=r,function(e,t){try{return e.src.startsWith("blob:"),n(e.src)!==n(t)}catch(e){return console.error(e),!0}}(e,r)&&(e.setAttribute("poster","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="),t(e),t(o)),o}function s(e,t){if(function(e,t){return e.querySelector("track[src='"+t+"']")}(e,t))return;!function(e){const t=r(e,"thumbnails");t&&t.remove()}(e);const n=o(e,t);return n.kind="metadata",n.id="thumbnails",n.src=t,e.append(n),n}var i=Object.freeze({__proto__:null,THUMBNAILS_RENDER:"thumbnails:render",THUMBNAILS_HIDE:"thumbnails:hide"});class Pipe{constructor(e){this.data=e}static of(e){return new Pipe(e)}static maybe(e,t,...n){return null==e?e:t.apply(e,[e,...n])}tap(e,...t){return e.apply(this,[this.data,...t]),new Pipe(this.data)}fmap(e,...t){const n=e.apply(this,[this.data,...t]);return new Pipe(n)}unwrap(){return this.data}}function u(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}const a=(e,t)=>new(((e,t)=>{const n=e.get(t);if(!n)throw new Error(`no flowplayer component with the name ${t} exists`);const r=window.customElements.get(t);if(!r)throw new Error(`no default flowplayer component with the name ${t} exists`);const o=window.customElements.get(n);return"function"!=typeof o?r:o})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}class FlowplayerThumbnails extends FlowplayerComponent{constructor(e){super(e),this.className="fp-thumbnail-carousel",this.carousel=this.makeCarousel(),e.on("thumbnails:render",this.onRender.bind(this,e)),e.on("thumbnails:hide",()=>e.root.classList.remove("with-thumbnails"))}onRender(e,t){var n;if(!e.reaper)return;const r=null===(n=t.detail)||void 0===n?void 0:n.timestamp;if("number"!=typeof r)return;const o=Thumbnails.activeThumbnails(e,r);o&&this.renderCarousel(e,o)}renderCarousel(e,{previous:t,current:n,next:r}){e.root.classList.add("with-thumbnails"),t&&this.renderCarouselItem(this.carousel.previous,t),n&&this.renderCarouselItem(this.carousel.current,n),r&&this.renderCarouselItem(this.carousel.next,r)}makeCarousel(){return{previous:this.makeCarouselItem("previous"),current:this.makeCarouselItem("current"),next:this.makeCarouselItem("next")}}makeCarouselItem(e){const t=document.createElement("div");return t.classList.add("thumbnail",e),this.append(t),t}renderCarouselItem(e,t){const n=e.style;n.backgroundImage=`url("${t.url}")`,n.backgroundPositionX="-"+t.x+"px ",n.backgroundPositionY="-"+t.y+"px",n.height=t.h+"px",n.width=t.w+"px"}}function l(e){const t=document.createElement("a");return t.href=e,t}const c=/#xywh=(\d+),(\d+),(\d+),(\d+)$/,m=/^(https:|https:|\/)/;function d(e,t){const n=l(e.src),r=l(t),[o,s,i,u,a]=(r.hash.match(c)||[]).map(e=>parseInt(e,10));return{x:s,y:i,w:u,h:a,url:h(t,n)}}function h(e,t){if(e.match(m))return e;try{return new URL(e,t.href).toString()}catch(e){return""}}class Thumbnails{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-thumbnails-carousel",FlowplayerThumbnails)}static activeThumbnails(e,t){var n,o;const s=r(e,"thumbnails");if(!s)return;const i=Array.from(s.track.cues||{length:0}),u=i.find(e=>e.startTime<=t&&t<=e.endTime);if(!u)return{};const a=i.indexOf(u);return{previous:d(s,(null===(n=i[a-1])||void 0===n?void 0:n.text)||""),current:d(s,(null==u?void 0:u.text)||""),next:d(s,(null===(o=i[a+1])||void 0===o?void 0:o.text)||"")}}init(e,t,n){const r=u(n,"flowplayer-ui"),o=u(n,"flowplayer-control");n.reaper&&r&&o&&(r.insertBefore(a(n,"flowplayer-thumbnails-carousel"),o),n.once("mount",(function(){var e;u(e=n,"flowplayer-timeline-bar")&&(e.on("timeline/gesture/move",({data:t})=>{const n=null==t?void 0:t.percent;if("number"!=typeof n)return;if(!Number.isFinite(e.duration))return;const r=Pipe.of(e.duration*(n/100)).fmap(Math.min,e.duration).fmap(Math.max,0).unwrap();requestAnimationFrame(()=>{e.emit("thumbnails:render",{timestamp:r})})}),e.on("timeline/gesture/end",()=>{e.emit("thumbnails:hide")}))})),n.textTracks.addEventListener("addtrack",(function(e){const t=e.track;"thumbnails"===(null==t?void 0:t.id)&&(t.mode="hidden")})),n.on("config",(function(){var t;const r=null===(t=null==e?void 0:e.thumbnails)||void 0===t?void 0:t.src;if("string"==typeof r)return s(n,r)})))}}return Thumbnails.events=i,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,Thumbnails),Thumbnails}));
|