@flowplayer/player 3.4.7-rc.3 → 3.5.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/plugins/rts.js CHANGED
@@ -4,4 +4,4 @@
4
4
  * Copyright (c) 2018-2022 Koala Interactive, Inc.
5
5
  * License: MIT
6
6
  */
7
- function wf(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function bf(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?wf(Object(r),!0).forEach((function(t){xf(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):wf(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function Sf(e,t,r,n,i,o,s){try{var a=e[o](s),c=a.value}catch(e){return void r(e)}a.done?t(c):Promise.resolve(c).then(n,i)}function Cf(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function s(e){Sf(o,n,i,s,a,"next",e)}function a(e){Sf(o,n,i,s,a,"throw",e)}s(void 0)}))}}function xf(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Ef(){}function Tf(){Tf.init.call(this)}function If(e){return void 0===e._maxListeners?Tf.defaultMaxListeners:e._maxListeners}function Rf(e,t,r){if(t)e.call(r);else for(var n=e.length,i=Nf(e,n),o=0;o<n;++o)i[o].call(r)}function Pf(e,t,r,n){if(t)e.call(r,n);else for(var i=e.length,o=Nf(e,i),s=0;s<i;++s)o[s].call(r,n)}function Af(e,t,r,n,i){if(t)e.call(r,n,i);else for(var o=e.length,s=Nf(e,o),a=0;a<o;++a)s[a].call(r,n,i)}function kf(e,t,r,n,i,o){if(t)e.call(r,n,i,o);else for(var s=e.length,a=Nf(e,s),c=0;c<s;++c)a[c].call(r,n,i,o)}function Of(e,t,r,n){if(t)e.apply(r,n);else for(var i=e.length,o=Nf(e,i),s=0;s<i;++s)o[s].apply(r,n)}function Lf(e,t,r,n){var i,o,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]):(o=e._events=new Ef,e._eventsCount=0),s){if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=If(e))&&i>0&&s.length>i){s.warned=!0;var c=Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=s.length,a=c,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function Df(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function Mf(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function Nf(e,t){for(var r=Array(t);t--;)r[t]=e[t];return r}MillicastAdapter.Events={ACTIVE:"rts/millicast/active",INACTIVE:"rts/millicast/inactive"},MillicastAdapter.Type="wowza/millicast",Ef.prototype=Object.create(null),Tf.EventEmitter=Tf,Tf.usingDomains=!1,Tf.prototype.domain=void 0,Tf.prototype._events=void 0,Tf.prototype._maxListeners=void 0,Tf.defaultMaxListeners=10,Tf.init=function(){this.domain=null,Tf.usingDomains&&(void 0).active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new Ef,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Tf.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},Tf.prototype.getMaxListeners=function(){return If(this)},Tf.prototype.emit=function(e){var t,r,n,i,o,s,a,c="error"===e;if(s=this._events)c=c&&null==s.error;else if(!c)return!1;if(a=this.domain,c){if(t=arguments[1],!a){if(t instanceof Error)throw t;var u=Error('Uncaught, unspecified "error" event. ('+t+")");throw u.context=t,u}return t||(t=Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var l="function"==typeof r;switch(n=arguments.length){case 1:Rf(r,l,this);break;case 2:Pf(r,l,this,arguments[1]);break;case 3:Af(r,l,this,arguments[1],arguments[2]);break;case 4:kf(r,l,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=Array(n-1),o=1;o<n;o++)i[o-1]=arguments[o];Of(r,l,this,i)}return!0},Tf.prototype.addListener=function(e,t){return Lf(this,e,t,!1)},Tf.prototype.on=Tf.prototype.addListener,Tf.prototype.prependListener=function(e,t){return Lf(this,e,t,!0)},Tf.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,Df(this,e,t)),this},Tf.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,Df(this,e,t)),this},Tf.prototype.removeListener=function(e,t){var r,n,i,o,s;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(n=this._events))return this;if(!(r=n[e]))return this;if(r===t||r.listener&&r.listener===t)0==--this._eventsCount?this._events=new Ef:(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(i=-1,o=r.length;o-- >0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new Ef,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n<i;r+=1,n+=1)e[r]=e[n];e.pop()}(r,i);n.removeListener&&this.emit("removeListener",e,s||t)}return this},Tf.prototype.removeAllListeners=function(e){var t,r;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=new Ef,this._eventsCount=0):r[e]&&(0==--this._eventsCount?this._events=new Ef:delete r[e]),this;if(0===arguments.length){for(var n,i=Object.keys(r),o=0;o<i.length;++o)"removeListener"!==(n=i[o])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=new Ef,this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},Tf.prototype.listeners=function(e){var t,r=this._events;return r&&(t=r[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(t):[]},Tf.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):Mf.call(e,t)},Tf.prototype.listenerCount=Mf,Tf.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var jf=window.RTCPeerConnection,_f=window.RTCIceCandidate,Bf=window.RTCSessionDescription;class b extends Tf{constructor(e){super(),xf(this,"pc",void 0),this.pc=new jf({iceServers:e}),"ontrack"in this.pc?this.pc.ontrack=this.handleTrackEvent.bind(this):this.pc.onaddstream=this.handleNewStreamEvent.bind(this)}getPeerConnection(){return this.pc}close(){this.pc.close()}setRemoteDescription(e){return this.pc.setRemoteDescription(new Bf(e))}setLocalDescription(e){return this.pc.setLocalDescription(new Bf(e))}createAnswer(){var e=this;return Cf((function*(){return e.pc.createAnswer()}))()}createOffer(){var e=this;return Cf((function*(){return e.pc.createOffer()}))()}attachIceCandidate(e){return this.pc.addIceCandidate(new _f(e))}attachMediaStream(e){var t=this.pc,r=t.getSenders(),n=e.getTracks();r.length?n.forEach(e=>{r.filter(t=>{var r;return(null===(r=t.track)||void 0===r?void 0:r.kind)===e.kind}).forEach(t=>{t.replaceTrack(e)})}):n.forEach(r=>{t.addTrack(r,e)})}handleNewStreamEvent(e){var{stream:t}=e;this.emit("addstream",t)}handleTrackEvent(e){e.streams.forEach(e=>{this.emit("addstream",e)})}}class C{constructor(e,t,r){this.url=e,this.streamInfo=t,this.userData=r,xf(this,"ws",null),xf(this,"pendingCommands",new Map)}connect(){return this.ws?Promise.resolve(this.ws):new Promise((e,t)=>{var r=new WebSocket(this.url);r.binaryType="arraybuffer",r.onopen=()=>e(r),r.onerror=()=>t(),r.onclose=()=>t(),r.onmessage=this.handleSocketData.bind(this),this.ws=r})}disconnect(){this.ws&&(this.ws.close(),this.ws=null)}getOffer(){var e={direction:"play",command:"getOffer"};return this.streamInfo.secureToken&&(e.secureToken=this.streamInfo.secureToken),this.send(e)}sendOffer(e){return this.send({direction:"publish",command:"sendOffer",sdp:e})}sendResponse(e){return this.send({direction:"play",command:"sendResponse",sdp:e})}getAvailableStreams(){return this.send({direction:"play",command:"getAvailableStreams"})}send(e){var t=this;return Cf((function*(){var r,n=t.ws||(yield t.connect());return t.pendingCommands.has(e.command)||t.pendingCommands.set(e.command,((r={}).promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r)),n.send(JSON.stringify(bf(bf({},e),{},{streamInfo:t.streamInfo,userData:t.userData}))),t.pendingCommands.get(e.command).promise}))()}handleSocketData(e){var t,r=JSON.parse(e.data);200===r.status?(null!==(t=r.streamInfo)&&void 0!==t&&t.sessionId&&(this.streamInfo.sessionId=r.streamInfo.sessionId),this.pendingCommands.has(r.command)&&(this.pendingCommands.get(r.command).resolve(r),this.pendingCommands.delete(r.command))):this.pendingCommands.has(r.command)&&(this.pendingCommands.get(r.command).reject(r),this.pendingCommands.delete(r.command))}}var Uf="mozGetUserMedia"in navigator?"firefox":"webkitGetUserMedia"in navigator||!1===window.isSecureContext&&"webkitRTCPeerConnection"in window&&!("RTCIceGatherer"in window)?"chrome":navigator.mediaDevices&&navigator.userAgent.match(/Edge\/(\d+).(\d+)$/)?"edge":window.RTCPeerConnection&&navigator.userAgent.match(/AppleWebKit\/(\d+)\./)?"safari":"unknown",Vf=["vp9","vp8","h264","red","ulpfec","rtx"],Ff=["opus","isac","g722","pcmu","pcma","cn"];class S{constructor(e,t){this.videoOptions=e,this.audioOptions=t,xf(this,"audioIndex",-1),xf(this,"videoIndex",-1)}transformPlay(e){return e.sdp?(e.sdp=e.sdp.replace(/profile-level-id=(\w+)/gi,(e,t)=>{var r=parseInt(t,16),n=r>>16&255,i=r>>8&255,o=255&r;return n>66?(n=66,i=224,o=31):0===i&&(i=224),"profile-level-id=".concat((n<<16|i<<8|o).toString(16))}),e):e}transformPublish(e){var t=this.prepareSDP(e),r=this.videoOptions,n=this.audioOptions,i=null,o=()=>"m=audio"===i?n:"m=video"===i?r:null,s=t.filter(Boolean).map(e=>{var[t]=e.split(/\s|:/,1);switch(t){case"m=audio":case"m=video":var s="m=audio"===t?this.audioIndex:this.videoIndex;if(-1!==s&&"chrome"===Uf){var[a,c,u]=e.split(" ");return"".concat(a," ").concat(c," ").concat(u," ").concat(s)}i=t;break;case"a=rtpmap":var l=/^a=rtpmap:(\d+)\s+(\w+)\/(\d+)/.exec(e);if(!l||"chrome"!==Uf)break;var d=l[2].toLowerCase();r.bitRate&&Vf.includes(d)&&(e+="\r\na=fmtp:".concat(l[1]," x-google-min-bitrate=").concat(r.bitRate,";x-google-max-bitrate=").concat(r.bitRate)),n.bitRate&&Ff.includes(d)&&(e+="\r\na=fmtp:".concat(l[1]," x-google-min-bitrate=").concat(n.bitRate,";x-google-max-bitrate=").concat(n.bitRate));break;case"c=IN":var f=o();if(null!=f&&f.bitRate&&["firefox","safari"].includes(Uf)){var p=1e3*f.bitRate;e+="\r\nb=TIAS:".concat(.95*p-16e3),e+="\r\nb=AS:".concat(p),e+="\r\nb=CT:".concat(p)}break;case"a=mid":var h=o();h&&"chrome"===Uf&&(h.bitRate&&(e+="\r\nb=CT:".concat(h.bitRate),e+="\r\nb=AS:".concat(h.bitRate),"frameRate"in h&&h.frameRate&&(e+="\r\na=framerate:".concat(h.frameRate.toFixed(2)))),i=null)}return e}).join("\r\n")+"\r\n";return{type:e.type,sdp:s}}checkLine(e,t){if(/^a=(rtpmap|rtcp-fb|fmtp)/.test(e)){var r=e.split(":");if(r.length>1){var[n,i]=r[1].split(" ");if(!i.startsWith("http")&&!i.startsWith("ur")){var o=parseInt(n,10),s=t.get(o)||[];return s.push(e),t.set(o,s),!1}}}return!0}deliverCheckLine(e,t,r){var n=Array.from(r).find(t=>{var[,r]=t;return r.join("\r\n").includes(e)});if(!n)return[];var[i,o]=n;return"audio"===t?this.audioIndex=i:this.videoIndex=i,"VP8"!==e&&"VP9"!==e?o:o.filter(e=>!e.includes("transport-cc")&&!e.includes("goog-remb")&&!e.includes("nack"))}addAudio(e,t){for(var r="",n=0,i=e.length;n<i;++n){var o=e[n];if(o.startsWith("m=audio"))r="audio";else if(o.startsWith("m=video"))r="video";else if("a=rtcp-mux"===o&&"audio"===r){var s=this.deliverCheckLine(this.audioOptions.codec,"audio",t);e.splice(n+1,0,...s);break}}return e}addVideo(e,t){var r=e.includes("a=rtcp-rsize"),n=e.includes("a=rtcp-mux"),i=!1;if(!r&&!n)return e;var o=this.deliverCheckLine(this.videoOptions.codec,"video",t);return e.map(e=>{if(r){if(!i&&"a=rtcp-rsize"===e)return i=!0,[e].concat(o).join("\r\n")}else if("a=rtcp-mux"===e){if(i)return[e].concat(o).join("\r\n");i=!0}return e})}flattenLines(e){return e.join("\r\n").split("\r\n")}prepareSDP(e){var t=new Map,r=(e.sdp||"").split(/\r\n/);return r=r.filter(e=>e&&this.checkLine(e,t)),r=this.flattenLines(this.addAudio(r,t)),this.flattenLines(this.addVideo(r,t))}}class x extends Tf{constructor(e,t){super(),this.video=e,xf(this,"sdpUrl",""),xf(this,"applicationName",""),xf(this,"streamName",""),xf(this,"userData",null),xf(this,"sdpHandler",void 0),xf(this,"secureToken",void 0),xf(this,"constraints",{audio:!0,video:!0}),xf(this,"videoConfigs",{bitRate:360,codec:"42e01f",frameRate:29.97}),xf(this,"audioConfigs",{codec:"opus",bitRate:64}),xf(this,"iceServers",[]),xf(this,"mediaStream",null),xf(this,"pc",null),t&&this.setConfigurations(t)}setConfigurations(e){e.constraints&&(this.constraints=e.constraints),e.videoConfigs&&(this.videoConfigs=e.videoConfigs),e.audioConfigs&&(this.audioConfigs=e.audioConfigs),e.applicationName&&(this.applicationName=e.applicationName),e.streamName&&(this.streamName=e.streamName),e.sdpUrl&&(this.sdpUrl=e.sdpUrl),void 0!==e.userData&&(this.userData=e.userData),e.iceServers&&(this.iceServers=e.iceServers),e.sdpHandler&&(this.sdpHandler=e.sdpHandler),e.secureToken&&(this.secureToken=e.secureToken)}stop(){this.pc&&(this.pc.close(),this.pc=null)}getMediaStream(){return this.mediaStream}getPeerConnection(){return this.pc?this.pc.getPeerConnection():null}playLocal(e){var t=this;return Cf((function*(){e&&(t.constraints=e);var r=yield function(e){var t;return null!==(t=navigator.mediaDevices)&&void 0!==t&&t.getUserMedia?navigator.mediaDevices.getUserMedia(e):"getUserMedia"in navigator?new Promise((t,r)=>{navigator.getUserMedia(e,t,r)}):Promise.reject("Your browser does not support getUserMedia API")}(t.constraints);return t.attachStream(r),r}))()}stopLocal(){this.stop(),this.mediaStream&&(this.mediaStream.getTracks().forEach(e=>{e.stop()}),this.mediaStream=null)}playRemote(e){var t=this;return Cf((function*(){e&&t.setConfigurations(e);var r=t.createWowzaInstance();try{var{sdp:n}=yield r.getOffer(),i=t.createPeerConnection();i.on("addstream",t.attachStream.bind(t)),yield i.setRemoteDescription(n);var o=yield i.createAnswer(),s=new S(t.videoConfigs,t.audioConfigs),a=t.sdpHandler?t.sdpHandler(o,e=>s.transformPlay(e),"play"):s.transformPlay(o);yield i.setLocalDescription(a);var{iceCandidates:c}=yield r.sendResponse(a);c.forEach(e=>{i.attachIceCandidate(e)})}finally{r.disconnect()}}))()}publish(e){var t=this;return Cf((function*(){e&&t.setConfigurations(e);var r=t.createWowzaInstance();try{var n=t.mediaStream||(yield t.playLocal()),i=t.createPeerConnection();i.attachMediaStream(n);var o=new S(t.videoConfigs,t.audioConfigs),s=yield i.createOffer(),a=t.sdpHandler?t.sdpHandler(s,e=>o.transformPublish(e),"publish"):o.transformPublish(s);yield i.setLocalDescription(a);var{sdp:c,iceCandidates:u}=yield r.sendOffer(a);yield i.setRemoteDescription(c),u.forEach(e=>{i.attachIceCandidate(e)})}finally{r.disconnect()}}))()}getAvailableStreams(){var e=this;return Cf((function*(){var t=e.createWowzaInstance();try{var{availableStreams:r}=yield t.getAvailableStreams();return r||[]}catch(e){return[]}finally{t.disconnect()}}))()}createWowzaInstance(){return new C(this.sdpUrl,{applicationName:this.applicationName,sessionId:"[empty]",streamName:this.streamName,secureToken:this.secureToken},this.userData)}createPeerConnection(){return this.pc=new b(this.iceServers),this.pc}attachStream(e){this.mediaStream=e;try{var t=this.video.srcObject instanceof MediaStream&&this.video.srcObject;t&&t.id===e.id||(this.video.srcObject=e)}catch(t){this.video.src=window.URL.createObjectURL(e)}this.pc&&this.pc.attachMediaStream(e),this.video.play()}}class WowzaWebRTCAdapter{constructor(e,r,n=t("rts/webrtc")){this.player=e,this.src=r,this.log=n}static wants(e){return e.type==WowzaWebRTCAdapter.Type}async load(){this.log("loading",this.src.streamName),this.engine=new x(this.player,this.src),await this.engine.playRemote()}async stop(){var e;await(null===(e=this.engine)||void 0===e?void 0:e.stop())}}WowzaWebRTCAdapter.Events={ACTIVE:"rts/wowza-webrtc/active",INACTIVE:"rts/webrtc/inactive"},WowzaWebRTCAdapter.Type="wowza/webrtc";class RTSLoader{constructor(){this.log=t("rts"),console.log("warning / the realtime plugin is in beta release")}init(e,t,r){r.on("reap",()=>{var e;return null===(e=this.engine)||void 0===e?void 0:e.stop()})}onload(e,t,r,n){var i;switch(n.type){case MillicastAdapter.Type:this.engine=new MillicastAdapter(r,n);break;case WowzaWebRTCAdapter.Type:this.engine=new WowzaWebRTCAdapter(r,n)}null===(i=this.engine)||void 0===i||i.load()}wants(e,t,r){return"string"==typeof t.type&&(MillicastAdapter.wants(t)||WowzaWebRTCAdapter.wants(t))}}return RTSLoader.events={},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 r=e.flowplayer;"function"==typeof r?r(t):(Array.isArray(r.extensions)||(r.extensions=[]),~r.extensions.indexOf(t)||r.extensions.push(t))}(window,RTSLoader),RTSLoader}));
7
+ function wf(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function bf(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?wf(Object(r),!0).forEach((function(t){xf(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):wf(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function Sf(e,t,r,n,i,o,s){try{var a=e[o](s),c=a.value}catch(e){return void r(e)}a.done?t(c):Promise.resolve(c).then(n,i)}function Cf(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function s(e){Sf(o,n,i,s,a,"next",e)}function a(e){Sf(o,n,i,s,a,"throw",e)}s(void 0)}))}}function xf(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Ef(){}function Tf(){Tf.init.call(this)}function If(e){return void 0===e._maxListeners?Tf.defaultMaxListeners:e._maxListeners}function Rf(e,t,r){if(t)e.call(r);else for(var n=e.length,i=Nf(e,n),o=0;o<n;++o)i[o].call(r)}function Pf(e,t,r,n){if(t)e.call(r,n);else for(var i=e.length,o=Nf(e,i),s=0;s<i;++s)o[s].call(r,n)}function Af(e,t,r,n,i){if(t)e.call(r,n,i);else for(var o=e.length,s=Nf(e,o),a=0;a<o;++a)s[a].call(r,n,i)}function kf(e,t,r,n,i,o){if(t)e.call(r,n,i,o);else for(var s=e.length,a=Nf(e,s),c=0;c<s;++c)a[c].call(r,n,i,o)}function Of(e,t,r,n){if(t)e.apply(r,n);else for(var i=e.length,o=Nf(e,i),s=0;s<i;++s)o[s].apply(r,n)}function Lf(e,t,r,n){var i,o,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]):(o=e._events=new Ef,e._eventsCount=0),s){if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=If(e))&&i>0&&s.length>i){s.warned=!0;var c=Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=s.length,a=c,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function Df(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function Mf(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function Nf(e,t){for(var r=Array(t);t--;)r[t]=e[t];return r}MillicastAdapter.Events={ACTIVE:"rts/millicast/active",INACTIVE:"rts/millicast/inactive"},MillicastAdapter.Type="wowza/rts",Ef.prototype=Object.create(null),Tf.EventEmitter=Tf,Tf.usingDomains=!1,Tf.prototype.domain=void 0,Tf.prototype._events=void 0,Tf.prototype._maxListeners=void 0,Tf.defaultMaxListeners=10,Tf.init=function(){this.domain=null,Tf.usingDomains&&(void 0).active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new Ef,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Tf.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},Tf.prototype.getMaxListeners=function(){return If(this)},Tf.prototype.emit=function(e){var t,r,n,i,o,s,a,c="error"===e;if(s=this._events)c=c&&null==s.error;else if(!c)return!1;if(a=this.domain,c){if(t=arguments[1],!a){if(t instanceof Error)throw t;var u=Error('Uncaught, unspecified "error" event. ('+t+")");throw u.context=t,u}return t||(t=Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var l="function"==typeof r;switch(n=arguments.length){case 1:Rf(r,l,this);break;case 2:Pf(r,l,this,arguments[1]);break;case 3:Af(r,l,this,arguments[1],arguments[2]);break;case 4:kf(r,l,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=Array(n-1),o=1;o<n;o++)i[o-1]=arguments[o];Of(r,l,this,i)}return!0},Tf.prototype.addListener=function(e,t){return Lf(this,e,t,!1)},Tf.prototype.on=Tf.prototype.addListener,Tf.prototype.prependListener=function(e,t){return Lf(this,e,t,!0)},Tf.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,Df(this,e,t)),this},Tf.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,Df(this,e,t)),this},Tf.prototype.removeListener=function(e,t){var r,n,i,o,s;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(n=this._events))return this;if(!(r=n[e]))return this;if(r===t||r.listener&&r.listener===t)0==--this._eventsCount?this._events=new Ef:(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(i=-1,o=r.length;o-- >0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new Ef,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n<i;r+=1,n+=1)e[r]=e[n];e.pop()}(r,i);n.removeListener&&this.emit("removeListener",e,s||t)}return this},Tf.prototype.removeAllListeners=function(e){var t,r;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=new Ef,this._eventsCount=0):r[e]&&(0==--this._eventsCount?this._events=new Ef:delete r[e]),this;if(0===arguments.length){for(var n,i=Object.keys(r),o=0;o<i.length;++o)"removeListener"!==(n=i[o])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=new Ef,this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},Tf.prototype.listeners=function(e){var t,r=this._events;return r&&(t=r[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(t):[]},Tf.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):Mf.call(e,t)},Tf.prototype.listenerCount=Mf,Tf.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var jf=window.RTCPeerConnection,_f=window.RTCIceCandidate,Bf=window.RTCSessionDescription;class b extends Tf{constructor(e){super(),xf(this,"pc",void 0),this.pc=new jf({iceServers:e}),"ontrack"in this.pc?this.pc.ontrack=this.handleTrackEvent.bind(this):this.pc.onaddstream=this.handleNewStreamEvent.bind(this)}getPeerConnection(){return this.pc}close(){this.pc.close()}setRemoteDescription(e){return this.pc.setRemoteDescription(new Bf(e))}setLocalDescription(e){return this.pc.setLocalDescription(new Bf(e))}createAnswer(){var e=this;return Cf((function*(){return e.pc.createAnswer()}))()}createOffer(){var e=this;return Cf((function*(){return e.pc.createOffer()}))()}attachIceCandidate(e){return this.pc.addIceCandidate(new _f(e))}attachMediaStream(e){var t=this.pc,r=t.getSenders(),n=e.getTracks();r.length?n.forEach(e=>{r.filter(t=>{var r;return(null===(r=t.track)||void 0===r?void 0:r.kind)===e.kind}).forEach(t=>{t.replaceTrack(e)})}):n.forEach(r=>{t.addTrack(r,e)})}handleNewStreamEvent(e){var{stream:t}=e;this.emit("addstream",t)}handleTrackEvent(e){e.streams.forEach(e=>{this.emit("addstream",e)})}}class C{constructor(e,t,r){this.url=e,this.streamInfo=t,this.userData=r,xf(this,"ws",null),xf(this,"pendingCommands",new Map)}connect(){return this.ws?Promise.resolve(this.ws):new Promise((e,t)=>{var r=new WebSocket(this.url);r.binaryType="arraybuffer",r.onopen=()=>e(r),r.onerror=()=>t(),r.onclose=()=>t(),r.onmessage=this.handleSocketData.bind(this),this.ws=r})}disconnect(){this.ws&&(this.ws.close(),this.ws=null)}getOffer(){var e={direction:"play",command:"getOffer"};return this.streamInfo.secureToken&&(e.secureToken=this.streamInfo.secureToken),this.send(e)}sendOffer(e){return this.send({direction:"publish",command:"sendOffer",sdp:e})}sendResponse(e){return this.send({direction:"play",command:"sendResponse",sdp:e})}getAvailableStreams(){return this.send({direction:"play",command:"getAvailableStreams"})}send(e){var t=this;return Cf((function*(){var r,n=t.ws||(yield t.connect());return t.pendingCommands.has(e.command)||t.pendingCommands.set(e.command,((r={}).promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r)),n.send(JSON.stringify(bf(bf({},e),{},{streamInfo:t.streamInfo,userData:t.userData}))),t.pendingCommands.get(e.command).promise}))()}handleSocketData(e){var t,r=JSON.parse(e.data);200===r.status?(null!==(t=r.streamInfo)&&void 0!==t&&t.sessionId&&(this.streamInfo.sessionId=r.streamInfo.sessionId),this.pendingCommands.has(r.command)&&(this.pendingCommands.get(r.command).resolve(r),this.pendingCommands.delete(r.command))):this.pendingCommands.has(r.command)&&(this.pendingCommands.get(r.command).reject(r),this.pendingCommands.delete(r.command))}}var Uf="mozGetUserMedia"in navigator?"firefox":"webkitGetUserMedia"in navigator||!1===window.isSecureContext&&"webkitRTCPeerConnection"in window&&!("RTCIceGatherer"in window)?"chrome":navigator.mediaDevices&&navigator.userAgent.match(/Edge\/(\d+).(\d+)$/)?"edge":window.RTCPeerConnection&&navigator.userAgent.match(/AppleWebKit\/(\d+)\./)?"safari":"unknown",Vf=["vp9","vp8","h264","red","ulpfec","rtx"],Ff=["opus","isac","g722","pcmu","pcma","cn"];class S{constructor(e,t){this.videoOptions=e,this.audioOptions=t,xf(this,"audioIndex",-1),xf(this,"videoIndex",-1)}transformPlay(e){return e.sdp?(e.sdp=e.sdp.replace(/profile-level-id=(\w+)/gi,(e,t)=>{var r=parseInt(t,16),n=r>>16&255,i=r>>8&255,o=255&r;return n>66?(n=66,i=224,o=31):0===i&&(i=224),"profile-level-id=".concat((n<<16|i<<8|o).toString(16))}),e):e}transformPublish(e){var t=this.prepareSDP(e),r=this.videoOptions,n=this.audioOptions,i=null,o=()=>"m=audio"===i?n:"m=video"===i?r:null,s=t.filter(Boolean).map(e=>{var[t]=e.split(/\s|:/,1);switch(t){case"m=audio":case"m=video":var s="m=audio"===t?this.audioIndex:this.videoIndex;if(-1!==s&&"chrome"===Uf){var[a,c,u]=e.split(" ");return"".concat(a," ").concat(c," ").concat(u," ").concat(s)}i=t;break;case"a=rtpmap":var l=/^a=rtpmap:(\d+)\s+(\w+)\/(\d+)/.exec(e);if(!l||"chrome"!==Uf)break;var d=l[2].toLowerCase();r.bitRate&&Vf.includes(d)&&(e+="\r\na=fmtp:".concat(l[1]," x-google-min-bitrate=").concat(r.bitRate,";x-google-max-bitrate=").concat(r.bitRate)),n.bitRate&&Ff.includes(d)&&(e+="\r\na=fmtp:".concat(l[1]," x-google-min-bitrate=").concat(n.bitRate,";x-google-max-bitrate=").concat(n.bitRate));break;case"c=IN":var f=o();if(null!=f&&f.bitRate&&["firefox","safari"].includes(Uf)){var p=1e3*f.bitRate;e+="\r\nb=TIAS:".concat(.95*p-16e3),e+="\r\nb=AS:".concat(p),e+="\r\nb=CT:".concat(p)}break;case"a=mid":var h=o();h&&"chrome"===Uf&&(h.bitRate&&(e+="\r\nb=CT:".concat(h.bitRate),e+="\r\nb=AS:".concat(h.bitRate),"frameRate"in h&&h.frameRate&&(e+="\r\na=framerate:".concat(h.frameRate.toFixed(2)))),i=null)}return e}).join("\r\n")+"\r\n";return{type:e.type,sdp:s}}checkLine(e,t){if(/^a=(rtpmap|rtcp-fb|fmtp)/.test(e)){var r=e.split(":");if(r.length>1){var[n,i]=r[1].split(" ");if(!i.startsWith("http")&&!i.startsWith("ur")){var o=parseInt(n,10),s=t.get(o)||[];return s.push(e),t.set(o,s),!1}}}return!0}deliverCheckLine(e,t,r){var n=Array.from(r).find(t=>{var[,r]=t;return r.join("\r\n").includes(e)});if(!n)return[];var[i,o]=n;return"audio"===t?this.audioIndex=i:this.videoIndex=i,"VP8"!==e&&"VP9"!==e?o:o.filter(e=>!e.includes("transport-cc")&&!e.includes("goog-remb")&&!e.includes("nack"))}addAudio(e,t){for(var r="",n=0,i=e.length;n<i;++n){var o=e[n];if(o.startsWith("m=audio"))r="audio";else if(o.startsWith("m=video"))r="video";else if("a=rtcp-mux"===o&&"audio"===r){var s=this.deliverCheckLine(this.audioOptions.codec,"audio",t);e.splice(n+1,0,...s);break}}return e}addVideo(e,t){var r=e.includes("a=rtcp-rsize"),n=e.includes("a=rtcp-mux"),i=!1;if(!r&&!n)return e;var o=this.deliverCheckLine(this.videoOptions.codec,"video",t);return e.map(e=>{if(r){if(!i&&"a=rtcp-rsize"===e)return i=!0,[e].concat(o).join("\r\n")}else if("a=rtcp-mux"===e){if(i)return[e].concat(o).join("\r\n");i=!0}return e})}flattenLines(e){return e.join("\r\n").split("\r\n")}prepareSDP(e){var t=new Map,r=(e.sdp||"").split(/\r\n/);return r=r.filter(e=>e&&this.checkLine(e,t)),r=this.flattenLines(this.addAudio(r,t)),this.flattenLines(this.addVideo(r,t))}}class x extends Tf{constructor(e,t){super(),this.video=e,xf(this,"sdpUrl",""),xf(this,"applicationName",""),xf(this,"streamName",""),xf(this,"userData",null),xf(this,"sdpHandler",void 0),xf(this,"secureToken",void 0),xf(this,"constraints",{audio:!0,video:!0}),xf(this,"videoConfigs",{bitRate:360,codec:"42e01f",frameRate:29.97}),xf(this,"audioConfigs",{codec:"opus",bitRate:64}),xf(this,"iceServers",[]),xf(this,"mediaStream",null),xf(this,"pc",null),t&&this.setConfigurations(t)}setConfigurations(e){e.constraints&&(this.constraints=e.constraints),e.videoConfigs&&(this.videoConfigs=e.videoConfigs),e.audioConfigs&&(this.audioConfigs=e.audioConfigs),e.applicationName&&(this.applicationName=e.applicationName),e.streamName&&(this.streamName=e.streamName),e.sdpUrl&&(this.sdpUrl=e.sdpUrl),void 0!==e.userData&&(this.userData=e.userData),e.iceServers&&(this.iceServers=e.iceServers),e.sdpHandler&&(this.sdpHandler=e.sdpHandler),e.secureToken&&(this.secureToken=e.secureToken)}stop(){this.pc&&(this.pc.close(),this.pc=null)}getMediaStream(){return this.mediaStream}getPeerConnection(){return this.pc?this.pc.getPeerConnection():null}playLocal(e){var t=this;return Cf((function*(){e&&(t.constraints=e);var r=yield function(e){var t;return null!==(t=navigator.mediaDevices)&&void 0!==t&&t.getUserMedia?navigator.mediaDevices.getUserMedia(e):"getUserMedia"in navigator?new Promise((t,r)=>{navigator.getUserMedia(e,t,r)}):Promise.reject("Your browser does not support getUserMedia API")}(t.constraints);return t.attachStream(r),r}))()}stopLocal(){this.stop(),this.mediaStream&&(this.mediaStream.getTracks().forEach(e=>{e.stop()}),this.mediaStream=null)}playRemote(e){var t=this;return Cf((function*(){e&&t.setConfigurations(e);var r=t.createWowzaInstance();try{var{sdp:n}=yield r.getOffer(),i=t.createPeerConnection();i.on("addstream",t.attachStream.bind(t)),yield i.setRemoteDescription(n);var o=yield i.createAnswer(),s=new S(t.videoConfigs,t.audioConfigs),a=t.sdpHandler?t.sdpHandler(o,e=>s.transformPlay(e),"play"):s.transformPlay(o);yield i.setLocalDescription(a);var{iceCandidates:c}=yield r.sendResponse(a);c.forEach(e=>{i.attachIceCandidate(e)})}finally{r.disconnect()}}))()}publish(e){var t=this;return Cf((function*(){e&&t.setConfigurations(e);var r=t.createWowzaInstance();try{var n=t.mediaStream||(yield t.playLocal()),i=t.createPeerConnection();i.attachMediaStream(n);var o=new S(t.videoConfigs,t.audioConfigs),s=yield i.createOffer(),a=t.sdpHandler?t.sdpHandler(s,e=>o.transformPublish(e),"publish"):o.transformPublish(s);yield i.setLocalDescription(a);var{sdp:c,iceCandidates:u}=yield r.sendOffer(a);yield i.setRemoteDescription(c),u.forEach(e=>{i.attachIceCandidate(e)})}finally{r.disconnect()}}))()}getAvailableStreams(){var e=this;return Cf((function*(){var t=e.createWowzaInstance();try{var{availableStreams:r}=yield t.getAvailableStreams();return r||[]}catch(e){return[]}finally{t.disconnect()}}))()}createWowzaInstance(){return new C(this.sdpUrl,{applicationName:this.applicationName,sessionId:"[empty]",streamName:this.streamName,secureToken:this.secureToken},this.userData)}createPeerConnection(){return this.pc=new b(this.iceServers),this.pc}attachStream(e){this.mediaStream=e;try{var t=this.video.srcObject instanceof MediaStream&&this.video.srcObject;t&&t.id===e.id||(this.video.srcObject=e)}catch(t){this.video.src=window.URL.createObjectURL(e)}this.pc&&this.pc.attachMediaStream(e),this.video.play()}}class WowzaWebRTCAdapter{constructor(e,r,n=t("rts/webrtc")){this.player=e,this.src=r,this.log=n}static wants(e){return e.type==WowzaWebRTCAdapter.Type}async load(){this.log("loading",this.src.streamName),this.engine=new x(this.player,this.src),await this.engine.playRemote()}async stop(){var e;await(null===(e=this.engine)||void 0===e?void 0:e.stop())}}WowzaWebRTCAdapter.Events={ACTIVE:"rts/wowza-webrtc/active",INACTIVE:"rts/webrtc/inactive"},WowzaWebRTCAdapter.Type="wowza/webrtc";class RTSLoader{constructor(){this.log=t("rts"),console.log("warning / the realtime plugin is in beta release")}init(e,t,r){r.on("reap",()=>{var e;return null===(e=this.engine)||void 0===e?void 0:e.stop()})}onload(e,t,r,n){var i;switch(n.type){case MillicastAdapter.Type:this.engine=new MillicastAdapter(r,n);break;case WowzaWebRTCAdapter.Type:this.engine=new WowzaWebRTCAdapter(r,n)}null===(i=this.engine)||void 0===i||i.load()}wants(e,t,r){return"string"==typeof t.type&&(MillicastAdapter.wants(t)||WowzaWebRTCAdapter.wants(t))}}return RTSLoader.events={},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 r=e.flowplayer;"function"==typeof r?r(t):(Array.isArray(r.extensions)||(r.extensions=[]),~r.extensions.indexOf(t)||r.extensions.push(t))}(window,RTSLoader),RTSLoader}));
package/plugins/speed.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.speed=t())}(this,(function(){"use strict";function e(e,t,n){const s=function(e){return Array.isArray(e)?e.slice(0):e.split(".")}(t);for(;s.length;){if(null==e)return n;const t=s.shift();if("string"!=typeof t)return n;e=e[t]}return null==e?n:e}class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}const t="flowplayer-speed-menu",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 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),s="fp-on",i="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=l(),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||(o(),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(e){if(this.summaryEle.id||(this.summaryEle.id=e.id||l()),this.className=e.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",e.menuTitle||"Menu"),e.summaryTitle&&(this.summaryEle.textContent=e.summaryTitle),e.summaryIcon){const t=n(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.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((t,n)=>{t.classList.toggle(s,n===e&&("flowplayer-subtitles-menu"!==this.localName||!t.classList.contains(s)))})}unselect_item(){this.options.forEach(e=>{e.classList.remove(s)})}toggle_visibility(e){this.classList.toggle(i,e),this.menu.style.setProperty("display",e?"none":"block")}}function o(){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 l(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}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}document.addEventListener("click",(function(e){this.active_menu&&!e.composedPath().includes(this.active_menu)&&(o(),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 Speed{constructor(e){((e,t,n)=>{window.customElements.get(t)||window.customElements.define(t,n),e.customElements.get(t)||e.customElements.set(t,t)})(e,t,FlowplayerMenu)}init(s,i,o){let l=void 0;const u=n(o,t);u instanceof FlowplayerMenu&&u.setMenuAttrs({menuTitle:o.i18n("speed.menu_title"),summaryTitle:"1x",class:"fp-speed",options_event:Speed.events.OPTIONS}),o.on("config",()=>{const t=e(s,"speed",!0);if(t===l)return;if(l=t,0==t)return r(u,Speed.events.OPTIONS,[]);const n=e(s,"speed.options",Speed.DEFAULT_SPEED_OPTIONS),i=e(s,"speed.labels",[]);r(u,Speed.events.OPTIONS,Array.from({length:n.length}).map((e,t)=>{const s=n[t];return{text:i[t]||s+"x",onclick:a.bind(0,o,s)}}))}),o.on("mount",(function(){var e;null===(e=function(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}(o,"flowplayer-control"))||void 0===e||e.append(u)}))}}function a(e,n){var s;const i=null===(s=e.root.querySelector(t))||void 0===s?void 0:s.summaryEle;i&&(i.textContent=n+"x"),isNaN(n)||(e.playbackRate=n)}return Speed.DEFAULT_SPEED_OPTIONS=[.2,.5,1,2,10],Speed.events={OPTIONS:"speed:options"},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;return"function"==typeof n?(n(t),t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t),t)}(window,Speed)}));
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.speed=t())}(this,(function(){"use strict";function e(e,t,n){const s=function(e){return Array.isArray(e)?e.slice(0):e.split(".")}(t);for(;s.length;){if(null==e)return n;const t=s.shift();if("string"!=typeof t)return n;e=e[t]}return null==e?n:e}class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}const t="flowplayer-speed-menu",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 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),s="fp-on",i="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=l(),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||(o(),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(e){if(this.summaryEle.id||(this.summaryEle.id=e.id||l()),this.className=e.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",e.menuTitle||"Menu"),e.summaryTitle&&(this.summaryEle.textContent=e.summaryTitle),e.summaryIcon){const t=n(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.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((t,n)=>{t.classList.toggle(s,n===e&&("flowplayer-subtitles-menu"!==this.localName||!t.classList.contains(s)))})}unselect_item(){this.options.forEach(e=>{e.classList.remove(s)})}toggle_visibility(e){this.classList.toggle(i,e),this.menu.style.setProperty("display",e?"none":"block")}}function o(){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 l(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}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}document.addEventListener("click",(function(e){this.active_menu&&!e.composedPath().includes(this.active_menu)&&(o(),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 Speed{constructor(e){((e,t,n)=>{window.customElements.get(t)||window.customElements.define(t,n),e.customElements.get(t)||e.customElements.set(t,t)})(e,t,FlowplayerMenu)}init(s,i,o){let l=void 0;const u=n(o,t);u instanceof FlowplayerMenu&&u.setMenuAttrs({menuTitle:o.i18n("speed.menu_title"),summaryTitle:"1x",class:"fp-speed",options_event:Speed.events.OPTIONS}),o.on("config",()=>{const t=e(s,"speed",!0);if(t===l)return;if(l=t,0==t)return r(u,Speed.events.OPTIONS,[]);const n=e(s,"speed.options",Speed.DEFAULT_SPEED_OPTIONS),i=e(s,"speed.labels",[]);r(u,Speed.events.OPTIONS,Array.from({length:n.length}).map((e,t)=>{const s=n[t];return{text:i[t]||s+"x",onclick:a.bind(0,o,s)}}))}),o.on("mount",(function(){var e;null===(e=function(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}(o,o.hasState("is-tv")?"flowplayer-tv-menu":"flowplayer-control"))||void 0===e||e.append(u)}))}}function a(e,n){var s;const i=null===(s=e.root.querySelector(t))||void 0===s?void 0:s.summaryEle;i&&(i.textContent=n+"x"),isNaN(n)||(e.playbackRate=n)}return Speed.DEFAULT_SPEED_OPTIONS=[.2,.5,1,2,10],Speed.events={OPTIONS:"speed:options"},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;return"function"==typeof n?(n(t),t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t),t)}(window,Speed)}));
package/plugins/tizen.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.tizen=t())}(this,(function(){"use strict";var e={BACK:"Back",BACK1:"XF86Back",EXIT:"Exit",ENTER:"Enter",PLAY:"MediaPlay",PAUSE:"MediaPause",REWIND:"MediaRewind",FORWARD:"MediaFastForward",ARROW_LEFT:"ArrowLeft",ARROW_UP:"ArrowUp",ARROW_RIGHT:"ArrowRight",ARROW_DOWN:"ArrowDown"};const t="is-hovered",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 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}}class TvMenu extends FlowplayerComponent{constructor(e){super(e),this.classList.add("tv-menu")}append(e){super.append(e.menu)}is_empty(){const e=this.querySelectorAll(".fp-menu");return!(e&&Array.from(e).find(e=>"none"!==e.style.display))}}const s="is-tv-seeking";let i=void 0;function o(e,t){e.enqueueSeek(t)&&function(e){e.setState("is-kb-active",!0),clearTimeout(i),i=setTimeout((function(){e.setState("is-kb-active",!1)}),2500)}(e)}class Tizen extends class TvPlugin{constructor(e){this.umd=e,this.should_restart=!1,this.previous_current_time=0,((e,t,n)=>{window.customElements.get(t)||window.customElements.define(t,n),e.customElements.get(t)||e.customElements.set(t,t)})(e,"flowplayer-tv-menu",TvMenu)}init(e,t,s){s.setState("is-tv",!0),this.menu=n(s,"flowplayer-tv-menu"),t.append(this.menu)}keydown_listener(e,t,n,s,i){var o,r;const a=this.is_linearAd_on(n);return a||e!==t.ARROW_UP||s.classList.contains("is-open")||s.is_empty()?!a&&s.classList.contains("is-open")?this.menu_handler(e,t,s):void this.main_handler(e,t,n,a,i):(s.classList.add("is-open"),null===(r=null===(o=Array.from(s.querySelectorAll(".fp-menu")).find(e=>"block"===e.style.display))||void 0===o?void 0:o.querySelector("li"))||void 0===r?void 0:r.focus())}menu_handler(e,t,n){var s,i,o;if([t.BACK,t.BACK1,t.EXIT].includes(e))return n.classList.remove("is-open");if([t.ARROW_UP,t.ARROW_DOWN,t.ARROW_RIGHT,t.ARROW_LEFT,t.ENTER].includes(e)){const n=document.activeElement,r=null===(s=document.activeElement)||void 0===s?void 0:s.closest(".fp-menu");if(!n||!r)return;if(e===t.ENTER)return n.dispatchEvent(new Event("click"));if(e===t.ARROW_DOWN&&n.nextSibling)return n.nextSibling.focus();if(e===t.ARROW_UP&&n.previousSibling)return n.previousSibling.focus();if(e===t.ARROW_RIGHT&&r.nextSibling)return null===(i=r.nextSibling.querySelector("li"))||void 0===i?void 0:i.focus();if(e===t.ARROW_LEFT&&r.previousSibling)return null===(o=r.previousSibling.querySelector("li"))||void 0===o?void 0:o.focus()}}main_handler(e,t,n,s,i){switch(e){case t.ENTER:return this.on_enter(n,s);case t.PLAY:return this.on_play(n,s);case t.PAUSE:return n.togglePlay(!1);case t.FORWARD:case t.ARROW_RIGHT:return this.on_seek(n,i||10,s);case t.REWIND:case t.ARROW_LEFT:return this.on_seek(n,-(i||10),s);case t.BACK:case t.BACK2:case t.BACK1:case t.EXIT:return this.on_exit(n,s);case t.ARROW_DOWN:return this.on_arrow_down(n,s)}}on_play(e,n){return n?e.togglePlay(!0):(this.is_live_status_focused()&&!e.hasState(t)&&this.live_status_toggle_focus(e,!1),e.hasState(s)?void this.on_seek_end(e,!1):e.togglePlay(!0))}on_enter(e,t){var n;return t?e.togglePlay():this.is_live_status_focused()?(null===(n=e.root.querySelector(".fp-live-status"))||void 0===n||n.dispatchEvent(new Event("click")),this.live_status_toggle_focus(e,!1)):e.hasState(s)?this.on_seek_end(e,!1):e.togglePlay()}on_exit(e,n){return n?e.emit("fullscreen:exit"):this.is_live_status_focused()?this.live_status_toggle_focus(e,!1):e.hasState(s)?this.on_seek_end(e,!0):e.hasState(t)?e.setState(t,!1):e.emit("fullscreen:exit")}on_arrow_down(e,n){if(clearTimeout(this.hover_timeout),this.hover_timeout=setTimeout(()=>{e.setState(t,!1),this.live_status_toggle_focus(e,!1)},2e3),!e.hasState(t)&&!e.hasState("is-paused"))return e.setState(t,!0);n||!e.hasState("is-live")||e.hasState("no-timeline")||this.live_status_toggle_focus(e,!0)}on_seek(e,t,n){n||e.hasState("is-live")&&e.hasState("no-timeline")||(e.hasState(s)||(this.should_restart=!e.hasState("is-paused"),this.previous_current_time=e.currentTime),e.paused||e.togglePlay(!1),e.setState(s,!0),o(e,t))}on_seek_end(e,t){e.setState(s,!1),t&&(e.currentTime=this.previous_current_time),t&&!this.should_restart||e.togglePlay(!0)}live_status_toggle_focus(e,t){const n=e.root.querySelector(".fp-live-status");n&&(t?n.focus():n.blur())}is_live_status_focused(){var e;const t=document.activeElement;return null===(e=null==t?void 0:t.classList)||void 0===e?void 0:e.contains("fp-live-status")}is_linearAd_on(e){var t,n;return!(!e.hasState("ad-paused")&&!e.hasState("ad-playing")||!(null===(n=null===(t=null==e?void 0:e.ads)||void 0===t?void 0:t.adapter)||void 0===n?void 0:n._adLinear))}}{init(t,n,s){(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),s=/Android/.test(t)&&!/Firefox/.test(t),i=/^((?!chrome|android).)*safari/i.test(t),o=/SamsungBrowser/.test(t),r=o&&/SMART-TV/.test(t);return{controls:!n,video:function(t){return e&&document.createElement("video").canPlayType(t)},lang:e&&window.navigator.language,android:s,iphone:n,safari:i,ios:e&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,samsung:o,samsung_tv:o&&r,touch:"ontouchstart"in window,tizen:"tizen"in window,webOS:"webos"in window}})().tizen&&(super.init(t,n,s),document.addEventListener("keydown",n=>{setTimeout(()=>{var i;!n.defaultPrevented&&Object.values(e).includes(n.key)&&this.keydown_listener(n.key,e,s,this.menu,null===(i=t.tizen)||void 0===i?void 0:i.seek_step)},0)}))}}return Tizen.events={EXIT_FULLSCREEN:"fullscreen:exit"},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,Tizen),Tizen}));
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.tizen=t())}(this,(function(){"use strict";var e={BACK:"Back",BACK1:"XF86Back",EXIT:"Exit",ENTER:"Enter",PLAY:"MediaPlay",PAUSE:"MediaPause",REWIND:"MediaRewind",FORWARD:"MediaFastForward",ARROW_LEFT:"ArrowLeft",ARROW_UP:"ArrowUp",ARROW_RIGHT:"ArrowRight",ARROW_DOWN:"ArrowDown"};const t="is-hovered",s=(e,t)=>new(((e,t)=>{const s=e.get(t);if(!s)throw new Error(`no flowplayer component with the name ${t} exists`);const n=window.customElements.get(t);if(!n)throw new Error(`no default flowplayer component with the name ${t} exists`);const i=window.customElements.get(s);return"function"!=typeof i?n:i})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}class TvMenu extends FlowplayerComponent{constructor(e){super(e),this.classList.add("tv-menu"),e.on("src",()=>this.classList.remove("is-open"))}append(e){super.append(e.menu)}is_empty(){const e=this.querySelectorAll(".fp-menu");return!(e&&Array.from(e).find(e=>"none"!==e.style.display))}find_focusable_menu(e,t){const s=Array.from(this.children);return(t?s:s.slice(0).reverse()).find((t,s,n)=>"none"!==t.style.display&&s>n.indexOf(e))}}const n="is-tv-seeking";let i=void 0;function o(e,t){e.enqueueSeek(t)&&function(e){e.setState("is-kb-active",!0),clearTimeout(i),i=setTimeout((function(){e.setState("is-kb-active",!1)}),2500)}(e)}class Tizen extends class TvPlugin{constructor(e){this.umd=e,this.should_restart=!1,this.previous_current_time=0,((e,t,s)=>{window.customElements.get(t)||window.customElements.define(t,s),e.customElements.get(t)||e.customElements.set(t,t)})(e,"flowplayer-tv-menu",TvMenu)}init(e,t,n){n.setState("is-tv",!0),this.menu=s(n,"flowplayer-tv-menu"),t.append(this.menu)}keydown_listener(e,t,s,n,i){var o,r;const a=this.is_linearAd_on(s);return a||e!==t.ARROW_UP||n.classList.contains("is-open")||n.is_empty()?!a&&n.classList.contains("is-open")?this.menu_handler(e,t,n):void this.main_handler(e,t,s,a,i):(n.classList.add("is-open"),null===(r=null===(o=Array.from(n.querySelectorAll(".fp-menu")).find(e=>"block"===e.style.display))||void 0===o?void 0:o.querySelector("li"))||void 0===r?void 0:r.focus())}menu_handler(e,t,s){var n,i,o;if([t.BACK,t.BACK1,t.EXIT].includes(e))return s.classList.remove("is-open");if([t.ARROW_UP,t.ARROW_DOWN,t.ARROW_RIGHT,t.ARROW_LEFT,t.ENTER].includes(e)){const r=document.activeElement,a=null===(n=document.activeElement)||void 0===n?void 0:n.closest(".fp-menu");if(!r||!a)return;if(e===t.ENTER)return r.dispatchEvent(new Event("click"));if(e===t.ARROW_DOWN&&r.nextSibling)return r.nextSibling.focus();if(e===t.ARROW_UP&&r.previousSibling)return r.previousSibling.focus();if([t.ARROW_RIGHT,t.ARROW_LEFT].includes(e))return null===(o=null===(i=s.find_focusable_menu(a,e===t.ARROW_RIGHT))||void 0===i?void 0:i.querySelector("li"))||void 0===o?void 0:o.focus()}}main_handler(e,t,s,n,i){switch(e){case t.ENTER:return this.on_enter(s,n);case t.PLAY:return this.on_play(s,n);case t.PAUSE:return s.togglePlay(!1);case t.FORWARD:case t.ARROW_RIGHT:return this.on_seek(s,i||10,n);case t.REWIND:case t.ARROW_LEFT:return this.on_seek(s,-(i||10),n);case t.BACK:case t.BACK2:case t.BACK1:case t.EXIT:return this.on_exit(s,n);case t.ARROW_DOWN:return this.on_arrow_down(s,n)}}on_play(e,s){return s?e.togglePlay(!0):(this.is_live_status_focused()&&!e.hasState(t)&&this.live_status_toggle_focus(e,!1),e.hasState(n)?void this.on_seek_end(e,!1):e.togglePlay(!0))}on_enter(e,t){var s;return t?e.togglePlay():this.is_live_status_focused()?(null===(s=e.root.querySelector(".fp-live-status"))||void 0===s||s.dispatchEvent(new Event("click")),this.live_status_toggle_focus(e,!1)):e.hasState(n)?this.on_seek_end(e,!1):e.togglePlay()}on_exit(e,s){return s?e.emit("fullscreen:exit"):this.is_live_status_focused()?this.live_status_toggle_focus(e,!1):e.hasState(n)?this.on_seek_end(e,!0):e.hasState(t)?e.setState(t,!1):e.emit("fullscreen:exit")}on_arrow_down(e,s){if(clearTimeout(this.hover_timeout),this.hover_timeout=setTimeout(()=>{e.setState(t,!1),this.live_status_toggle_focus(e,!1)},2e3),!e.hasState(t)&&!e.hasState("is-paused"))return e.setState(t,!0);s||!e.hasState("is-live")||e.hasState("no-timeline")||this.live_status_toggle_focus(e,!0)}on_seek(e,t,s){s||e.hasState("is-live")&&e.hasState("no-timeline")||(e.hasState(n)||(this.should_restart=!e.hasState("is-paused"),this.previous_current_time=e.currentTime),e.paused||e.togglePlay(!1),e.setState(n,!0),o(e,t))}on_seek_end(e,t){e.setState(n,!1),t&&(e.currentTime=this.previous_current_time),t&&!this.should_restart||e.togglePlay(!0)}live_status_toggle_focus(e,t){const s=e.root.querySelector(".fp-live-status");s&&(t?s.focus():s.blur())}is_live_status_focused(){var e;const t=document.activeElement;return null===(e=null==t?void 0:t.classList)||void 0===e?void 0:e.contains("fp-live-status")}is_linearAd_on(e){var t,s;return!(!e.hasState("ad-paused")&&!e.hasState("ad-playing")||!(null===(s=null===(t=null==e?void 0:e.ads)||void 0===t?void 0:t.adapter)||void 0===s?void 0:s._adLinear))}}{init(t,s,n){(function(){const e="undefined"!=typeof document&&"undefined"!=typeof window,t=e?navigator.userAgent:"",s=/iP(hone|od)/i.test(t)&&!/iPad/.test(t)&&!/IEMobile/i.test(t),n=/Android/.test(t)&&!/Firefox/.test(t),i=/^((?!chrome|android).)*safari/i.test(t),o=/SamsungBrowser/.test(t),r=o&&/SMART-TV/.test(t);return{controls:!s,video:function(t){return e&&document.createElement("video").canPlayType(t)},lang:e&&window.navigator.language,android:n,iphone:s,safari:i,ios:e&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,samsung:o,samsung_tv:o&&r,touch:"ontouchstart"in window,tizen:"tizen"in window,webOS:"webos"in window}})().tizen&&(super.init(t,s,n),document.addEventListener("keydown",s=>{setTimeout(()=>{var i;!s.defaultPrevented&&Object.values(e).includes(s.key)&&this.keydown_listener(s.key,e,n,this.menu,null===(i=t.tizen)||void 0===i?void 0:i.seek_step)},0)}))}}return Tizen.events={EXIT_FULLSCREEN:"fullscreen:exit"},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 s=e.flowplayer;"function"==typeof s?s(t):(Array.isArray(s.extensions)||(s.extensions=[]),~s.extensions.indexOf(t)||s.extensions.push(t))}(window,Tizen),Tizen}));
package/plugins/webos.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.webos=t())}(this,(function(){"use strict";const e="is-hovered",t=(e,t)=>new(((e,t)=>{const s=e.get(t);if(!s)throw new Error(`no flowplayer component with the name ${t} exists`);const n=window.customElements.get(t);if(!n)throw new Error(`no default flowplayer component with the name ${t} exists`);const i=window.customElements.get(s);return"function"!=typeof i?n:i})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}class TvMenu extends FlowplayerComponent{constructor(e){super(e),this.classList.add("tv-menu")}append(e){super.append(e.menu)}is_empty(){const e=this.querySelectorAll(".fp-menu");return!(e&&Array.from(e).find(e=>"none"!==e.style.display))}}const s="is-tv-seeking";let n=void 0;function i(e,t){e.enqueueSeek(t)&&function(e){e.setState("is-kb-active",!0),clearTimeout(n),n=setTimeout((function(){e.setState("is-kb-active",!1)}),2500)}(e)}var o={EXIT:461,ENTER:13,PLAY:415,PAUSE:19,REWIND:412,FORWARD:417,ARROW_LEFT:37,ARROW_UP:38,ARROW_RIGHT:39,ARROW_DOWN:40};class Webos extends class TvPlugin{constructor(e){this.umd=e,this.should_restart=!1,this.previous_current_time=0,((e,t,s)=>{window.customElements.get(t)||window.customElements.define(t,s),e.customElements.get(t)||e.customElements.set(t,t)})(e,"flowplayer-tv-menu",TvMenu)}init(e,s,n){n.setState("is-tv",!0),this.menu=t(n,"flowplayer-tv-menu"),s.append(this.menu)}keydown_listener(e,t,s,n,i){var o,r;const a=this.is_linearAd_on(s);return a||e!==t.ARROW_UP||n.classList.contains("is-open")||n.is_empty()?!a&&n.classList.contains("is-open")?this.menu_handler(e,t,n):void this.main_handler(e,t,s,a,i):(n.classList.add("is-open"),null===(r=null===(o=Array.from(n.querySelectorAll(".fp-menu")).find(e=>"block"===e.style.display))||void 0===o?void 0:o.querySelector("li"))||void 0===r?void 0:r.focus())}menu_handler(e,t,s){var n,i,o;if([t.BACK,t.BACK1,t.EXIT].includes(e))return s.classList.remove("is-open");if([t.ARROW_UP,t.ARROW_DOWN,t.ARROW_RIGHT,t.ARROW_LEFT,t.ENTER].includes(e)){const s=document.activeElement,r=null===(n=document.activeElement)||void 0===n?void 0:n.closest(".fp-menu");if(!s||!r)return;if(e===t.ENTER)return s.dispatchEvent(new Event("click"));if(e===t.ARROW_DOWN&&s.nextSibling)return s.nextSibling.focus();if(e===t.ARROW_UP&&s.previousSibling)return s.previousSibling.focus();if(e===t.ARROW_RIGHT&&r.nextSibling)return null===(i=r.nextSibling.querySelector("li"))||void 0===i?void 0:i.focus();if(e===t.ARROW_LEFT&&r.previousSibling)return null===(o=r.previousSibling.querySelector("li"))||void 0===o?void 0:o.focus()}}main_handler(e,t,s,n,i){switch(e){case t.ENTER:return this.on_enter(s,n);case t.PLAY:return this.on_play(s,n);case t.PAUSE:return s.togglePlay(!1);case t.FORWARD:case t.ARROW_RIGHT:return this.on_seek(s,i||10,n);case t.REWIND:case t.ARROW_LEFT:return this.on_seek(s,-(i||10),n);case t.BACK:case t.BACK2:case t.BACK1:case t.EXIT:return this.on_exit(s,n);case t.ARROW_DOWN:return this.on_arrow_down(s,n)}}on_play(t,n){return n?t.togglePlay(!0):(this.is_live_status_focused()&&!t.hasState(e)&&this.live_status_toggle_focus(t,!1),t.hasState(s)?void this.on_seek_end(t,!1):t.togglePlay(!0))}on_enter(e,t){var n;return t?e.togglePlay():this.is_live_status_focused()?(null===(n=e.root.querySelector(".fp-live-status"))||void 0===n||n.dispatchEvent(new Event("click")),this.live_status_toggle_focus(e,!1)):e.hasState(s)?this.on_seek_end(e,!1):e.togglePlay()}on_exit(t,n){return n?t.emit("fullscreen:exit"):this.is_live_status_focused()?this.live_status_toggle_focus(t,!1):t.hasState(s)?this.on_seek_end(t,!0):t.hasState(e)?t.setState(e,!1):t.emit("fullscreen:exit")}on_arrow_down(t,s){if(clearTimeout(this.hover_timeout),this.hover_timeout=setTimeout(()=>{t.setState(e,!1),this.live_status_toggle_focus(t,!1)},2e3),!t.hasState(e)&&!t.hasState("is-paused"))return t.setState(e,!0);s||!t.hasState("is-live")||t.hasState("no-timeline")||this.live_status_toggle_focus(t,!0)}on_seek(e,t,n){n||e.hasState("is-live")&&e.hasState("no-timeline")||(e.hasState(s)||(this.should_restart=!e.hasState("is-paused"),this.previous_current_time=e.currentTime),e.paused||e.togglePlay(!1),e.setState(s,!0),i(e,t))}on_seek_end(e,t){e.setState(s,!1),t&&(e.currentTime=this.previous_current_time),t&&!this.should_restart||e.togglePlay(!0)}live_status_toggle_focus(e,t){const s=e.root.querySelector(".fp-live-status");s&&(t?s.focus():s.blur())}is_live_status_focused(){var e;const t=document.activeElement;return null===(e=null==t?void 0:t.classList)||void 0===e?void 0:e.contains("fp-live-status")}is_linearAd_on(e){var t,s;return!(!e.hasState("ad-paused")&&!e.hasState("ad-playing")||!(null===(s=null===(t=null==e?void 0:e.ads)||void 0===t?void 0:t.adapter)||void 0===s?void 0:s._adLinear))}}{init(e,t,s){(function(){const e="undefined"!=typeof document&&"undefined"!=typeof window,t=e?navigator.userAgent:"",s=/iP(hone|od)/i.test(t)&&!/iPad/.test(t)&&!/IEMobile/i.test(t),n=/Android/.test(t)&&!/Firefox/.test(t),i=/^((?!chrome|android).)*safari/i.test(t),o=/SamsungBrowser/.test(t),r=o&&/SMART-TV/.test(t);return{controls:!s,video:function(t){return e&&document.createElement("video").canPlayType(t)},lang:e&&window.navigator.language,android:n,iphone:s,safari:i,ios:e&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,samsung:o,samsung_tv:o&&r,touch:"ontouchstart"in window,tizen:"tizen"in window,webOS:"webos"in window}})().webOS&&(super.init(e,t,s),document.addEventListener("keydown",t=>{setTimeout(()=>{var n;!t.defaultPrevented&&Object.values(o).includes(t.keyCode)&&this.keydown_listener(t.keyCode,o,s,this.menu,null===(n=e.webos)||void 0===n?void 0:n.seek_step)},0)}))}}return Webos.events={EXIT_FULLSCREEN:"fullscreen:exit"},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 s=e.flowplayer;"function"==typeof s?s(t):(Array.isArray(s.extensions)||(s.extensions=[]),~s.extensions.indexOf(t)||s.extensions.push(t))}(window,Webos),Webos}));
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.webos=t())}(this,(function(){"use strict";const e="is-hovered",t=(e,t)=>new(((e,t)=>{const s=e.get(t);if(!s)throw new Error(`no flowplayer component with the name ${t} exists`);const n=window.customElements.get(t);if(!n)throw new Error(`no default flowplayer component with the name ${t} exists`);const i=window.customElements.get(s);return"function"!=typeof i?n:i})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}class TvMenu extends FlowplayerComponent{constructor(e){super(e),this.classList.add("tv-menu"),e.on("src",()=>this.classList.remove("is-open"))}append(e){super.append(e.menu)}is_empty(){const e=this.querySelectorAll(".fp-menu");return!(e&&Array.from(e).find(e=>"none"!==e.style.display))}find_focusable_menu(e,t){const s=Array.from(this.children);return(t?s:s.slice(0).reverse()).find((t,s,n)=>"none"!==t.style.display&&s>n.indexOf(e))}}const s="is-tv-seeking";let n=void 0;function i(e,t){e.enqueueSeek(t)&&function(e){e.setState("is-kb-active",!0),clearTimeout(n),n=setTimeout((function(){e.setState("is-kb-active",!1)}),2500)}(e)}var o={EXIT:461,ENTER:13,PLAY:415,PAUSE:19,REWIND:412,FORWARD:417,ARROW_LEFT:37,ARROW_UP:38,ARROW_RIGHT:39,ARROW_DOWN:40};class Webos extends class TvPlugin{constructor(e){this.umd=e,this.should_restart=!1,this.previous_current_time=0,((e,t,s)=>{window.customElements.get(t)||window.customElements.define(t,s),e.customElements.get(t)||e.customElements.set(t,t)})(e,"flowplayer-tv-menu",TvMenu)}init(e,s,n){n.setState("is-tv",!0),this.menu=t(n,"flowplayer-tv-menu"),s.append(this.menu)}keydown_listener(e,t,s,n,i){var o,r;const a=this.is_linearAd_on(s);return a||e!==t.ARROW_UP||n.classList.contains("is-open")||n.is_empty()?!a&&n.classList.contains("is-open")?this.menu_handler(e,t,n):void this.main_handler(e,t,s,a,i):(n.classList.add("is-open"),null===(r=null===(o=Array.from(n.querySelectorAll(".fp-menu")).find(e=>"block"===e.style.display))||void 0===o?void 0:o.querySelector("li"))||void 0===r?void 0:r.focus())}menu_handler(e,t,s){var n,i,o;if([t.BACK,t.BACK1,t.EXIT].includes(e))return s.classList.remove("is-open");if([t.ARROW_UP,t.ARROW_DOWN,t.ARROW_RIGHT,t.ARROW_LEFT,t.ENTER].includes(e)){const r=document.activeElement,a=null===(n=document.activeElement)||void 0===n?void 0:n.closest(".fp-menu");if(!r||!a)return;if(e===t.ENTER)return r.dispatchEvent(new Event("click"));if(e===t.ARROW_DOWN&&r.nextSibling)return r.nextSibling.focus();if(e===t.ARROW_UP&&r.previousSibling)return r.previousSibling.focus();if([t.ARROW_RIGHT,t.ARROW_LEFT].includes(e))return null===(o=null===(i=s.find_focusable_menu(a,e===t.ARROW_RIGHT))||void 0===i?void 0:i.querySelector("li"))||void 0===o?void 0:o.focus()}}main_handler(e,t,s,n,i){switch(e){case t.ENTER:return this.on_enter(s,n);case t.PLAY:return this.on_play(s,n);case t.PAUSE:return s.togglePlay(!1);case t.FORWARD:case t.ARROW_RIGHT:return this.on_seek(s,i||10,n);case t.REWIND:case t.ARROW_LEFT:return this.on_seek(s,-(i||10),n);case t.BACK:case t.BACK2:case t.BACK1:case t.EXIT:return this.on_exit(s,n);case t.ARROW_DOWN:return this.on_arrow_down(s,n)}}on_play(t,n){return n?t.togglePlay(!0):(this.is_live_status_focused()&&!t.hasState(e)&&this.live_status_toggle_focus(t,!1),t.hasState(s)?void this.on_seek_end(t,!1):t.togglePlay(!0))}on_enter(e,t){var n;return t?e.togglePlay():this.is_live_status_focused()?(null===(n=e.root.querySelector(".fp-live-status"))||void 0===n||n.dispatchEvent(new Event("click")),this.live_status_toggle_focus(e,!1)):e.hasState(s)?this.on_seek_end(e,!1):e.togglePlay()}on_exit(t,n){return n?t.emit("fullscreen:exit"):this.is_live_status_focused()?this.live_status_toggle_focus(t,!1):t.hasState(s)?this.on_seek_end(t,!0):t.hasState(e)?t.setState(e,!1):t.emit("fullscreen:exit")}on_arrow_down(t,s){if(clearTimeout(this.hover_timeout),this.hover_timeout=setTimeout(()=>{t.setState(e,!1),this.live_status_toggle_focus(t,!1)},2e3),!t.hasState(e)&&!t.hasState("is-paused"))return t.setState(e,!0);s||!t.hasState("is-live")||t.hasState("no-timeline")||this.live_status_toggle_focus(t,!0)}on_seek(e,t,n){n||e.hasState("is-live")&&e.hasState("no-timeline")||(e.hasState(s)||(this.should_restart=!e.hasState("is-paused"),this.previous_current_time=e.currentTime),e.paused||e.togglePlay(!1),e.setState(s,!0),i(e,t))}on_seek_end(e,t){e.setState(s,!1),t&&(e.currentTime=this.previous_current_time),t&&!this.should_restart||e.togglePlay(!0)}live_status_toggle_focus(e,t){const s=e.root.querySelector(".fp-live-status");s&&(t?s.focus():s.blur())}is_live_status_focused(){var e;const t=document.activeElement;return null===(e=null==t?void 0:t.classList)||void 0===e?void 0:e.contains("fp-live-status")}is_linearAd_on(e){var t,s;return!(!e.hasState("ad-paused")&&!e.hasState("ad-playing")||!(null===(s=null===(t=null==e?void 0:e.ads)||void 0===t?void 0:t.adapter)||void 0===s?void 0:s._adLinear))}}{init(e,t,s){(function(){const e="undefined"!=typeof document&&"undefined"!=typeof window,t=e?navigator.userAgent:"",s=/iP(hone|od)/i.test(t)&&!/iPad/.test(t)&&!/IEMobile/i.test(t),n=/Android/.test(t)&&!/Firefox/.test(t),i=/^((?!chrome|android).)*safari/i.test(t),o=/SamsungBrowser/.test(t),r=o&&/SMART-TV/.test(t);return{controls:!s,video:function(t){return e&&document.createElement("video").canPlayType(t)},lang:e&&window.navigator.language,android:n,iphone:s,safari:i,ios:e&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,samsung:o,samsung_tv:o&&r,touch:"ontouchstart"in window,tizen:"tizen"in window,webOS:"webos"in window}})().webOS&&(super.init(e,t,s),document.addEventListener("keydown",t=>{setTimeout(()=>{var n;!t.defaultPrevented&&Object.values(o).includes(t.keyCode)&&this.keydown_listener(t.keyCode,o,s,this.menu,null===(n=e.webos)||void 0===n?void 0:n.seek_step)},0)}))}}return Webos.events={EXIT_FULLSCREEN:"fullscreen:exit"},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 s=e.flowplayer;"function"==typeof s?s(t):(Array.isArray(s.extensions)||(s.extensions=[]),~s.extensions.indexOf(t)||s.extensions.push(t))}(window,Webos),Webos}));