@playkit-js/playkit-js-youtube 2.0.5 → 2.0.6

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.0.6](https://github.com/kaltura/playkit-js-youtube/compare/v2.0.5...v2.0.6) (2022-09-01)
6
+
5
7
  ### [2.0.5](https://github.com/kaltura/playkit-js-youtube/compare/v2.0.4...v2.0.5) (2022-08-31)
6
8
 
7
9
  ### [2.0.4](https://github.com/kaltura/playkit-js-youtube/compare/v2.0.3...v2.0.4) (2022-08-31)
@@ -1,2 +1,2 @@
1
- var playkit="object"==typeof playkit?playkit:{};playkit.youtube=function(e){var t={};function n(i){if(t[i])return t[i].exports;var a=t[i]={i:i,l:!1,exports:{}};return e[i].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(i,a,function(t){return e[t]}.bind(null,a));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=5)}([function(e,t){e.exports=KalturaPlayer.core},function(e,t,n){"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var n=function(e,t){var n=e[1]||"",i=e[3];if(!i)return n;if(t&&"function"==typeof btoa){var a=(o=i,s=btoa(unescape(encodeURIComponent(JSON.stringify(o)))),u="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(s),"/*# ".concat(u," */")),r=i.sources.map((function(e){return"/*# sourceURL=".concat(i.sourceRoot||"").concat(e," */")}));return[n].concat(r).concat([a]).join("\n")}var o,s,u;return[n].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}},function(e,t,n){var i=n(3),a=n(4);"string"==typeof(a=a.__esModule?a.default:a)&&(a=[[e.i,a,""]]);var r={insert:"head",singleton:!1};i(a,r);e.exports=a.locals||{}},function(e,t,n){"use strict";var i,a=function(){return void 0===i&&(i=Boolean(window&&document&&document.all&&!window.atob)),i},r=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]}}(),o=[];function s(e){for(var t=-1,n=0;n<o.length;n++)if(o[n].identifier===e){t=n;break}return t}function u(e,t){for(var n={},i=[],a=0;a<e.length;a++){var r=e[a],u=t.base?r[0]+t.base:r[0],c=n[u]||0,l="".concat(u," ").concat(c);n[u]=c+1;var d=s(l),p={css:r[1],media:r[2],sourceMap:r[3]};-1!==d?(o[d].references++,o[d].updater(p)):o.push({identifier:l,updater:g(p,t),references:1}),i.push(l)}return i}function c(e){var t=document.createElement("style"),i=e.attributes||{};if(void 0===i.nonce){var a=n.nc;a&&(i.nonce=a)}if(Object.keys(i).forEach((function(e){t.setAttribute(e,i[e])})),"function"==typeof e.insert)e.insert(t);else{var o=r(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 l,d=(l=[],function(e,t){return l[e]=t,l.filter(Boolean).join("\n")});function p(e,t,n,i){var a=n?"":i.media?"@media ".concat(i.media," {").concat(i.css,"}"):i.css;if(e.styleSheet)e.styleSheet.cssText=d(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 f(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 g(e,t){var n,i,a;if(t.singleton){var r=y++;n=h||(h=c(t)),i=p.bind(null,n,r,!1),a=p.bind(null,n,r,!0)}else n=c(t),i=f.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=a());var n=u(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=s(n[i]);o[a].references--}for(var r=u(e,t),c=0;c<n.length;c++){var l=s(n[c]);0===o[l].references&&(o[l].updater(),o.splice(l,1))}n=r}}}},function(e,t,n){"use strict";n.r(t);var i=n(1),a=n.n(i)()(!0);a.push([e.i,".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"]}]),t.default=a},function(e,t,n){"use strict";n.r(t),n.d(t,"Engine",(function(){return u})),n.d(t,"VERSION",(function(){return c})),n.d(t,"NAME",(function(){return l}));var i=n(0);function a(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 r(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var s={controls:0,autoplay:0,origin:window.location.origin,iv_load_policy:3,disablekb:1,modestbranding:1,playsinline:1,rel:0,fs:0},u=function(e){var t,n;function u(t,n){var a;return o(r(a=e.call(this)||this),"_isAdaptiveBitrate",!0),o(r(a),"_loaded",!1),o(r(a),"_isSeeking",!1),o(r(a),"_firstPlaying",!0),o(r(a),"_currentState",null),o(r(a),"_playerTracks",[]),a._eventManager=new i.EventManager,a._createVideoElement(),a._init(t,n),a}n=e,(t=u).prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n,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,p=u.prototype;return p.restore=function(e,t){this.reset(),this._init(e,t)},p._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},p.reset=function(){this._reset(),this._eventManager.removeAll()},p.destroy=function(){this._reset(),this._api&&this._api.destroy&&this._api.destroy(),this._eventManager.destroy()},p.attach=function(){},p.detach=function(){},p.getVideoElement=function(){return this._el},p.selectVideoTrack=function(e){this._api&&e instanceof i.VideoTrack&&(!e.active||this.isAdaptiveBitrateEnabled())&&(this.isAdaptiveBitrateEnabled()&&this.dispatchEvent(i.EventType.ABR_MODE_CHANGED,{mode:"manual"}),this._isAdaptiveBitrate=!1,this._api.setPlaybackQuality(e.label))},p.selectAudioTrack=function(e){u._logger.info("audio track switching not supported, cannot switch to "+e.language)},p.selectTextTrack=function(e){u._logger.info("text track switching not supported, cannot switch to "+e.language)},p.hideTextTrack=function(){},p.enableAdaptiveBitrate=function(){this._api&&(this._api.setPlaybackQuality("default"),this._isAdaptiveBitrate=!0)},p.isAdaptiveBitrateEnabled=function(){return this._isAdaptiveBitrate},p.seekToLiveEdge=function(){},p.attachMediaSource=function(){},p.detachMediaSource=function(){},p.getStartTimeOfDvrWindow=function(){return 0},p.isLive=function(){return!1},p.play=function(){this._api&&(this.currentTime===this.duration&&(this.currentTime=0),this._api.playVideo())},p.pause=function(){this._api&&this._api.pauseVideo&&this._api.pauseVideo()},p.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},p._playerReady=function(){return!(!this._api||!this._loaded)},p._parseVideoTracks=function(){var e=this._api.getAvailableQualityLevels(),t=this._api.getPlaybackQuality(),n=[];return e.forEach((function(e,a){var r={active:t===e,label:e,bandwidth:0,width:a+1,height:a+1,language:"",index:a};n.push(new i.VideoTrack(r))})),n},p._startSeekTargetWatchDog=function(){var e=this,t=this.currentTime;this._stopSeekTargetWatchDog(),this._seekTargetIntervalId=setInterval((function(){e.paused&&e._isSeeking?e.currentTime!==t&&(e.dispatchEvent(new i.FakeEvent(i.EventType.TIME_UPDATE)),e.dispatchEvent(new i.FakeEvent(i.EventType.SEEKED)),e._isSeeking=!1):e._stopSeekTargetWatchDog()}),250)},p._stopSeekTargetWatchDog=function(){this._seekTargetIntervalId&&(clearInterval(this._seekTargetIntervalId),this._seekTargetIntervalId=null)},p._init=function(e,t){var n=this;this._source=e,this._config=t,this._api=null,this._videoLoaded=null,this._playingIntervalId=null;var a=function(e){var t=new i.Error(i.Error.Severity.CRITICAL,i.Error.Category.PLAYER,i.Error.Code.LOAD_FAILED,e);n.dispatchEvent(new i.FakeEvent(i.EventType.ERROR,t))};this._sdkLoaded=new Promise((function(e,t){n._apiReady=function(){(n._config.playback.muted||n._config.playback.autoplay)&&(n._api.mute&&n._api.mute(),n._muted=!0),e()},n._apiError=function(e){var i=n._getYoutubeErrorCodeData(e.data);a(i),t(e.data)}})),this._loadYouTubeIframeAPI().then((function(){n._loadYouTubePlayer()})).catch((function(e){a(e)}))},p._createVideoElement=function(){var e=this._el=i.Utils.Dom.createElement("div");i.Utils.Dom.setAttribute(e,"id",i.Utils.Generator.uniqueId(5)),i.Utils.Dom.setAttribute(e,"tabindex","-1")},p._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"}}},p._loadYouTubePlayer=function(){var e=this,t=function(){var t={playerVars:s,events:{onReady:e._apiReady,onError:e._apiError,onStateChange:function(t){return e._onPlayerStateChange(t)},onPlaybackQualityChange:function(t){return e._onPlaybackQualityChange(t)},onVolumeChange:function(){return e.dispatchEvent(new i.FakeEvent(i.EventType.VOLUME_CHANGE))}}};if(t.playerVars.playsinline=e._config.playback.playsinline?1:0,t.playerVars.autoplay=e._config.playback.autoplay?1:0,i.Utils.Object.hasPropertyPath(e._config,"playback.options.youtube")){var n=e._config.playback.options.youtube;i.Utils.Object.mergeDeep(t.playerVars,n.playerVars)}e._api=new window.YT.Player(e._el.id,t)};if(this._api)return this._apiReady();window&&window.YT&&window.YT.Player?t():window.onYouTubeIframeAPIReady=t},p._loadYouTubeIframeAPI=function(){var e=this;return new Promise((function(t,n){if(window&&window.YT&&window.YT.Player)return t();var a=i.Utils.Dom.createElement("script"),r="https://www.youtube.com/iframe_api";i.Utils.Object.hasPropertyPath(e._config,"playback.options.youtube")&&e._config.playback.options.youtube.iframeApi&&(r=e._config.playback.options.youtube.iframeApi),a.src=r,a.async=!0,a.onload=function(){t()},a.onerror=function(){n({message:"Youtube Iframe API loading failed: "+r})};var o=document.getElementsByTagName("script")[0];o&&o.parentNode&&o.parentNode.insertBefore(a,o)}))},p._getPlayerStateKey=function(e){var t=window.YT.PlayerState;return Object.keys(t).find((function(n){return t[n]===e}))||"UNKNOWN"},p._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();break;case t.CUED:}},p._onPlaybackQualityChange=function(e){var t=this._playerTracks.find((function(t){return t instanceof i.VideoTrack&&t.label===e.data}));this.dispatchEvent(i.EventType.VIDEO_TRACK_CHANGED,{selectedVideoTrack:t})},p._onPlaying=function(){this.dispatchEvent(new i.FakeEvent(i.EventType.PLAY)),this.dispatchEvent(new i.FakeEvent(i.EventType.PLAYING)),this._startPlayingWatchDog(),this._isSeeking&&(this._isSeeking=!1,this.dispatchEvent(new i.FakeEvent(i.EventType.TIME_UPDATE)),this.dispatchEvent(new i.FakeEvent(i.EventType.SEEKED)))},p._handleLoaded=function(){this._loaded&&(this.dispatchEvent(new i.FakeEvent(i.EventType.LOADED_METADATA)),this.dispatchEvent(new i.FakeEvent(i.EventType.LOADED_DATA)),this._videoLoaded.resolve({tracks:this._playerTracks}))},p._handleFirstPlaying=function(){this._firstPlaying=!1,this.dispatchEvent(new i.FakeEvent(i.EventType.DURATION_CHANGE))},p._onBuffering=function(){this._stopPlayingWatchDog(),this.dispatchEvent(new i.FakeEvent(i.EventType.WAITING))},p._onPaused=function(){this._isSeeking&&(this._isSeeking=!1),this._stopPlayingWatchDog(),this.dispatchEvent(new i.FakeEvent(i.EventType.TIME_UPDATE)),this.dispatchEvent(new i.FakeEvent(i.EventType.PAUSE))},p._onEnded=function(){this._stopPlayingWatchDog(),this.dispatchEvent(new i.FakeEvent(i.EventType.TIME_UPDATE)),this.dispatchEvent(new i.FakeEvent(i.EventType.PAUSE)),this.dispatchEvent(new i.FakeEvent(i.EventType.ENDED))},p._startPlayingWatchDog=function(){var e=this;this._stopPlayingWatchDog(),this.dispatchEvent(new i.FakeEvent(i.EventType.TIME_UPDATE)),this._playingIntervalId=setInterval((function(){e._isSeeking||e.dispatchEvent(new i.FakeEvent(i.EventType.TIME_UPDATE))}),250)},p._stopPlayingWatchDog=function(){clearInterval(this._playingIntervalId),this._playingIntervalId=null},p.resetAllCues=function(){},p.enterPictureInPicture=function(){},p.exitPictureInPicture=function(){},p.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(e){this._api&&this.currentTime!==e&&(this._isSeeking=!0,this._api.seekTo(e,!0),this.dispatchEvent(new i.FakeEvent(i.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}}])&&a(c.prototype,l),d&&a(c,d),u}(i.FakeEventTarget);o(u,"_logger",Object(i.getLogger)("Youtube")),o(u,"id","youtube"),o(u,"PLAYBACK_RATES",[1]);n(2);var c="2.0.5",l="@playkit-js/playkit-js-youtube";u.isSupported()&&Object(i.registerEngine)(u.id,u)}]);
1
+ var playkit="object"==typeof playkit?playkit:{};playkit.youtube=function(e){var t={};function n(i){if(t[i])return t[i].exports;var a=t[i]={i:i,l:!1,exports:{}};return e[i].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(i,a,function(t){return e[t]}.bind(null,a));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=5)}([function(e,t){e.exports=KalturaPlayer.core},function(e,t,n){"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var n=function(e,t){var n=e[1]||"",i=e[3];if(!i)return n;if(t&&"function"==typeof btoa){var a=(o=i,s=btoa(unescape(encodeURIComponent(JSON.stringify(o)))),u="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(s),"/*# ".concat(u," */")),r=i.sources.map((function(e){return"/*# sourceURL=".concat(i.sourceRoot||"").concat(e," */")}));return[n].concat(r).concat([a]).join("\n")}var o,s,u;return[n].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}},function(e,t,n){var i=n(3),a=n(4);"string"==typeof(a=a.__esModule?a.default:a)&&(a=[[e.i,a,""]]);var r={insert:"head",singleton:!1};i(a,r);e.exports=a.locals||{}},function(e,t,n){"use strict";var i,a=function(){return void 0===i&&(i=Boolean(window&&document&&document.all&&!window.atob)),i},r=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]}}(),o=[];function s(e){for(var t=-1,n=0;n<o.length;n++)if(o[n].identifier===e){t=n;break}return t}function u(e,t){for(var n={},i=[],a=0;a<e.length;a++){var r=e[a],u=t.base?r[0]+t.base:r[0],c=n[u]||0,l="".concat(u," ").concat(c);n[u]=c+1;var d=s(l),p={css:r[1],media:r[2],sourceMap:r[3]};-1!==d?(o[d].references++,o[d].updater(p)):o.push({identifier:l,updater:g(p,t),references:1}),i.push(l)}return i}function c(e){var t=document.createElement("style"),i=e.attributes||{};if(void 0===i.nonce){var a=n.nc;a&&(i.nonce=a)}if(Object.keys(i).forEach((function(e){t.setAttribute(e,i[e])})),"function"==typeof e.insert)e.insert(t);else{var o=r(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 l,d=(l=[],function(e,t){return l[e]=t,l.filter(Boolean).join("\n")});function p(e,t,n,i){var a=n?"":i.media?"@media ".concat(i.media," {").concat(i.css,"}"):i.css;if(e.styleSheet)e.styleSheet.cssText=d(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 f(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 g(e,t){var n,i,a;if(t.singleton){var r=y++;n=h||(h=c(t)),i=p.bind(null,n,r,!1),a=p.bind(null,n,r,!0)}else n=c(t),i=f.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=a());var n=u(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=s(n[i]);o[a].references--}for(var r=u(e,t),c=0;c<n.length;c++){var l=s(n[c]);0===o[l].references&&(o[l].updater(),o.splice(l,1))}n=r}}}},function(e,t,n){"use strict";n.r(t);var i=n(1),a=n.n(i)()(!0);a.push([e.i,".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"]}]),t.default=a},function(e,t,n){"use strict";n.r(t),n.d(t,"Engine",(function(){return u})),n.d(t,"VERSION",(function(){return c})),n.d(t,"NAME",(function(){return l}));var i=n(0);function a(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 r(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var s={controls:0,autoplay:0,origin:window.location.origin,iv_load_policy:3,disablekb:1,modestbranding:1,playsinline:1,rel:0,fs:0},u=function(e){var t,n;function u(t,n){var a;return o(r(a=e.call(this)||this),"_isAdaptiveBitrate",!0),o(r(a),"_loaded",!1),o(r(a),"_isSeeking",!1),o(r(a),"_firstPlaying",!0),o(r(a),"_currentState",null),o(r(a),"_playerTracks",[]),a._eventManager=new i.EventManager,a._createVideoElement(),a._init(t,n),a}n=e,(t=u).prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n,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,p=u.prototype;return p.restore=function(e,t){this.reset(),this._init(e,t)},p._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},p.reset=function(){this._reset(),this._eventManager.removeAll()},p.destroy=function(){this._reset(),this._api&&this._api.destroy&&this._api.destroy(),this._eventManager.destroy()},p.attach=function(){},p.detach=function(){},p.getVideoElement=function(){return this._el},p.selectVideoTrack=function(e){this._api&&e instanceof i.VideoTrack&&(!e.active||this.isAdaptiveBitrateEnabled())&&(this.isAdaptiveBitrateEnabled()&&this.dispatchEvent(i.EventType.ABR_MODE_CHANGED,{mode:"manual"}),this._isAdaptiveBitrate=!1,this._api.setPlaybackQuality(e.label))},p.selectAudioTrack=function(e){u._logger.info("audio track switching not supported, cannot switch to "+e.language)},p.selectTextTrack=function(e){u._logger.info("text track switching not supported, cannot switch to "+e.language)},p.hideTextTrack=function(){},p.enableAdaptiveBitrate=function(){this._api&&(this._api.setPlaybackQuality("default"),this._isAdaptiveBitrate=!0)},p.isAdaptiveBitrateEnabled=function(){return this._isAdaptiveBitrate},p.seekToLiveEdge=function(){},p.attachMediaSource=function(){},p.detachMediaSource=function(){},p.getStartTimeOfDvrWindow=function(){return 0},p.isLive=function(){return!1},p.play=function(){this._api&&(this.currentTime===this.duration&&(this.currentTime=0),this._api.playVideo())},p.pause=function(){this._api&&this._api.pauseVideo&&this._api.pauseVideo()},p.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},p._playerReady=function(){return!(!this._api||!this._loaded)},p._parseVideoTracks=function(){var e=this._api.getAvailableQualityLevels(),t=this._api.getPlaybackQuality(),n=[];return e.forEach((function(e,a){var r={active:t===e,label:e,bandwidth:0,width:a+1,height:a+1,language:"",index:a};n.push(new i.VideoTrack(r))})),n},p._startSeekTargetWatchDog=function(){var e=this,t=this.currentTime;this._stopSeekTargetWatchDog(),this._seekTargetIntervalId=setInterval((function(){e.paused&&e._isSeeking?e.currentTime!==t&&(e.dispatchEvent(new i.FakeEvent(i.EventType.TIME_UPDATE)),e.dispatchEvent(new i.FakeEvent(i.EventType.SEEKED)),e._isSeeking=!1):e._stopSeekTargetWatchDog()}),250)},p._stopSeekTargetWatchDog=function(){this._seekTargetIntervalId&&(clearInterval(this._seekTargetIntervalId),this._seekTargetIntervalId=null)},p._init=function(e,t){var n=this;this._source=e,this._config=t,this._api=null,this._videoLoaded=null,this._playingIntervalId=null;var a=function(e){var t=new i.Error(i.Error.Severity.CRITICAL,i.Error.Category.PLAYER,i.Error.Code.LOAD_FAILED,e);n.dispatchEvent(new i.FakeEvent(i.EventType.ERROR,t))};this._sdkLoaded=new Promise((function(e,t){n._apiReady=function(){(n._config.playback.muted||n._config.playback.autoplay)&&(n._api.mute&&n._api.mute(),n._muted=!0),e()},n._apiError=function(e){var i=n._getYoutubeErrorCodeData(e.data);a(i),t(e.data)}})),this._loadYouTubeIframeAPI().then((function(){n._loadYouTubePlayer()})).catch((function(e){a(e)}))},p._createVideoElement=function(){var e=this._el=i.Utils.Dom.createElement("div");i.Utils.Dom.setAttribute(e,"id",i.Utils.Generator.uniqueId(5)),i.Utils.Dom.setAttribute(e,"tabindex","-1")},p._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"}}},p._loadYouTubePlayer=function(){var e=this,t=function(){var t={playerVars:s,events:{onReady:e._apiReady,onError:e._apiError,onStateChange:function(t){return e._onPlayerStateChange(t)},onPlaybackQualityChange:function(t){return e._onPlaybackQualityChange(t)},onVolumeChange:function(){return e.dispatchEvent(new i.FakeEvent(i.EventType.VOLUME_CHANGE))}}};if(t.playerVars.playsinline=e._config.playback.playsinline?1:0,t.playerVars.autoplay=e._config.playback.autoplay?1:0,i.Utils.Object.hasPropertyPath(e._config,"playback.options.youtube")){var n=e._config.playback.options.youtube;i.Utils.Object.mergeDeep(t.playerVars,n.playerVars)}e._api=new window.YT.Player(e._el.id,t)};if(this._api)return this._apiReady();window&&window.YT&&window.YT.Player?t():window.onYouTubeIframeAPIReady=t},p._loadYouTubeIframeAPI=function(){var e=this;return new Promise((function(t,n){if(window&&window.YT&&window.YT.Player)return t();var a=i.Utils.Dom.createElement("script"),r="https://www.youtube.com/iframe_api";i.Utils.Object.hasPropertyPath(e._config,"playback.options.youtube")&&e._config.playback.options.youtube.iframeApi&&(r=e._config.playback.options.youtube.iframeApi),a.src=r,a.async=!0,a.onload=function(){t()},a.onerror=function(){n({message:"Youtube Iframe API loading failed: "+r})};var o=document.getElementsByTagName("script")[0];o&&o.parentNode&&o.parentNode.insertBefore(a,o)}))},p._getPlayerStateKey=function(e){var t=window.YT.PlayerState;return Object.keys(t).find((function(n){return t[n]===e}))||"UNKNOWN"},p._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();break;case t.CUED:}},p._onPlaybackQualityChange=function(e){var t=this._playerTracks.find((function(t){return t instanceof i.VideoTrack&&t.label===e.data}));this.dispatchEvent(i.EventType.VIDEO_TRACK_CHANGED,{selectedVideoTrack:t})},p._onPlaying=function(){this.dispatchEvent(new i.FakeEvent(i.EventType.PLAY)),this.dispatchEvent(new i.FakeEvent(i.EventType.PLAYING)),this._startPlayingWatchDog(),this._isSeeking&&(this._isSeeking=!1,this.dispatchEvent(new i.FakeEvent(i.EventType.TIME_UPDATE)),this.dispatchEvent(new i.FakeEvent(i.EventType.SEEKED)))},p._handleLoaded=function(){this._loaded&&(this.dispatchEvent(new i.FakeEvent(i.EventType.LOADED_METADATA)),this.dispatchEvent(new i.FakeEvent(i.EventType.LOADED_DATA)),this._videoLoaded.resolve({tracks:this._playerTracks}))},p._handleFirstPlaying=function(){this._firstPlaying=!1,this.dispatchEvent(new i.FakeEvent(i.EventType.DURATION_CHANGE))},p._onBuffering=function(){this._stopPlayingWatchDog(),this.dispatchEvent(new i.FakeEvent(i.EventType.WAITING))},p._onPaused=function(){this._isSeeking&&(this._isSeeking=!1),this._stopPlayingWatchDog(),this.dispatchEvent(new i.FakeEvent(i.EventType.TIME_UPDATE)),this.dispatchEvent(new i.FakeEvent(i.EventType.PAUSE))},p._onEnded=function(){this._stopPlayingWatchDog(),this.dispatchEvent(new i.FakeEvent(i.EventType.TIME_UPDATE)),this.dispatchEvent(new i.FakeEvent(i.EventType.PAUSE)),this.dispatchEvent(new i.FakeEvent(i.EventType.ENDED))},p._startPlayingWatchDog=function(){var e=this;this._stopPlayingWatchDog(),this.dispatchEvent(new i.FakeEvent(i.EventType.TIME_UPDATE)),this._playingIntervalId=setInterval((function(){e._isSeeking||e.dispatchEvent(new i.FakeEvent(i.EventType.TIME_UPDATE))}),250)},p._stopPlayingWatchDog=function(){clearInterval(this._playingIntervalId),this._playingIntervalId=null},p.resetAllCues=function(){},p.enterPictureInPicture=function(){},p.exitPictureInPicture=function(){},p.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(e){this._api&&this.currentTime!==e&&(this._isSeeking=!0,this._api.seekTo(e,!0),this.dispatchEvent(new i.FakeEvent(i.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}}])&&a(c.prototype,l),d&&a(c,d),u}(i.FakeEventTarget);o(u,"_logger",Object(i.getLogger)("Youtube")),o(u,"id","youtube"),o(u,"PLAYBACK_RATES",[1]);n(2);var c="2.0.6",l="@playkit-js/playkit-js-youtube";u.isSupported()&&Object(i.registerEngine)(u.id,u)}]);
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.0.5",
3
+ "version": "2.0.6",
4
4
  "main": "dist/playkit-youtube.js",
5
5
  "scripts": {
6
6
  "clean": "rm -rf ./dist",