@playkit-js/playkit-js-youtube 2.2.2 → 2.2.3

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/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### 2.2.3 (2025-09-11)
6
+
5
7
  ### 2.2.2 (2025-04-03)
6
8
 
7
9
  ### 2.2.1 (2025-04-02)
@@ -1,2 +1,2 @@
1
- var playkit;(()=>{var e={42:(e,t,n)=>{var i=n(292),a=n(791);"string"==typeof(a=a.__esModule?a.default:a)&&(a=[[e.id,a,""]]),i(a,{attributes:{id:"@playkit-js/playkit-js-youtube"},insert:function(e){window.kalturaGlobalConfig&&"string"==typeof window.kalturaGlobalConfig.stylesNonce&&e.setAttribute("nonce",window.kalturaGlobalConfig.stylesNonce),document.head.appendChild(e)},singleton:!1}),e.exports=a.locals||{}},278:e=>{"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var n=function(e,t){var n,i,a,r=e[1]||"",o=e[3];if(!o)return r;if(t&&"function"==typeof btoa){var s=(n=o,i=btoa(unescape(encodeURIComponent(JSON.stringify(n)))),a="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(i),"/*# ".concat(a," */")),u=o.sources.map((function(e){return"/*# sourceURL=".concat(o.sourceRoot||"").concat(e," */")}));return[r].concat(u).concat([s]).join("\n")}return[r].join("\n")}(t,e);return t[2]?"@media ".concat(t[2]," {").concat(n,"}"):n})).join("")},t.i=function(e,n,i){"string"==typeof e&&(e=[[null,e,""]]);var a={};if(i)for(var r=0;r<this.length;r++){var o=this[r][0];null!=o&&(a[o]=!0)}for(var s=0;s<e.length;s++){var u=[].concat(e[s]);i&&a[u[0]]||(n&&(u[2]?u[2]="".concat(n," and ").concat(u[2]):u[2]=n),t.push(u))}},t}},292:(e,t,n)=>{"use strict";var i,a=function(){var e={};return function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(e){n=null}e[t]=n}return e[t]}}(),r=[];function o(e){for(var t=-1,n=0;n<r.length;n++)if(r[n].identifier===e){t=n;break}return t}function s(e,t){for(var n={},i=[],a=0;a<e.length;a++){var s=e[a],u=t.base?s[0]+t.base:s[0],c=n[u]||0,l="".concat(u," ").concat(c);n[u]=c+1;var d=o(l),p={css:s[1],media:s[2],sourceMap:s[3]};-1!==d?(r[d].references++,r[d].updater(p)):r.push({identifier:l,updater:f(p,t),references:1}),i.push(l)}return i}function u(e){var t=document.createElement("style"),i=e.attributes||{};if(void 0===i.nonce){var r=n.nc;r&&(i.nonce=r)}if(Object.keys(i).forEach((function(e){t.setAttribute(e,i[e])})),"function"==typeof e.insert)e.insert(t);else{var o=a(e.insert||"head");if(!o)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");o.appendChild(t)}return t}var c,l=(c=[],function(e,t){return c[e]=t,c.filter(Boolean).join("\n")});function d(e,t,n,i){var a=n?"":i.media?"@media ".concat(i.media," {").concat(i.css,"}"):i.css;if(e.styleSheet)e.styleSheet.cssText=l(t,a);else{var r=document.createTextNode(a),o=e.childNodes;o[t]&&e.removeChild(o[t]),o.length?e.insertBefore(r,o[t]):e.appendChild(r)}}function p(e,t,n){var i=n.css,a=n.media,r=n.sourceMap;if(a?e.setAttribute("media",a):e.removeAttribute("media"),r&&btoa&&(i+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(r))))," */")),e.styleSheet)e.styleSheet.cssText=i;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(i))}}var h=null,y=0;function f(e,t){var n,i,a;if(t.singleton){var r=y++;n=h||(h=u(t)),i=d.bind(null,n,r,!1),a=d.bind(null,n,r,!0)}else n=u(t),i=p.bind(null,n,t),a=function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(n)};return i(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;i(e=t)}else a()}}e.exports=function(e,t){(t=t||{}).singleton||"boolean"==typeof t.singleton||(t.singleton=(void 0===i&&(i=Boolean(window&&document&&document.all&&!window.atob)),i));var n=s(e=e||[],t);return function(e){if(e=e||[],"[object Array]"===Object.prototype.toString.call(e)){for(var i=0;i<n.length;i++){var a=o(n[i]);r[a].references--}for(var u=s(e,t),c=0;c<n.length;c++){var l=o(n[c]);0===r[l].references&&(r[l].updater(),r.splice(l,1))}n=u}}}},773:e=>{"use strict";e.exports=KalturaPlayer},791:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>r});var i=n(278),a=n.n(i)()(!0);a.push([e.id,".playkit-iOS .playkit-engine-youtube,\n.playkit-Mac-OS .playkit-engine-youtube {\n object-fit: fill;\n}\n","",{version:3,sources:["style.css"],names:[],mappings:"AAAA;;EAEE,gBAAgB;AAClB",file:"style.css",sourcesContent:[".playkit-iOS .playkit-engine-youtube,\n.playkit-Mac-OS .playkit-engine-youtube {\n object-fit: fill;\n}\n"]}]);const r=a},948:(e,t,n)=>{"use strict";t.L=void 0;const i=n(773),a="YouTubeClipChapter";class r extends i.BasePlugin{constructor(e,t,n){super(e,t,n)}get timelineManager(){return this.player.getService("timeline")}static isValid(){return!0}loadMedia(){this.eventManager.listenOnce(this.player,this.player.Event.Core.SOURCE_SELECTED,(()=>{if(this.player.engineType===this.player.EngineType.YOUTUBE&&this.timelineManager){const{seekFrom:e,clipTo:t,duration:n}=this.player.config.sources,i=!!(t&&n&&t<n);(e||i)&&(this.timelineManager.disableChapters(),e&&this.timelineManager.addKalturaCuePoint(e,a,0),i&&this.timelineManager.addKalturaCuePoint(t,a,1))}}))}reset(){}destroy(){}}t.L=r}},t={};function n(i){var a=t[i];if(void 0!==a)return a.exports;var r=t[i]={id:i,exports:{}};return e[i](r,r.exports,n),r.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.nc=void 0;var i={};(()=>{"use strict";n.r(i),n.d(i,{Engine:()=>s,NAME:()=>d,Plugin:()=>c.L,VERSION:()=>l});const e=KalturaPlayer.core;function t(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function a(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var o={controls:0,autoplay:0,origin:window.location.origin,iv_load_policy:3,disablekb:1,modestbranding:1,playsinline:1,rel:0,fs:0,cc_load_policy:1},s=function(n){var i,s;function u(t,i){var o;return r(a(o=n.call(this)||this),"_isAdaptiveBitrate",!0),r(a(o),"_loaded",!1),r(a(o),"_isSeeking",!1),r(a(o),"_firstPlaying",!0),r(a(o),"_currentState",null),r(a(o),"_playerTracks",[]),r(a(o),"_clipToInterval",null),o._eventManager=new e.EventManager,o._createVideoElement(),o._init(t,i),o}s=n,(i=u).prototype=Object.create(s.prototype),i.prototype.constructor=i,i.__proto__=s,u.isSupported=function(){return!0},u.createEngine=function(e,t){return new this(e,t)},u.canPlaySource=function(e){var t="string"==typeof e.mimetype&&"video/youtube"===e.mimetype.toLowerCase();return u._logger.debug("canPlayType result for mimeType: "+e.mimetype+" is "+t.toString()),t},u.runCapabilities=function(){},u.getCapabilities=function(){var e,t=!1;"connection"in navigator&&navigator.connection&&(t=!!navigator.connection.saveData);var n=((e={})[u.id]={autoplay:!1,mutedAutoPlay:!t},e);return Promise.resolve(n)},u.prepareVideoElement=function(){u._logger.debug("Prepare the video element for playing not supported")};var c,l,d=u.prototype;return d.restore=function(e,t){this.reset(),this._init(e,t)},d._reset=function(){this._stopSeekTargetWatchDog(),this._stopPlayingWatchDog(),this.detach(),this._playerReady()&&this._api.stopVideo&&this._api.stopVideo(),this._loaded=!1,this._firstPlaying=!0,this._isSeeking=!1,this._isAdaptiveBitrate=!0,this._playerTracks=[],this._currentState=null,this._clipToInterval&&(clearInterval(this._clipToInterval),this._clipToInterval=null)},d.reset=function(){this._reset(),this._eventManager.removeAll(),this._api&&this._api.destroy&&this._api.destroy()},d.destroy=function(){this._reset(),this._api&&this._api.destroy&&this._api.destroy(),this._eventManager.destroy()},d.attach=function(){},d.detach=function(){},d.getVideoElement=function(){return this._el},d.selectVideoTrack=function(t){this._api&&t instanceof e.VideoTrack&&(!t.active||this.isAdaptiveBitrateEnabled())&&(this.isAdaptiveBitrateEnabled()&&this.dispatchEvent(e.EventType.ABR_MODE_CHANGED,{mode:"manual"}),this._isAdaptiveBitrate=!1,this._api.setPlaybackQuality(t.label))},d.selectAudioTrack=function(e){u._logger.info("audio track switching not supported, cannot switch to "+e.language)},d.selectTextTrack=function(e){u._logger.info("text track switching not supported, cannot switch to "+e.language)},d.hideTextTrack=function(){},d.enableAdaptiveBitrate=function(){this._api&&(this._api.setPlaybackQuality("default"),this._isAdaptiveBitrate=!0)},d.isAdaptiveBitrateEnabled=function(){return this._isAdaptiveBitrate},d.seekToLiveEdge=function(){},d.attachMediaSource=function(){},d.detachMediaSource=function(){},d.getStartTimeOfDvrWindow=function(){return 0},d.isLive=function(){return!1},d.play=function(){this._api&&(this.currentTime===this.duration&&(this.currentTime=0),this._api.playVideo())},d.pause=function(){this._api&&this._api.pauseVideo&&this._api.pauseVideo()},d.load=function(e){var t=this;return this._sdkLoaded.then((function(){var n={videoId:t._source.url,startSeconds:e&&e>0?e:0};t._api.cueVideoById(n),t._loaded=!0})).catch((function(e){return Promise.reject(e)})),this._videoLoaded={},this._videoLoaded.promise=new Promise((function(e,n){t._videoLoaded.resolve=e,t._videoLoaded.reject=n})),this._videoLoaded.promise},d._playerReady=function(){return!(!this._api||!this._loaded)},d._parseVideoTracks=function(){var t=this._api.getAvailableQualityLevels(),n=this._api.getPlaybackQuality(),i=[];return t.forEach((function(t,a){var r={active:n===t,label:t,bandwidth:0,width:a+1,height:a+1,language:"",index:a};i.push(new e.VideoTrack(r))})),i},d._startSeekTargetWatchDog=function(){var t=this,n=this.currentTime;this._stopSeekTargetWatchDog(),this._seekTargetIntervalId=setInterval((function(){t.paused&&t._isSeeking?t.currentTime!==n&&(t.dispatchEvent(new e.FakeEvent(e.EventType.TIME_UPDATE)),t.dispatchEvent(new e.FakeEvent(e.EventType.SEEKED)),t._isSeeking=!1):t._stopSeekTargetWatchDog()}),250)},d._stopSeekTargetWatchDog=function(){this._seekTargetIntervalId&&(clearInterval(this._seekTargetIntervalId),this._seekTargetIntervalId=null)},d._init=function(t,n){var i=this;this._source=t,this._config=n,this._api=null,this._videoLoaded=null,this._playingIntervalId=null;var a=function(t){var n=new e.Error(e.Error.Severity.CRITICAL,e.Error.Category.PLAYER,e.Error.Code.LOAD_FAILED,t);i.dispatchEvent(new e.FakeEvent(e.EventType.ERROR,n))};this._sdkLoaded=new Promise((function(e,t){i._apiReady=function(){(i._config.playback.muted||i._config.playback.autoplay)&&(i._api.mute&&i._api.mute(),i._muted=!0),e()},i._apiError=function(e){var n=i._getYoutubeErrorCodeData(e.data);a(n),t(e.data)}})),this._loadYouTubeIframeAPI().then((function(){i._loadYouTubePlayer()})).catch((function(e){a(e)}))},d._createVideoElement=function(){var t=this._el=e.Utils.Dom.createElement("div");e.Utils.Dom.setAttribute(t,"id",e.Utils.Generator.uniqueId(5)),e.Utils.Dom.setAttribute(t,"tabindex","-1")},d._getYoutubeErrorCodeData=function(e){switch(e){case 2:return{code:e,message:"Invalid params"};case 5:return{code:e,message:"Error while trying to play the video"};case 100:return{code:e,message:"Video not found"};case 101:case 150:return{code:e,message:"The owner of the requested video does not allow it to be played in embedded players"};default:return{code:e,message:"Unknown error"}}},d._loadYouTubePlayer=function(){var t=this,n=function(){var n={playerVars:o,events:{onReady:t._apiReady,onError:t._apiError,onStateChange:function(e){return t._onPlayerStateChange(e)},onPlaybackQualityChange:function(e){return t._onPlaybackQualityChange(e)},onVolumeChange:function(){return t.dispatchEvent(new e.FakeEvent(e.EventType.VOLUME_CHANGE))}}};if(n.playerVars.playsinline=t._config.playback.playsinline?1:0,n.playerVars.autoplay=t._config.playback.autoplay?1:0,e.Utils.Object.hasPropertyPath(t._config,"playback.options.youtube")){var i=t._config.playback.options.youtube;e.Utils.Object.mergeDeep(n.playerVars,i.playerVars)}t._api=new window.YT.Player(t._el.id,n)};if(this._api)return this._apiReady();window&&window.YT&&window.YT.Player?n():window.onYouTubeIframeAPIReady=n},d._loadYouTubeIframeAPI=function(){var t=this;return new Promise((function(n,i){if(window&&window.YT&&window.YT.Player)return n();var a=e.Utils.Dom.createElement("script"),r="https://www.youtube.com/iframe_api";e.Utils.Object.hasPropertyPath(t._config,"playback.options.youtube")&&t._config.playback.options.youtube.iframeApi&&(r=t._config.playback.options.youtube.iframeApi),a.src=r,a.async=!0,a.onload=function(){n()},a.onerror=function(){i({message:"Youtube Iframe API loading failed: "+r})};var o=document.getElementsByTagName("script")[0];o&&o.parentNode&&o.parentNode.insertBefore(a,o)}))},d._getPlayerStateKey=function(e){var t=window.YT.PlayerState;return Object.keys(t).find((function(n){return t[n]===e}))||"UNKNOWN"},d._onPlayerStateChange=function(e){var t=window.YT.PlayerState,n=e.data;if(u._logger.info("player state changed from "+this._getPlayerStateKey(this._currentState)+" to "+this._getPlayerStateKey(n)),n!==this._currentState)switch(this._currentState=n,this._currentState){case t.UNSTARTED:this._handleLoaded();break;case t.ENDED:this._onEnded();break;case t.PLAYING:this._firstPlaying&&this._handleFirstPlaying(),this._onPlaying();break;case t.PAUSED:this._onPaused();break;case t.BUFFERING:this._onBuffering();case t.CUED:}},d._onPlaybackQualityChange=function(t){var n=this._playerTracks.find((function(n){return n instanceof e.VideoTrack&&n.label===t.data}));this.dispatchEvent(e.EventType.VIDEO_TRACK_CHANGED,{selectedVideoTrack:n})},d._handleClipTo=function(){var e=this;this._clipToInterval&&clearInterval(this._clipToInterval);var t=this._config.sources.clipTo;this._api&&t&&this.currentTime<t&&(this._clipToInterval=setInterval((function(){e._api.getCurrentTime()>=t&&(e._api.pauseVideo(),clearInterval(e._clipToInterval))}),200))},d._onPlaying=function(){this._handleClipTo(),this.dispatchEvent(new e.FakeEvent(e.EventType.PLAY)),this.dispatchEvent(new e.FakeEvent(e.EventType.PLAYING)),this._startPlayingWatchDog(),this._isSeeking&&(this._isSeeking=!1,this.dispatchEvent(new e.FakeEvent(e.EventType.TIME_UPDATE)),this.dispatchEvent(new e.FakeEvent(e.EventType.SEEKED)))},d._handleLoaded=function(){this._loaded&&(this.dispatchEvent(new e.FakeEvent(e.EventType.LOADED_METADATA)),this.dispatchEvent(new e.FakeEvent(e.EventType.LOADED_DATA)),this._videoLoaded.resolve({tracks:this._playerTracks}))},d._handleFirstPlaying=function(){this._firstPlaying=!1,this.dispatchEvent(new e.FakeEvent(e.EventType.DURATION_CHANGE));var t=this._config.sources,n=t.seekFrom,i=t.captions;this._api&&n&&this._api.seekTo(n),this._api&&i&&i.length>0&&this._api.setOption("captions","track",{})},d._onBuffering=function(){this._stopPlayingWatchDog(),this.dispatchEvent(new e.FakeEvent(e.EventType.WAITING))},d._onPaused=function(){this._isSeeking&&(this._isSeeking=!1),this._stopPlayingWatchDog(),this.dispatchEvent(new e.FakeEvent(e.EventType.TIME_UPDATE)),this.dispatchEvent(new e.FakeEvent(e.EventType.PAUSE))},d._onEnded=function(){this._stopPlayingWatchDog(),this.dispatchEvent(new e.FakeEvent(e.EventType.TIME_UPDATE)),this.dispatchEvent(new e.FakeEvent(e.EventType.PAUSE)),this.dispatchEvent(new e.FakeEvent(e.EventType.ENDED))},d._startPlayingWatchDog=function(){var t=this;this._stopPlayingWatchDog(),this.dispatchEvent(new e.FakeEvent(e.EventType.TIME_UPDATE)),this._playingIntervalId=setInterval((function(){t._isSeeking||t.dispatchEvent(new e.FakeEvent(e.EventType.TIME_UPDATE))}),250)},d._stopPlayingWatchDog=function(){clearInterval(this._playingIntervalId),this._playingIntervalId=null},d.getThumbnail=function(e){return null},d.resetAllCues=function(){},d.enterPictureInPicture=function(){},d.exitPictureInPicture=function(){},d.isPictureInPictureSupported=function(){return!1},c=u,(l=[{key:"id",get:function(){return u.id}},{key:"src",set:function(e){this._source.url=e},get:function(){return this._loaded&&this._source?this._source.url:""}},{key:"currentTime",get:function(){return this._playerReady()?this._api.getCurrentTime():0},set:function(t){this._api&&this.currentTime!==t&&(this._isSeeking=!0,this._api.seekTo(t,!0),this.dispatchEvent(new e.FakeEvent(e.EventType.SEEKING)),this.paused&&this._startSeekTargetWatchDog())}},{key:"duration",get:function(){return this._playerReady()?this._api.getDuration():NaN}},{key:"volume",set:function(e){this._playerReady()&&this._api.setVolume(100*e)},get:function(){return this._playerReady()?this._api.getVolume()/100:1}},{key:"paused",get:function(){return!this._playerReady()||![window.YT.PlayerState.PLAYING,window.YT.PlayerState.BUFFERING].includes(this._api.getPlayerState())}},{key:"seeking",get:function(){return this._isSeeking}},{key:"seekable",get:function(){var e=this;return{length:1,start:function(){return 0},end:function(){return e._api?e.currentTime:0}}}},{key:"played",get:function(){var e=this;return{length:1,start:function(){return 0},end:function(){return e._api?e.currentTime:0}}}},{key:"buffered",get:function(){var e=this;return{length:1,start:function(){return 0},end:function(){return e._api&&e._api.getVideoLoadedFraction?e._api.getVideoLoadedFraction()*e.duration:0}}}},{key:"muted",set:function(e){this._playerReady()&&(e?this._api.mute():this._api.unMute(),this._muted=e)},get:function(){var e=!1;return this._playerReady()&&(e="boolean"==typeof this._muted?this._muted:this._api.isMuted()),e}},{key:"defaultMuted",get:function(){return!1}},{key:"poster",set:function(e){},get:function(){return""}},{key:"preload",set:function(e){},get:function(){return"none"}},{key:"autoplay",set:function(e){},get:function(){return!1}},{key:"loop",set:function(e){},get:function(){return!1}},{key:"controls",set:function(e){},get:function(){return!1}},{key:"playbackRate",set:function(e){this._api&&this._api.setPlaybackRate(e)},get:function(){return this._playerReady()?this._api.getPlaybackRate():1}},{key:"defaultPlaybackRate",set:function(e){},get:function(){return 1}},{key:"ended",get:function(){return!!this._playerReady()&&this._api.getPlayerState()===window.YT.PlayerState.ENDED}},{key:"error",get:function(){return null}},{key:"networkState",get:function(){if(!this._playerReady())return 0;var e=window.YT.PlayerState;switch(this._api.getPlayerState()){case e.UNSTARTED:return 0;case e.BUFFERING:return 2;default:return 1}}},{key:"readyState",get:function(){if(!this._api)return 0;var e=window.YT.PlayerState;switch(this._api.getPlayerState()){case e.UNSTARTED:return 0;case e.BUFFERING:return 2;default:return 4}}},{key:"videoHeight",get:function(){return-1}},{key:"videoWidth",get:function(){return-1}},{key:"playsinline",set:function(e){},get:function(){return this._config.playsinline}},{key:"crossOrigin",set:function(e){},get:function(){return null}},{key:"playbackRates",get:function(){var e=u.PLAYBACK_RATES;if(this._playerReady()){var t=this._api.getAvailablePlaybackRates();t&&Array.isArray(t)&&(e=t)}return e}},{key:"isInPictureInPicture",get:function(){return!1}},{key:"targetBuffer",get:function(){return NaN}},{key:"availableBuffer",get:function(){return NaN}}])&&t(c.prototype,l),u}(e.FakeEventTarget);r(s,"_logger",(0,e.getLogger)("Youtube")),r(s,"id","youtube"),r(s,"PLAYBACK_RATES",[1]),n(42);var u=n(773),c=n(948),l="2.2.2",d="@playkit-js/playkit-js-youtube";(0,u.registerPlugin)("youtube",c.L),s.isSupported()&&(0,e.registerEngine)(s.id,s)})(),(playkit=void 0===playkit?{}:playkit).youtube=i})();
1
+ var playkit;(()=>{var e={42:(e,t,n)=>{var i=n(292),a=n(791);"string"==typeof(a=a.__esModule?a.default:a)&&(a=[[e.id,a,""]]),i(a,{attributes:{id:"@playkit-js/playkit-js-youtube"},insert:function(e){window.kalturaGlobalConfig&&"string"==typeof window.kalturaGlobalConfig.stylesNonce&&e.setAttribute("nonce",window.kalturaGlobalConfig.stylesNonce),document.head.appendChild(e)},singleton:!1}),e.exports=a.locals||{}},278:e=>{"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var n=function(e,t){var n,i,a,r=e[1]||"",o=e[3];if(!o)return r;if(t&&"function"==typeof btoa){var s=(n=o,i=btoa(unescape(encodeURIComponent(JSON.stringify(n)))),a="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(i),"/*# ".concat(a," */")),u=o.sources.map((function(e){return"/*# sourceURL=".concat(o.sourceRoot||"").concat(e," */")}));return[r].concat(u).concat([s]).join("\n")}return[r].join("\n")}(t,e);return t[2]?"@media ".concat(t[2]," {").concat(n,"}"):n})).join("")},t.i=function(e,n,i){"string"==typeof e&&(e=[[null,e,""]]);var a={};if(i)for(var r=0;r<this.length;r++){var o=this[r][0];null!=o&&(a[o]=!0)}for(var s=0;s<e.length;s++){var u=[].concat(e[s]);i&&a[u[0]]||(n&&(u[2]?u[2]="".concat(n," and ").concat(u[2]):u[2]=n),t.push(u))}},t}},292:(e,t,n)=>{"use strict";var i,a=function(){var e={};return function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(e){n=null}e[t]=n}return e[t]}}(),r=[];function o(e){for(var t=-1,n=0;n<r.length;n++)if(r[n].identifier===e){t=n;break}return t}function s(e,t){for(var n={},i=[],a=0;a<e.length;a++){var s=e[a],u=t.base?s[0]+t.base:s[0],c=n[u]||0,l="".concat(u," ").concat(c);n[u]=c+1;var d=o(l),p={css:s[1],media:s[2],sourceMap:s[3]};-1!==d?(r[d].references++,r[d].updater(p)):r.push({identifier:l,updater:f(p,t),references:1}),i.push(l)}return i}function u(e){var t=document.createElement("style"),i=e.attributes||{};if(void 0===i.nonce){var r=n.nc;r&&(i.nonce=r)}if(Object.keys(i).forEach((function(e){t.setAttribute(e,i[e])})),"function"==typeof e.insert)e.insert(t);else{var o=a(e.insert||"head");if(!o)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");o.appendChild(t)}return t}var c,l=(c=[],function(e,t){return c[e]=t,c.filter(Boolean).join("\n")});function d(e,t,n,i){var a=n?"":i.media?"@media ".concat(i.media," {").concat(i.css,"}"):i.css;if(e.styleSheet)e.styleSheet.cssText=l(t,a);else{var r=document.createTextNode(a),o=e.childNodes;o[t]&&e.removeChild(o[t]),o.length?e.insertBefore(r,o[t]):e.appendChild(r)}}function p(e,t,n){var i=n.css,a=n.media,r=n.sourceMap;if(a?e.setAttribute("media",a):e.removeAttribute("media"),r&&btoa&&(i+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(r))))," */")),e.styleSheet)e.styleSheet.cssText=i;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(i))}}var h=null,y=0;function f(e,t){var n,i,a;if(t.singleton){var r=y++;n=h||(h=u(t)),i=d.bind(null,n,r,!1),a=d.bind(null,n,r,!0)}else n=u(t),i=p.bind(null,n,t),a=function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(n)};return i(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;i(e=t)}else a()}}e.exports=function(e,t){(t=t||{}).singleton||"boolean"==typeof t.singleton||(t.singleton=(void 0===i&&(i=Boolean(window&&document&&document.all&&!window.atob)),i));var n=s(e=e||[],t);return function(e){if(e=e||[],"[object Array]"===Object.prototype.toString.call(e)){for(var i=0;i<n.length;i++){var a=o(n[i]);r[a].references--}for(var u=s(e,t),c=0;c<n.length;c++){var l=o(n[c]);0===r[l].references&&(r[l].updater(),r.splice(l,1))}n=u}}}},773:e=>{"use strict";e.exports=KalturaPlayer},791:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>r});var i=n(278),a=n.n(i)()(!0);a.push([e.id,".playkit-iOS .playkit-engine-youtube,\n.playkit-Mac-OS .playkit-engine-youtube {\n object-fit: fill;\n}\n","",{version:3,sources:["style.css"],names:[],mappings:"AAAA;;EAEE,gBAAgB;AAClB",file:"style.css",sourcesContent:[".playkit-iOS .playkit-engine-youtube,\n.playkit-Mac-OS .playkit-engine-youtube {\n object-fit: fill;\n}\n"]}]);const r=a},948:(e,t,n)=>{"use strict";t.L=void 0;const i=n(773),a="YouTubeClipChapter";class r extends i.BasePlugin{constructor(e,t,n){super(e,t,n)}get timelineManager(){return this.player.getService("timeline")}static isValid(){return!0}loadMedia(){this.eventManager.listenOnce(this.player,this.player.Event.Core.SOURCE_SELECTED,(()=>{if(this.player.engineType===this.player.EngineType.YOUTUBE&&this.timelineManager){const{seekFrom:e,clipTo:t,duration:n}=this.player.config.sources,i=!!(t&&n&&t<n);(e||i)&&(this.timelineManager.disableChapters(),e&&this.timelineManager.addKalturaCuePoint(e,a,0),i&&this.timelineManager.addKalturaCuePoint(t,a,1))}}))}reset(){}destroy(){}}t.L=r}},t={};function n(i){var a=t[i];if(void 0!==a)return a.exports;var r=t[i]={id:i,exports:{}};return e[i](r,r.exports,n),r.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.nc=void 0;var i={};(()=>{"use strict";n.r(i),n.d(i,{Engine:()=>s,NAME:()=>d,Plugin:()=>c.L,VERSION:()=>l});const e=KalturaPlayer.core;function t(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function a(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var o={controls:0,autoplay:0,origin:window.location.origin,iv_load_policy:3,disablekb:1,modestbranding:1,playsinline:1,rel:0,fs:0,cc_load_policy:1},s=function(n){var i,s;function u(t,i){var o;return r(a(o=n.call(this)||this),"_isAdaptiveBitrate",!0),r(a(o),"_loaded",!1),r(a(o),"_isSeeking",!1),r(a(o),"_firstPlaying",!0),r(a(o),"_currentState",null),r(a(o),"_playerTracks",[]),r(a(o),"_clipToInterval",null),o._eventManager=new e.EventManager,o._createVideoElement(),o._init(t,i),o}s=n,(i=u).prototype=Object.create(s.prototype),i.prototype.constructor=i,i.__proto__=s,u.isSupported=function(){return!0},u.createEngine=function(e,t){return new this(e,t)},u.canPlaySource=function(e){var t="string"==typeof e.mimetype&&"video/youtube"===e.mimetype.toLowerCase();return u._logger.debug("canPlayType result for mimeType: "+e.mimetype+" is "+t.toString()),t},u.runCapabilities=function(){},u.getCapabilities=function(){var e,t=!1;"connection"in navigator&&navigator.connection&&(t=!!navigator.connection.saveData);var n=((e={})[u.id]={autoplay:!1,mutedAutoPlay:!t},e);return Promise.resolve(n)},u.prepareVideoElement=function(){u._logger.debug("Prepare the video element for playing not supported")};var c,l,d=u.prototype;return d.restore=function(e,t){this.reset(),this._init(e,t)},d._reset=function(){this._stopSeekTargetWatchDog(),this._stopPlayingWatchDog(),this.detach(),this._playerReady()&&this._api.stopVideo&&this._api.stopVideo(),this._loaded=!1,this._firstPlaying=!0,this._isSeeking=!1,this._isAdaptiveBitrate=!0,this._playerTracks=[],this._currentState=null,this._clipToInterval&&(clearInterval(this._clipToInterval),this._clipToInterval=null)},d.reset=function(){this._reset(),this._eventManager.removeAll(),this._api&&this._api.destroy&&this._api.destroy()},d.destroy=function(){this._reset(),this._api&&this._api.destroy&&this._api.destroy(),this._eventManager.destroy()},d.attach=function(){},d.detach=function(){},d.getVideoElement=function(){return this._el},d.selectVideoTrack=function(t){this._api&&t instanceof e.VideoTrack&&(!t.active||this.isAdaptiveBitrateEnabled())&&(this.isAdaptiveBitrateEnabled()&&this.dispatchEvent(e.EventType.ABR_MODE_CHANGED,{mode:"manual"}),this._isAdaptiveBitrate=!1,this._api.setPlaybackQuality(t.label))},d.selectAudioTrack=function(e){u._logger.info("audio track switching not supported, cannot switch to "+e.language)},d.selectTextTrack=function(e){u._logger.info("text track switching not supported, cannot switch to "+e.language)},d.hideTextTrack=function(){},d.enableAdaptiveBitrate=function(){this._api&&(this._api.setPlaybackQuality("default"),this._isAdaptiveBitrate=!0)},d.isAdaptiveBitrateEnabled=function(){return this._isAdaptiveBitrate},d.seekToLiveEdge=function(){},d.attachMediaSource=function(){},d.detachMediaSource=function(){},d.getStartTimeOfDvrWindow=function(){return 0},d.isLive=function(){return!1},d.play=function(){this._api&&(this.currentTime===this.duration&&(this.currentTime=0),this._api.playVideo())},d.pause=function(){this._api&&this._api.pauseVideo&&this._api.pauseVideo()},d.load=function(e){var t=this;return this._sdkLoaded.then((function(){var n={videoId:t._source.url,startSeconds:e&&e>0?e:0};t._api.cueVideoById(n),t._loaded=!0})).catch((function(e){return Promise.reject(e)})),this._videoLoaded={},this._videoLoaded.promise=new Promise((function(e,n){t._videoLoaded.resolve=e,t._videoLoaded.reject=n})),this._videoLoaded.promise},d._playerReady=function(){return!(!this._api||!this._loaded)},d._parseVideoTracks=function(){var t=this._api.getAvailableQualityLevels(),n=this._api.getPlaybackQuality(),i=[];return t.forEach((function(t,a){var r={active:n===t,label:t,bandwidth:0,width:a+1,height:a+1,language:"",index:a};i.push(new e.VideoTrack(r))})),i},d._startSeekTargetWatchDog=function(){var t=this,n=this.currentTime;this._stopSeekTargetWatchDog(),this._seekTargetIntervalId=setInterval((function(){t.paused&&t._isSeeking?t.currentTime!==n&&(t.dispatchEvent(new e.FakeEvent(e.EventType.TIME_UPDATE)),t.dispatchEvent(new e.FakeEvent(e.EventType.SEEKED)),t._isSeeking=!1):t._stopSeekTargetWatchDog()}),250)},d._stopSeekTargetWatchDog=function(){this._seekTargetIntervalId&&(clearInterval(this._seekTargetIntervalId),this._seekTargetIntervalId=null)},d._init=function(t,n){var i=this;this._source=t,this._config=n,this._api=null,this._videoLoaded=null,this._playingIntervalId=null;var a=function(t){var n=new e.Error(e.Error.Severity.CRITICAL,e.Error.Category.PLAYER,e.Error.Code.LOAD_FAILED,t);i.dispatchEvent(new e.FakeEvent(e.EventType.ERROR,n))};this._sdkLoaded=new Promise((function(e,t){i._apiReady=function(){(i._config.playback.muted||i._config.playback.autoplay)&&(i._api.mute&&i._api.mute(),i._muted=!0),e()},i._apiError=function(e){var n=i._getYoutubeErrorCodeData(e.data);a(n),t(e.data)}})),this._loadYouTubeIframeAPI().then((function(){i._loadYouTubePlayer()})).catch((function(e){a(e)}))},d._createVideoElement=function(){var t=this._el=e.Utils.Dom.createElement("div");e.Utils.Dom.setAttribute(t,"id",e.Utils.Generator.uniqueId(5)),e.Utils.Dom.setAttribute(t,"tabindex","-1")},d._getYoutubeErrorCodeData=function(e){switch(e){case 2:return{code:e,message:"Invalid params"};case 5:return{code:e,message:"Error while trying to play the video"};case 100:return{code:e,message:"Video not found"};case 101:case 150:return{code:e,message:"The owner of the requested video does not allow it to be played in embedded players"};default:return{code:e,message:"Unknown error"}}},d._loadYouTubePlayer=function(){var t=this,n=function(){var n={playerVars:o,events:{onReady:t._apiReady,onError:t._apiError,onStateChange:function(e){return t._onPlayerStateChange(e)},onPlaybackQualityChange:function(e){return t._onPlaybackQualityChange(e)},onVolumeChange:function(){return t.dispatchEvent(new e.FakeEvent(e.EventType.VOLUME_CHANGE))}}};if(n.playerVars.playsinline=t._config.playback.playsinline?1:0,n.playerVars.autoplay=t._config.playback.autoplay?1:0,e.Utils.Object.hasPropertyPath(t._config,"playback.options.youtube")){var i=t._config.playback.options.youtube;e.Utils.Object.mergeDeep(n.playerVars,i.playerVars)}t._api=new window.YT.Player(t._el.id,n)};if(this._api)return this._apiReady();window&&window.YT&&window.YT.Player?n():window.onYouTubeIframeAPIReady=n},d._loadYouTubeIframeAPI=function(){var t=this;return new Promise((function(n,i){if(window&&window.YT&&window.YT.Player)return n();var a=e.Utils.Dom.createElement("script"),r="https://www.youtube.com/iframe_api";e.Utils.Object.hasPropertyPath(t._config,"playback.options.youtube")&&t._config.playback.options.youtube.iframeApi&&(r=t._config.playback.options.youtube.iframeApi),a.src=r,a.async=!0,a.onload=function(){n()},a.onerror=function(){i({message:"Youtube Iframe API loading failed: "+r})};var o=document.getElementsByTagName("script")[0];o&&o.parentNode&&o.parentNode.insertBefore(a,o)}))},d._getPlayerStateKey=function(e){var t=window.YT.PlayerState;return Object.keys(t).find((function(n){return t[n]===e}))||"UNKNOWN"},d._onPlayerStateChange=function(e){var t=window.YT.PlayerState,n=e.data;if(u._logger.info("player state changed from "+this._getPlayerStateKey(this._currentState)+" to "+this._getPlayerStateKey(n)),n!==this._currentState)switch(this._currentState=n,this._currentState){case t.UNSTARTED:this._handleLoaded();break;case t.ENDED:this._onEnded();break;case t.PLAYING:this._firstPlaying&&this._handleFirstPlaying(),this._onPlaying();break;case t.PAUSED:this._onPaused();break;case t.BUFFERING:this._onBuffering();case t.CUED:}},d._onPlaybackQualityChange=function(t){var n=this._playerTracks.find((function(n){return n instanceof e.VideoTrack&&n.label===t.data}));this.dispatchEvent(e.EventType.VIDEO_TRACK_CHANGED,{selectedVideoTrack:n})},d._handleClipTo=function(){var e=this;this._clipToInterval&&clearInterval(this._clipToInterval);var t=this._config.sources.clipTo;this._api&&t&&this.currentTime<t&&(this._clipToInterval=setInterval((function(){e._api.getCurrentTime()>=t&&(e._api.pauseVideo(),clearInterval(e._clipToInterval))}),200))},d._onPlaying=function(){this._handleClipTo(),this.dispatchEvent(new e.FakeEvent(e.EventType.PLAY)),this.dispatchEvent(new e.FakeEvent(e.EventType.PLAYING)),this._startPlayingWatchDog(),this._isSeeking&&(this._isSeeking=!1,this.dispatchEvent(new e.FakeEvent(e.EventType.TIME_UPDATE)),this.dispatchEvent(new e.FakeEvent(e.EventType.SEEKED)))},d._handleLoaded=function(){this._loaded&&(this.dispatchEvent(new e.FakeEvent(e.EventType.LOADED_METADATA)),this.dispatchEvent(new e.FakeEvent(e.EventType.LOADED_DATA)),this._videoLoaded.resolve({tracks:this._playerTracks}))},d._handleFirstPlaying=function(){this._firstPlaying=!1,this.dispatchEvent(new e.FakeEvent(e.EventType.DURATION_CHANGE));var t=this._config.sources,n=t.seekFrom,i=t.captions;this._api&&n&&this._api.seekTo(n),this._api&&i&&i.length>0&&this._api.setOption("captions","track",{})},d._onBuffering=function(){this._stopPlayingWatchDog(),this.dispatchEvent(new e.FakeEvent(e.EventType.WAITING))},d._onPaused=function(){this._isSeeking&&(this._isSeeking=!1),this._stopPlayingWatchDog(),this.dispatchEvent(new e.FakeEvent(e.EventType.TIME_UPDATE)),this.dispatchEvent(new e.FakeEvent(e.EventType.PAUSE))},d._onEnded=function(){this._stopPlayingWatchDog(),this.dispatchEvent(new e.FakeEvent(e.EventType.TIME_UPDATE)),this.dispatchEvent(new e.FakeEvent(e.EventType.PAUSE)),this.dispatchEvent(new e.FakeEvent(e.EventType.ENDED))},d._startPlayingWatchDog=function(){var t=this;this._stopPlayingWatchDog(),this.dispatchEvent(new e.FakeEvent(e.EventType.TIME_UPDATE)),this._playingIntervalId=setInterval((function(){t._isSeeking||t.dispatchEvent(new e.FakeEvent(e.EventType.TIME_UPDATE))}),250)},d._stopPlayingWatchDog=function(){clearInterval(this._playingIntervalId),this._playingIntervalId=null},d.getThumbnail=function(e){return null},d.resetAllCues=function(){},d.enterPictureInPicture=function(){},d.exitPictureInPicture=function(){},d.isPictureInPictureSupported=function(){return!1},c=u,(l=[{key:"id",get:function(){return u.id}},{key:"src",set:function(e){this._source.url=e},get:function(){return this._loaded&&this._source?this._source.url:""}},{key:"currentTime",get:function(){return this._playerReady()?this._api.getCurrentTime():0},set:function(t){this._api&&this.currentTime!==t&&(this._isSeeking=!0,this._api.seekTo(t,!0),this.dispatchEvent(new e.FakeEvent(e.EventType.SEEKING)),this.paused&&this._startSeekTargetWatchDog())}},{key:"duration",get:function(){return this._playerReady()?this._api.getDuration():NaN}},{key:"volume",set:function(e){this._playerReady()&&this._api.setVolume(100*e)},get:function(){return this._playerReady()?this._api.getVolume()/100:1}},{key:"paused",get:function(){return!this._playerReady()||![window.YT.PlayerState.PLAYING,window.YT.PlayerState.BUFFERING].includes(this._api.getPlayerState())}},{key:"seeking",get:function(){return this._isSeeking}},{key:"seekable",get:function(){var e=this;return{length:1,start:function(){return 0},end:function(){return e._api?e.currentTime:0}}}},{key:"played",get:function(){var e=this;return{length:1,start:function(){return 0},end:function(){return e._api?e.currentTime:0}}}},{key:"buffered",get:function(){var e=this;return{length:1,start:function(){return 0},end:function(){return e._api&&e._api.getVideoLoadedFraction?e._api.getVideoLoadedFraction()*e.duration:0}}}},{key:"muted",set:function(e){this._playerReady()&&(e?this._api.mute():this._api.unMute(),this._muted=e)},get:function(){var e=!1;return this._playerReady()&&(e="boolean"==typeof this._muted?this._muted:this._api.isMuted()),e}},{key:"defaultMuted",get:function(){return!1}},{key:"poster",set:function(e){},get:function(){return""}},{key:"preload",set:function(e){},get:function(){return"none"}},{key:"autoplay",set:function(e){},get:function(){return!1}},{key:"loop",set:function(e){},get:function(){return!1}},{key:"controls",set:function(e){},get:function(){return!1}},{key:"playbackRate",set:function(e){this._api&&this._api.setPlaybackRate(e)},get:function(){return this._playerReady()?this._api.getPlaybackRate():1}},{key:"defaultPlaybackRate",set:function(e){},get:function(){return 1}},{key:"ended",get:function(){return!!this._playerReady()&&this._api.getPlayerState()===window.YT.PlayerState.ENDED}},{key:"error",get:function(){return null}},{key:"networkState",get:function(){if(!this._playerReady())return 0;var e=window.YT.PlayerState;switch(this._api.getPlayerState()){case e.UNSTARTED:return 0;case e.BUFFERING:return 2;default:return 1}}},{key:"readyState",get:function(){if(!this._api)return 0;var e=window.YT.PlayerState;switch(this._api.getPlayerState()){case e.UNSTARTED:return 0;case e.BUFFERING:return 2;default:return 4}}},{key:"videoHeight",get:function(){return-1}},{key:"videoWidth",get:function(){return-1}},{key:"playsinline",set:function(e){},get:function(){return this._config.playsinline}},{key:"crossOrigin",set:function(e){},get:function(){return null}},{key:"playbackRates",get:function(){var e=u.PLAYBACK_RATES;if(this._playerReady()){var t=this._api.getAvailablePlaybackRates();t&&Array.isArray(t)&&(e=t)}return e}},{key:"isInPictureInPicture",get:function(){return!1}},{key:"targetBuffer",get:function(){return NaN}},{key:"availableBuffer",get:function(){return NaN}}])&&t(c.prototype,l),u}(e.FakeEventTarget);r(s,"_logger",(0,e.getLogger)("Youtube")),r(s,"id","youtube"),r(s,"PLAYBACK_RATES",[1]),n(42);var u=n(773),c=n(948),l="2.2.3",d="@playkit-js/playkit-js-youtube";(0,u.registerPlugin)("youtube",c.L),s.isSupported()&&(0,e.registerEngine)(s.id,s)})(),(playkit=void 0===playkit?{}:playkit).youtube=i})();
2
2
  //# sourceMappingURL=playkit-youtube.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playkit-js/playkit-js-youtube",
3
- "version": "2.2.2",
3
+ "version": "2.2.3",
4
4
  "main": "dist/playkit-youtube.js",
5
5
  "scripts": {
6
6
  "clean": "rm -rf ./dist",
@@ -116,7 +116,7 @@
116
116
  "kaltura": {
117
117
  "name": "youtube",
118
118
  "dependencies": {
119
- "playkit-timeline": "3.1.3"
119
+ "playkit-timeline": "3.1.4"
120
120
  }
121
121
  }
122
122
  }