UNPKG

videojs-externals

Version:
8 lines 40.9 kB
/** * videojs-externals * @version 1.0.12 * @copyright 2016 Benjamin Pott * @license MIT */ !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.videojsExternals=e()}}(function(){return function e(t,n,i){function r(a,s){if(!n[a]){if(!t[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(o)return o(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var c=n[a]={exports:{}};t[a][0].call(c.exports,function(e){var n=t[a][1][e];return r(n?n:e)},c,c.exports,e,t,n,i)}return n[a].exports}for(var o="function"==typeof require&&require,a=0;a<i.length;a++)r(i[a]);return r}({1:[function(e,t,n){(function(e){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(n,"__esModule",{value:!0});var a=function(){function e(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)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),s=function(e,t,n){for(var i=!0;i;){var r=e,o=t,a=n;i=!1,null===r&&(r=Function.prototype);var s=Object.getOwnPropertyDescriptor(r,o);if(void 0!==s){if("value"in s)return s.value;var u=s.get;if(void 0===u)return;return u.call(a)}var l=Object.getPrototypeOf(r);if(null===l)return;e=l,t=o,n=a,i=!0,s=l=void 0}},u="undefined"!=typeof window?window.videojs:"undefined"!=typeof e?e.videojs:null,l=i(u),c=l["default"].getComponent("Component"),d=l["default"].getComponent("PosterImage"),p=function(e){function t(e,n){r(this,t),s(Object.getPrototypeOf(t.prototype),"constructor",this).call(this,e,n)}return o(t,e),a(t,[{key:"update",value:function(e){this.setSrc(e),e?this.show():this.hide()}}]),t}(d);c.registerComponent("SubPosterImage",p),n["default"]=p,t.exports=n["default"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(e,t,n){(function(i){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(n,"__esModule",{value:!0});var s=function(){function e(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)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),u=function(e,t,n){for(var i=!0;i;){var r=e,o=t,a=n;i=!1,null===r&&(r=Function.prototype);var s=Object.getOwnPropertyDescriptor(r,o);if(void 0!==s){if("value"in s)return s.value;var u=s.get;if(void 0===u)return;return u.call(a)}var l=Object.getPrototypeOf(r);if(null===l)return;e=l,t=o,n=a,i=!0,s=l=void 0}},l="undefined"!=typeof window?window.videojs:"undefined"!=typeof i?i.videojs:null,c=r(l),d=e("./Externals"),p=r(d),f=c["default"].getComponent("Component"),h=c["default"].getComponent("Tech"),y=function(e){function t(e,n){o(this,t),u(Object.getPrototypeOf(t.prototype),"constructor",this).call(this,e,n)}return a(t,e),s(t,[{key:"injectCss",value:function(){var e=".vjs-"+this.className_+" > .vjs-poster { display:block; width:50%; background-size:contain; background-position: 0 50%; background-color: #000; }\n .vjs-"+this.className_+" .vjs-tech > .vjs-poster { display:block; background-color: rgba(76, 50, 65, 0.35);}\n .vjs-deezer-info{position:absolute;padding:3em 1em 1em 1em;left:50%;top:0;right:0;bottom:0;\n text-align: center; pointer-events: none; text-shadow: 0px 0px 5px rgba(0, 0, 0, 0.69);}";u(Object.getPrototypeOf(t.prototype),"injectCss",this).call(this,e)}},{key:"createEl",value:function(){var e=null;"string"==typeof this.options_.source?e=this.options_.source:"object"==typeof this.options_.source&&(e=this.options_.source.src),e=this.parseSrc(e);var n=u(Object.getPrototypeOf(t.prototype),"createEl",this).call(this,"div",{width:"100%",height:"100%",src:"//www.deezer.com/plugins/player?type=tracks&id="+e+"\n &format=classic&color=007FEB&autoplay="+this.options_.autoplay+"\n &playlist="+this.options_.playList+"&width=100%&height=100%"});this.infosEl_=c["default"].createEl("div",{className:"vjs-deezer-info"});var i=c["default"].createEl("div",{id:"dz-root"});return n.firstChild.style.visibility=this.options_.visibility,n.appendChild(this.infosEl_),n.appendChild(i),n}},{key:"isApiReady",value:function(){return window.DZ&&window.DZ.player}},{key:"onStateChange",value:function(e){var t=e.type;switch(t){case-1:this.trigger("loadstart"),this.trigger("loadedmetadata"),this.trigger("durationchange"),this.trigger("waiting");break;case"player_loaded":this.trigger("loadedmetadata"),this.trigger("durationchange"),this.trigger("canplay"),this.updatePause();break;case"track_end":this.updatePause(),this.trigger("ended");break;case"player_play":this.updateDuration(),this.updatePause(),this.trigger("play");break;case"player_position":this.trigger("playing"),this.currentTime_=e[0],this.duration_=e[1],this.trigger("timeupdate");break;case"player_paused":this.updatePause(),this.trigger("pause")}}},{key:"parseSrc",value:function(e){if(e){var t=/^https?:\/\/(?:www\.)?deezer\.com\/(track|album|playlist)\/(\d+)$/,n=e.match(t);return n?n[2]||n[2]:null}}},{key:"onReady",value:function(){u(Object.getPrototypeOf(t.prototype),"onReady",this).call(this),this.updateDuration(),this.updateVolume(),this.updatePoster()}},{key:"initTech",value:function(){DZ.init({channelUrl:window.location.protocol+"//"+window.location.hostname,appId:this.options_.appId,player:{container:this.options_.techId,width:800,height:300,onload:this.onReady.bind(this)}}),this.widgetPlayer=DZ.player,u(Object.getPrototypeOf(t.prototype),"initTech",this).call(this),this.onStateChange({type:-1})}},{key:"setupTriggers",value:function(){var e=this;this.widgetPlayer.vjsTech=this;for(var n=t.Events.length-1;n>=0;n--){var i=t.Events[n];DZ.Event.subscribe(i,function(t,n){e.eventHandler(c["default"].mergeOptions({type:n||t},t))})}}},{key:"ended",value:function(){return this.duration()===this.currentTime()}},{key:"enterFullScreen",value:function(){}},{key:"exitFullScreen",value:function(){}},{key:"updatePause",value:function(){this.paused_=!this.widgetPlayer.isPlaying()}},{key:"updateDuration",value:function(){var e=this.widgetPlayer.getCurrentTrack();this.duration_=e&&e.duration||0,this.trigger("durationchange")}},{key:"updateVolume",value:function(){this.volume_=this.widgetPlayer.getVolume(),this.trigger("volumechange")}},{key:"updatePoster",value:function(){var e=this;try{var t={};"string"==typeof this.options_.source?t.id=this.options_.source:"object"==typeof this.options_.source&&(t.id=this.options_.source.src),t.id=this.parseSrc(t.id),DZ.api("/track/"+t.id,function(t){e.setPoster(""+t.album.cover_big),e.update(t)})}catch(n){console.log("unable to set poster",n)}}},{key:"update",value:function(e){this.infosEl_.innerHTML=e.title}},{key:"src",value:function(e){e&&e.src||("string"==typeof this.options_.source?e=this.options_.source:"object"==typeof this.options_.source&&(e=this.options_.source.src),e=this.parseSrc(e)),this.widgetPlayer.playTracks([e])}},{key:"duration",value:function(){return this.duration_}},{key:"currentTime",value:function(){return this.currentTime_}},{key:"setCurrentTime",value:function(e){this.trigger("seeking"),this.widgetPlayer.seekTo(1e3*e)}},{key:"play",value:function(){this.widgetPlayer.play(),this.updatePause()}},{key:"pause",value:function(){this.widgetPlayer.pause(),this.updatePause()}},{key:"paused",value:function(){return this.paused_}},{key:"muted",value:function(){return this.muted_}},{key:"volume",value:function(){return this.volume_}},{key:"setVolume",value:function(e){e!==this.volume_&&(this.volume_=e,this.muted_=!this.volume_,this.widgetPlayer.setVolume(this.volume_),this.updateVolume())}},{key:"setMuted",value:function(e){this.muted_=e,this.widgetPlayer.setMute(this.muted_),this.updateVolume()}}]),t}(p["default"]);y.prototype.className_="deezer",y.prototype.options_={api:"https://cdns-files.dzcdn.net/js/min/dz.js",appId:213642,playList:!1,visibility:"hidden",children:["subPosterImage"]},y.isSupported=function(){return!0},h.withSourceHandlers(y),y.nativeSourceHandler={},y.nativeSourceHandler.canPlayType=function(e){return-1!==e.indexOf("deezer")},y.nativeSourceHandler.canHandleSource=function(e){return e.type?y.nativeSourceHandler.canPlayType(e.type):e.src?y.nativeSourceHandler.canPlayType(e.src):""},y.nativeSourceHandler.handleSource=function(e,t){t.src(e.src)},y.nativeSourceHandler.dispose=function(){},y.Events="player_loaded,player_play,player_paused,player_position,player_buffering,volume_changed,shuffle_changed,mute_changed,track_end,".split(","),y.registerSourceHandler(y.nativeSourceHandler),f.registerComponent("Deezer",y),h.registerTech("Deezer",y),n["default"]=y,t.exports=n["default"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./Externals":3}],3:[function(e,t,n){(function(e){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(n,"__esModule",{value:!0});var a=function(){function e(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)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),s=function(e,t,n){for(var i=!0;i;){var r=e,o=t,a=n;i=!1,null===r&&(r=Function.prototype);var s=Object.getOwnPropertyDescriptor(r,o);if(void 0!==s){if("value"in s)return s.value;var u=s.get;if(void 0===u)return;return u.call(a)}var l=Object.getPrototypeOf(r);if(null===l)return;e=l,t=o,n=a,i=!0,s=l=void 0}},u="undefined"!=typeof window?window.videojs:"undefined"!=typeof e?e.videojs:null,l=i(u),c=l["default"].getComponent("Component"),d=l["default"].getComponent("Tech"),p=function(e){function t(e,n){r(this,t),s(Object.getPrototypeOf(t.prototype),"constructor",this).call(this,e,n),this.params={id:this.options_.techId,autoplay:parseInt(e.autoplay),chromeless:parseInt(e.controls),html:1,info:1,logo:1,controls:"html",wmode:"opaque",format:"json",url:e.source.src},"file:"!==window.location.protocol&&(this.params.origin=window.location.protocol+"//"+window.location.hostname),this.videoId=this.parseSrc(e.source.src),setTimeout(function(){this.loadApi()}.bind(this))}return o(t,e),a(t,[{key:"injectCss",value:function(e){var t=".vjs-"+this.className_+" .vjs-iframe-blocker { display: none; }\n .vjs-"+this.className_+".vjs-user-inactive .vjs-iframe-blocker { display: block; }\n .vjs-"+this.className_+" .vjs-poster { background-size: cover; }";e&&(t+=e);var n=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css",i.styleSheet?i.styleSheet.cssText=t:i.appendChild(document.createTextNode(t)),n.appendChild(i)}},{key:"parseSrc",value:function(e){return e}},{key:"createEl",value:function(e,t,n){var i=l["default"].createEl("div",{id:"vjs-tech"+this.options_.techId,className:"vjs-tech vjs-tech-"+this.className_}),r=l["default"].createEl(e,l["default"].mergeOptions({id:this.options_.techId,scrolling:"no",marginWidth:0,marginHeight:0,frameBorder:0,webkitAllowFullScreen:"",mozallowfullscreen:"",allowFullScreen:""},t));r.style.visibility=this.options_.visibility,r.style.width="100%",r.style.height="100%",r.style.top="0",r.style.left="0",r.style.position="absolute",i.appendChild(r);var o=this.isOnMobile();if(!o&&n!==!1||n){var a=l["default"].createEl("div",{className:"vjs-iframe-blocker",style:"position:absolute;top:0;left:0;width:100%;height:100%"});l["default"].on(a,"click",l["default"].bind(this,this.togglePlayPause)),l["default"].on(a,"tap",l["default"].bind(this,this.togglePlayPause)),l["default"].on(a,"touchend",l["default"].bind(this,this.togglePlayPause)),i.appendChild(a)}var s=(0,l["default"])(this.options_.playerId);return s.addClass("vjs-"+this.className_),o&&s.addClass("vjs-"+this.className_+"-mobile"),i}},{key:"togglePlayPause",value:function(){this.paused()?this.play():this.pause()}},{key:"isOnMobile",value:function(){return l["default"].browser.IS_EDGE||l["default"].browser.IS_ANDROID||l["default"].browser.IS_IOS}},{key:"addScriptTag",value:function(){var e=!1,t=this,n=document,i=n.getElementsByTagName("head")[0]||n.documentElement,r=n.createElement("script");r.async=!0,r.type="text/javascript",r.onload=r.onreadystatechange=function(){var n=this.readyState;e||n&&!/loaded|complete/.test(n)||(e=!0,r.onload=r.onreadystatechange=null,t.initTech())},r.src=this.options_.api,i.insertBefore(r,i.firstChild)}},{key:"loadApi",value:function(){this.isApiReady()?this.initTech():(t.apiReadyQueue.push(this),this.addScriptTag(),this.injectCss())}},{key:"isApiReady",value:function(){return!1}},{key:"initTech",value:function(){this.setupTriggers()}},{key:"setupTriggers",value:function(){this.widgetPlayer.vjsTech=this;for(var e=t.Events.length-1;e>=0;e--){var n=l["default"].bind(this,this.eventHandler);this.widgetPlayer.addEventListener(t.Events[e],n)}}},{key:"eventHandler",value:function(e){e&&(this.onStateChange(e),this.trigger(e))}},{key:"onStateChange",value:function(e){var t=e.type;switch(this.lastState=t,t){case-1:this.trigger("loadstart"),this.trigger("waiting");break;case"apiready":this.trigger("loadedmetadata"),this.onReady(),this.trigger("durationchange");break;case"ended":break;case"play":this.trigger("playing");break;case"pause":break;case"seeked":break;case"timeupdate":break;case"error":this.onPlayerError()}}},{key:"onReady",value:function(){this.triggerReady()}},{key:"poster",value:function(){return this.poster_}},{key:"setPoster",value:function(e){this.poster_=e,this.trigger("posterchange")}},{key:"src",value:function(e){return"undefined"!=typeof e&&(this.src_=this.parseSrc(e)),this.src_}},{key:"currentSrc",value:function(){return this.src_}},{key:"play",value:function(){}},{key:"ended",value:function(){return this.isReady_?0===this.lastState:!1}},{key:"pause",value:function(){}},{key:"paused",value:function(){return!1}},{key:"currentTime",value:function(){return 0}},{key:"setCurrentTime",value:function(e){this.currentTime=e}},{key:"duration",value:function(){return 0}},{key:"volume",value:function(){return this.volume_}},{key:"enterFullScreen",value:function(){}},{key:"exitFullScreen",value:function(){}},{key:"setVolume",value:function(e){"undefined"!=typeof e&&e!==this.volume_&&(this.volume_=e,this.trigger("volumechange"))}},{key:"buffered",value:function(){return[]}},{key:"controls",value:function(){return!1}},{key:"muted",value:function(){return this.muted_}},{key:"setMuted",value:function(e){this.muted_=e}},{key:"supportsFullScreen",value:function(){return!0}},{key:"onPlayerError",value:function(e){this.errorNumber=e.data,this.trigger("error")}},{key:"error",value:function(){return{code:"External unknown error ("+this.errorNumber+")"}}}]),t}(d);p.prototype.className_=" vjs-externals",p.prototype.widgetPlayer={},p.prototype.options_={visibility:"hidden"},p.apiReadyQueue=[],p.prototype.featuresVolumeControl=!0,p.prototype.featuresPlaybackRate=!1,p.prototype.movingMediaElementInDOM=!1,p.prototype.featuresFullscreenResize=!1,p.prototype.featuresTimeupdateEvents=!1,p.prototype.featuresProgressEvents=!1,p.prototype.featuresNativeTextTracks=!0,p.prototype.featuresNativeAudioTracks=!0,p.prototype.featuresNativeVideoTracks=!1,p.Events="apiready,ad_play,ad_start,ad_timeupdate,ad_pause,ad_end,video_start,\n 'video_end,play,playing,pause,ended,canplay,canplaythrough,timeupdate,progress,seeking,\n 'seeked,volumechange,durationchange,fullscreenchange,error".split(","),c.registerComponent("Externals",p),d.registerTech("Externals",p),n["default"]=p,t.exports=n["default"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],4:[function(e,t,n){(function(i){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(n,"__esModule",{value:!0});var s=function(){function e(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)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),u=function(e,t,n){for(var i=!0;i;){var r=e,o=t,a=n;i=!1,null===r&&(r=Function.prototype);var s=Object.getOwnPropertyDescriptor(r,o);if(void 0!==s){if("value"in s)return s.value;var u=s.get;if(void 0===u)return;return u.call(a)}var l=Object.getPrototypeOf(r);if(null===l)return;e=l,t=o,n=a,i=!0,s=l=void 0}},l="undefined"!=typeof window?window.videojs:"undefined"!=typeof i?i.videojs:null,c=r(l),d=e("./Externals"),p=r(d),f=c["default"].getComponent("Component"),h=c["default"].getComponent("Tech"),y=function(e){function t(e,n){o(this,t),u(Object.getPrototypeOf(t.prototype),"constructor",this).call(this,e,n)}return a(t,e),s(t,[{key:"injectCss",value:function(){var e=".vjs-"+this.className_+" > .vjs-poster { display:block; width:50%; }\n .vjs-"+this.className_+" .vjs-tech { }\n .vjs-"+this.className_+" .vjs-tech > .vjs-poster { display:block; }\n .vjs-"+this.className_+".vjs-has-started .vjs-poster {display:block;}\n .vjs-soundcloud-info{position:absolute;display: flex;justify-content: center;align-items: center;left:50%;top:0;right:0;bottom:0;\n text-align: center; pointer-events: none; text-shadow: 0px 0px 5px rgba(0, 0, 0, 0.69);}";u(Object.getPrototypeOf(t.prototype),"injectCss",this).call(this,e)}},{key:"createEl",value:function(){var e=null;"string"==typeof this.options_.source?e=this.options_.source:"object"==typeof this.options_.source&&(e=this.options_.source.src);var n=u(Object.getPrototypeOf(t.prototype),"createEl",this).call(this,"iframe",{width:"100%",height:"100%",src:"https://w.soundcloud.com/player/?url="+e+"&auto_play="+this.options_.autoplay+"\n &buying=false&liking=false&sharing=false&show_comments=false&show_playcount=false&show_user=false"});return this.infosEl_=c["default"].createEl("div",{className:"vjs-soundcloud-info"}),n.firstChild.style.visibility=this.options_.visibility,n.appendChild(this.infosEl_),n}},{key:"isApiReady",value:function(){return window.SC}},{key:"onStateChange",value:function(e){var t=e.type;switch(t){case-1:this.trigger("loadstart"),this.trigger("waiting");break;case SC.Widget.Events.READY:this.trigger("loadedmetadata"),this.trigger("durationchange"),this.trigger("canplay"),this.onReady();break;case SC.Widget.Events.FINISH:this.updatePause(),this.trigger("ended");break;case SC.Widget.Events.PLAY:this.updatePause(),this.trigger("play"),this.trigger("waiting");break;case SC.Widget.Events.PLAY_PROGRESS:this.trigger("canplay"),this.trigger("playing"),this.currentTime_=1e3*this.duration_*e.relativePosition/1e3;break;case SC.Widget.Events.PAUSE:this.updatePause(),this.trigger("pause");break;case SC.Widget.Events.SEEK:this.trigger("seeked");break;case SC.Widget.Events.LOAD_PROGRESS:this.trigger("timeupdate");break;case SC.Widget.Events.ERROR:this.onPlayerError()}}},{key:"parseSrc",value:function(e){if(e){var t=/^(https?:\/\/)?(www.|api.)?soundcloud.com\//i,n=e.match(t);return n?n[5]||n[3]:null}}},{key:"onReady",value:function(){u(Object.getPrototypeOf(t.prototype),"onReady",this).call(this),this.updatePause(),this.updateDuration(),this.updateVolume(),this.updatePoster()}},{key:"initTech",value:function(){this.widgetPlayer=SC.Widget(this.options_.techId),u(Object.getPrototypeOf(t.prototype),"initTech",this).call(this),this.onStateChange({type:-1})}},{key:"setupTriggers",value:function(){var e=this;this.widgetPlayer.vjsTech=this;for(var n=function(){var n=t.Events[i];e.widgetPlayer.bind(n,function(t){e.eventHandler(c["default"].mergeOptions({type:n},t))})},i=t.Events.length-1;i>=0;i--)n()}},{key:"ended",value:function(){return this.duration()===this.currentTime()}},{key:"enterFullScreen",value:function(){this.widgetPlayer.webkitEnterFullScreen()}},{key:"exitFullScreen",value:function(){this.widgetPlayer.webkitExitFullScreen()}},{key:"updatePause",value:function(){var e=this;this.widgetPlayer.isPaused(function(t){e.paused_=t})}},{key:"updateDuration",value:function(){var e=this;this.widgetPlayer.getDuration(function(t){e.duration_=t/1e3,e.trigger("durationchange")})}},{key:"updateVolume",value:function(){var e=this;this.widgetPlayer.getVolume(function(t){e.volume_=t,e.trigger("volumechange")})}},{key:"updatePoster",value:function(){var e=this;try{this.widgetPlayer.getCurrentSound(function(t){t&&(e.setPoster(t.artwork_url.replace("large.jpg","t500x500.jpg")),e.subPosterImage.update(t.waveform_url.replace("wis","w1").replace("json","png")),e.update(t))})}catch(t){console.log("unable to set poster",t)}}},{key:"update",value:function(e){this.infosEl_.innerHTML=e.title}},{key:"src",value:function(e){this.widgetPlayer.load(e,{auto_play:this.options_.autoplay})}},{key:"duration",value:function(){return this.duration_}},{key:"currentTime",value:function(){return this.currentTime_}},{key:"setCurrentTime",value:function(e){this.trigger("seeking"),this.widgetPlayer.seekTo(1e3*e)}},{key:"play",value:function(){this.widgetPlayer.play(),this.updatePause()}},{key:"pause",value:function(){this.widgetPlayer.pause(),this.updatePause()}},{key:"paused",value:function(){return this.paused_}},{key:"muted",value:function(){return this.muted_}},{key:"volume",value:function(){return this.volume_}},{key:"setVolume",value:function(e){e!==this.volume_&&(this.volume_=e,this.muted_=!this.volume_,this.widgetPlayer.setVolume(this.volume_),this.updateVolume())}},{key:"setMuted",value:function(e){this.muted_=e,this.widgetPlayer.setVolume(this.muted_?0:this.volume_),this.updateVolume()}}]),t}(p["default"]);y.prototype.className_="soundcloud",y.prototype.options_={api:"//w.soundcloud.com/player/api.js",visibility:"hidden",children:["subPosterImage"]},y.isSupported=function(){return!0},h.withSourceHandlers(y),y.nativeSourceHandler={},y.nativeSourceHandler.canPlayType=function(e){return-1!==e.indexOf("soundcloud")},y.nativeSourceHandler.canHandleSource=function(e){return e.type?y.nativeSourceHandler.canPlayType(e.type):e.src?y.nativeSourceHandler.canPlayType(e.src):""},y.nativeSourceHandler.handleSource=function(e,t){t.src(e.src)},y.nativeSourceHandler.dispose=function(){},y.Events="ready,play,playProgress,loadProgress,pause,seek,finish,error".split(","),y.registerSourceHandler(y.nativeSourceHandler),f.registerComponent("Soundcloud",y),h.registerTech("Soundcloud",y),n["default"]=y,t.exports=n["default"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./Externals":3}],5:[function(e,t,n){(function(i){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(n,"__esModule",{value:!0});var s=function(){function e(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)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),u=function(e,t,n){for(var i=!0;i;){var r=e,o=t,a=n;i=!1,null===r&&(r=Function.prototype);var s=Object.getOwnPropertyDescriptor(r,o);if(void 0!==s){if("value"in s)return s.value;var u=s.get;if(void 0===u)return;return u.call(a)}var l=Object.getPrototypeOf(r);if(null===l)return;e=l,t=o,n=a,i=!0,s=l=void 0}},l="undefined"!=typeof window?window.videojs:"undefined"!=typeof i?i.videojs:null,c=r(l),d=e("./Externals"),p=r(d),f=c["default"].getComponent("Component"),h=c["default"].getComponent("Tech"),y=function(e){function t(e,n){o(this,t),u(Object.getPrototypeOf(t.prototype),"constructor",this).call(this,e,n)}return a(t,e),s(t,[{key:"createEl",value:function(){var e=null;"string"==typeof this.options_.source?e=this.options_.source:"object"==typeof this.options_.source&&(e=this.options_.source.src);var n=u(Object.getPrototypeOf(t.prototype),"createEl",this).call(this,"iframe",{width:"100%",height:"100%",src:"https://embed.spotify.com/?uri="+e},!1);n.firstChild.style.visibility=this.options_.visibility;var i=(0,c["default"])(this.options_.playerId);return i.controls(!1),n}},{key:"addScriptTag",value:function(){this.initTech()}},{key:"isApiReady",value:function(){return!0}},{key:"parseSrc",value:function(e){return e}},{key:"setupTriggers",value:function(){}},{key:"ended",value:function(){return!1}},{key:"play",value:function(){}},{key:"pause",value:function(){}},{key:"enterFullScreen",value:function(){}},{key:"exitFullScreen",value:function(){}},{key:"src",value:function(e){this.el_.src(e)}}]),t}(p["default"]);y.prototype.className_="spotify",y.prototype.options_={api:"",visibility:"show"},y.isSupported=function(){return!0},h.withSourceHandlers(y),y.nativeSourceHandler={},y.nativeSourceHandler.canPlayType=function(e){return-1!==e.indexOf("spotify")},y.nativeSourceHandler.canHandleSource=function(e){return e.type?y.nativeSourceHandler.canPlayType(e.type):e.src?y.nativeSourceHandler.canPlayType(e.src):""},y.nativeSourceHandler.handleSource=function(e,t){t.src(e.src)},y.nativeSourceHandler.dispose=function(){},y.Events="".split(","),y.registerSourceHandler(y.nativeSourceHandler),f.registerComponent("Spotify",y),h.registerTech("Spotify",y),n["default"]=y,t.exports=n["default"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./Externals":3}],6:[function(e,t,n){(function(i){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(n,"__esModule",{value:!0});var s=function(){function e(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)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),u=function(e,t,n){for(var i=!0;i;){var r=e,o=t,a=n;i=!1,null===r&&(r=Function.prototype);var s=Object.getOwnPropertyDescriptor(r,o);if(void 0!==s){if("value"in s)return s.value;var u=s.get;if(void 0===u)return;return u.call(a)}var l=Object.getPrototypeOf(r);if(null===l)return;e=l,t=o,n=a,i=!0,s=l=void 0}},l="undefined"!=typeof window?window.videojs:"undefined"!=typeof i?i.videojs:null,c=r(l),d=e("./Externals"),p=r(d),f=c["default"].getComponent("Component"),h=c["default"].getComponent("Tech"),y=function(e){function t(e,n){o(this,t),u(Object.getPrototypeOf(t.prototype),"constructor",this).call(this,e,n)}return a(t,e),s(t,[{key:"createEl",value:function(){var e=null;"string"==typeof this.options_.source?e=this.options_.source:"object"==typeof this.options_.source&&(e=this.options_.source.src),e=this.parseSrc(e);var n=u(Object.getPrototypeOf(t.prototype),"createEl",this).call(this,"iframe",{id:this.options_.techId,src:this.options_.embed+"/"+e+"??api=1&player_id="+this.options_.techId+"&fullscreen=1&autoplay="+this.options_.autoplay}),i=(0,c["default"])(this.options_.playerId);return i.controls(!1),n}},{key:"parseSrc",value:function(e){if(e){var t=/^.*(vimeo\.com\/)((channels\/[A-z]+\/)|(groups\/[A-z]+\/videos\/))?([0-9]+)/,n=e.match(t);if(n&&n[5])return n[5]}}},{key:"isApiReady",value:function(){return window.Vimeo&&window.Vimeo.Player}},{key:"initTech",value:function(){if(this.isApiReady()){var e=null;"string"==typeof this.options_.source?e=this.options_.source:"object"==typeof this.options_.source&&(e=this.options_.source.src),e=this.parseSrc(e);var n=c["default"].mergeOptions(this.options_,{id:e,byline:0,color:"#00adef",portrait:0,controls:0,fullscreen:1});this.widgetPlayer=new window.Vimeo.Player(this.options_.techId,n),this.widgetPlayer.ready().then(c["default"].bind(this,this.onReady)),u(Object.getPrototypeOf(t.prototype),"initTech",this).call(this),this.onStateChange({type:-1})}}},{key:"setupTriggers",value:function(){var e=this;this.widgetPlayer.vjsTech=this;for(var n=function(){var n=t.Events[i];e.widgetPlayer.on(n,function(t){e.eventHandler(c["default"].mergeOptions({type:n},t))})},i=t.Events.length-1;i>=0;i--)n()}},{key:"onStateChange",value:function(e){var n=e.type;switch(this.lastState=n,u(Object.getPrototypeOf(t.prototype),"onStateChange",this).call(this,e),e.volume&&(this.volume_=e.volume),e.duration&&(this.duration_=e.duration),e.seconds&&(this.currentTime_=e.seconds),e.percent&&(this.buffered_=e.percent),n){case"loaded":this.trigger("loadedmetadata"),this.trigger("durationchange"),this.trigger("canplay");break;case"onLoadProgress":this.trigger("progress"),this.trigger("durationchange");break;case"playProgress":this.trigger("timeupdate")}}},{key:"updateVolume",value:function(){var e=this;this.widgetPlayer.getVolume().then(function(t){e.volume_=t,e.trigger("volumechange")})}},{key:"updateEnded",value:function(){var e=this;this.widgetPlayer.getEnded().then(function(t){e.ended_=t})}},{key:"updatePaused",value:function(){var e=this;this.widgetPlayer.getPaused().then(function(t){e.paused_=t})}},{key:"updateDuration",value:function(){var e=this;this.widgetPlayer.getDuration().then(function(t){e.duration_=t})}},{key:"buffered",value:function(){return c["default"].createTimeRange(0,this.buffered_*this.duration_||0)}},{key:"ended",value:function(){return this.ended_}},{key:"duration",value:function(){return this.duration_}},{key:"currentTime",value:function(){return this.currentTime_}},{key:"setCurrentTime",value:function(e){var t=this;this.widgetPlayer.setCurrentTime(e).then(function(e){t.currentTime_=e})}},{key:"play",value:function(){this.widgetPlayer.play()}},{key:"pause",value:function(){this.widgetPlayer.pause()}},{key:"paused",value:function(){return this.paused_}},{key:"muted",value:function(){return this.muted_}},{key:"volume",value:function(){return this.volume_; }},{key:"setVolume",value:function(e){var t=this;e!==this.volume_&&this.widgetPlayer.setVolume(e).then(function(){t.updateVolume()})}},{key:"setMuted",value:function(e){this.muted_=e,e&&(this.volumeBefore_=this.volume_),this.setVolume(e?0:this.volumeBefore_)}}]),t}(p["default"]);y.prototype.options_={api:"//player.vimeo.com/api/player.js",embed:"//player.vimeo.com/video",visibility:"visible"},y.prototype.className_="Vimeo",y.isSupported=function(){return!0},h.withSourceHandlers(y),y.nativeSourceHandler={},y.nativeSourceHandler.canPlayType=function(e){return-1!==e.indexOf("vimeo")},y.nativeSourceHandler.canHandleSource=function(e){return e.type?y.nativeSourceHandler.canPlayType(e.type):e.src?y.nativeSourceHandler.canPlayType(e.src):""},y.nativeSourceHandler.handleSource=function(e,t){t.src(e.src)},y.nativeSourceHandler.dispose=function(){},y.registerSourceHandler(y.nativeSourceHandler),y.Events="loaded,play,ended,timeupdate,progress,seeked,texttrackchange,cuechange,volumechange,error".split(","),f.registerComponent("Vimeo",y),h.registerTech("Vimeo",y),n["default"]=y,t.exports=n["default"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./Externals":3}],7:[function(e,t,n){(function(i){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(n,"__esModule",{value:!0});var s=function(){function e(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)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),u=function(e,t,n){for(var i=!0;i;){var r=e,o=t,a=n;i=!1,null===r&&(r=Function.prototype);var s=Object.getOwnPropertyDescriptor(r,o);if(void 0!==s){if("value"in s)return s.value;var u=s.get;if(void 0===u)return;return u.call(a)}var l=Object.getPrototypeOf(r);if(null===l)return;e=l,t=o,n=a,i=!0,s=l=void 0}},l="undefined"!=typeof window?window.videojs:"undefined"!=typeof i?i.videojs:null,c=r(l),d=e("./Externals"),p=r(d),f=e("global/window"),h=r(f),y=c["default"].getComponent("Component"),v=c["default"].getComponent("Tech"),g=function(e){function t(e,n){o(this,t),u(Object.getPrototypeOf(t.prototype),"constructor",this).call(this,e,n)}return a(t,e),s(t,[{key:"createEl",value:function(){var e=u(Object.getPrototypeOf(t.prototype),"createEl",this).call(this,"div",{id:this.options_.techId});return e}},{key:"injectCss",value:function(){var e=".vjs-"+this.className_+" .vjs-big-play-button { display: none; }";u(Object.getPrototypeOf(t.prototype),"injectCss",this).call(this,e)}},{key:"loadApi",value:function(){u(Object.getPrototypeOf(t.prototype),"loadApi",this).call(this),h["default"].onYouTubeIframeAPIReady=this.onYoutubeReady.bind(this)}},{key:"onStateChange",value:function(e){var t=e.data;switch(t){case-1:this.trigger("loadstart"),this.trigger("loadedmetadata"),this.trigger("durationchange");break;case YT.PlayerState.PLAYING:this.trigger("timeupdate"),this.trigger("durationchange"),this.trigger("playing"),this.trigger("play"),this.isSeeking&&this.onSeeked();break;case YT.PlayerState.ENDED:this.trigger("ended");break;case YT.PlayerState.PAUSED:this.trigger("canplay"),this.isSeeking?this.onSeeked():this.trigger("pause");break;case YT.PlayerState.BUFFERING:this.trigger("timeupdate"),this.trigger("waiting")}this.lastState=t}},{key:"parseSrc",value:function(e){if(e){var t=/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/,n=e.match(t);if(n&&11===n[2].length)return n[2]}}},{key:"onReady",value:function(){u(Object.getPrototypeOf(t.prototype),"onReady",this).call(this),this.updateVolume()}},{key:"isApiReady",value:function(){return h["default"].YT&&h["default"].YT.Player}},{key:"onYoutubeReady",value:function(){YT.ready(function(){for(var e=0;e<p["default"].apiReadyQueue.length;++e)p["default"].apiReadyQueue[e].initTech()}.bind(this))}},{key:"initTech",value:function(){if(this.isApiReady()){var e=null;"string"==typeof this.options_.source?e=this.options_.source:"object"==typeof this.options_.source&&(e=this.options_.source.src),e=this.parseSrc(e);var n=c["default"].mergeOptions(this.options_,{controls:0,playsinline:1,rel:0,showinfo:0,autohide:1,disablekb:1,end:0,modestbranding:1,fs:1});this.widgetPlayer=new YT.Player(this.options_.techId,{videoId:e,playerVars:n,events:{onReady:this.onReady.bind(this),onPlaybackQualityChange:this.onPlayerPlaybackQualityChange.bind(this),onStateChange:this.onStateChange.bind(this),onError:this.onPlayerError.bind(this)}}),u(Object.getPrototypeOf(t.prototype),"initTech",this).call(this)}}},{key:"setupTriggers",value:function(){}},{key:"onPlayerPlaybackQualityChange",value:function(){}},{key:"src",value:function(e){e&&e.src&&(this.url=this.parseSrc(e.src),this.options_.poster||this.url&&this.setPoster("//img.youtube.com/vi/"+this.url+"/0.jpg"))}},{key:"ended",value:function(){return this.widgetPlayer?this.lastState===YT.PlayerState.ENDED:!1}},{key:"duration",value:function(){return this.widgetPlayer?this.widgetPlayer.getDuration():0}},{key:"currentTime",value:function(){return this.widgetPlayer&&this.widgetPlayer.getCurrentTime()}},{key:"setCurrentTime",value:function(e){this.lastState===YT.PlayerState.PAUSED&&(this.timeBeforeSeek=this.currentTime()),this.isSeeking||(this.wasPausedBeforeSeek=this.paused()),this.widgetPlayer.seekTo(e,!0),this.trigger("timeupdate"),this.trigger("seeking"),this.isSeeking=!0,this.lastState===YT.PlayerState.PAUSED&&this.timeBeforeSeek!==e&&(this.clearInterval(this.checkSeekedInPauseInterval),this.checkSeekedInPauseInterval=this.setInterval(function(){this.lastState===YT.PlayerState.PAUSED&&this.isSeeking?this.currentTime()!==this.timeBeforeSeek&&(this.trigger("timeupdate"),this.onSeeked()):this.clearInterval(this.checkSeekedInPauseInterval)}.bind(this),250))}},{key:"onSeeked",value:function(){this.clearInterval(this.checkSeekedInPauseInterval),this.isSeeking=!1,this.wasPausedBeforeSeek&&this.pause(),this.trigger("seeked")}},{key:"updateVolume",value:function(){this.volume_=this.widgetPlayer.getVolume(),this.trigger("volumechange")}},{key:"play",value:function(){this.widgetPlayer.playVideo()}},{key:"pause",value:function(){this.widgetPlayer.pauseVideo()}},{key:"paused",value:function(){return this.widgetPlayer&&this.lastState!==YT.PlayerState.PLAYING&&this.lastState!==YT.PlayerState.BUFFERING}},{key:"muted",value:function(){return this.muted_}},{key:"volume",value:function(){return this.widgetPlayer&&this.widgetPlayer.getVolume()/100}},{key:"setVolume",value:function(e){e!==this.volume_&&(this.widgetPlayer.setVolume(100*e),this.updateVolume())}},{key:"setMuted",value:function(e){this.muted_=e,e&&(this.volumeBefore_=this.volume_),this.widgetPlayer.setVolume(e?0:this.volumeBefore_),this.updateVolume()}}]),t}(p["default"]);g.prototype.options_={api:"//www.youtube.com/iframe_api",visibility:"visible"},g.prototype.className_="youtube",g.isSupported=function(){return!0},v.withSourceHandlers(g),g.nativeSourceHandler={},g.nativeSourceHandler.canPlayType=function(e){return-1!==e.indexOf("youtube")},g.nativeSourceHandler.canHandleSource=function(e){return e.type?g.nativeSourceHandler.canPlayType(e.type):e.src?g.nativeSourceHandler.canPlayType(e.src):""},g.nativeSourceHandler.handleSource=function(e,t){t.src(e.src)},g.nativeSourceHandler.dispose=function(){},g.Events="ready,play,playProgress,loadProgress,pause,seek,finish,error".split(","),g.registerSourceHandler(g.nativeSourceHandler),y.registerComponent("Youtube",g),v.registerTech("Youtube",g),n["default"]=g,t.exports=n["default"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./Externals":3,"global/window":8}],8:[function(e,t,n){(function(e){"undefined"!=typeof window?t.exports=window:"undefined"!=typeof e?t.exports=e:"undefined"!=typeof self?t.exports=self:t.exports={}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],9:[function(e,t,n){"use strict";e("./tech/Externals"),e("./tech/Youtube"),e("./tech/Deezer"),e("./tech/Spotify"),e("./tech/Vimeo"),e("./tech/Soundcloud"),e("./component/sub-poster-image")},{"./component/sub-poster-image":1,"./tech/Deezer":2,"./tech/Externals":3,"./tech/Soundcloud":4,"./tech/Spotify":5,"./tech/Vimeo":6,"./tech/Youtube":7}]},{},[9])(9)});