text: var VueAudioSoundcloud=function(t){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t;const e=t=>{let e=new Date(t).toISOString().substr(11,8);return 0===e.indexOf("00:")?e.substr(3):e};const i={name:"vue-audio-soundcloud",props:{elements:{type:Object,default:{}},defaultVolume:{type:Number,default:100}},data:()=>({currentTrack:{},duration:{current:"00:00",total:"--:--"},els:{},list:[],listPosition:{},isDraggable:!1,isLoading:!1,isLoop:!1,isMuted:!1,isPlaying:!1,progression:0,seekToShortcutAvailable:!0,volume:100,widget:{}}),methods:{finished(){if("track"===this.isLoop)return this.widget.seekTo(0),this.play();this.next(),(this.list&&this.list.length<=0||this.list&&this.list.length>0&&!this.isLoop)&&this.pause()},load({track:t,list:e}){this.isLoading=!0,this.loadList(t,e),this.loadTrack(t)},loadList(t,e){if(!e)return this.list=[],this.listPosition=!1;this.list=e,this.setListPosition(e.findIndex(e=>e.id===t.id))},loadTrack(t){this.currentTrack=t,this.progression=0,this.duration.total=e(t.duration),this.loadWidget(t)},loadWidget(t){this.widget.load(t.uri,{show_artwork:!1,show_comments:!1,show_playcount:!1,show_user:!1,buying:!1,sharing:!1,auto_play:!0,callback:()=>{this.isLoading=!1,this.isPlaying=!0,this.isMuted?this.widget.setVolume(0):this.widget.setVolume(this.volume),this.$emit("load",this.currentTrack.id)}})},loop(){let t=[!1,"track","list"];this.list.length>0?(this.isLoop="list"===this.isLoop?t[0]:t[t.indexOf(this.isLoop)+1],this.setListPosition()):this.isLoop="track"===this.isLoop?t[0]:t[t.indexOf(this.isLoop)+1]},mute(){this.isMuted=!0,this.widget.setVolume(0)},next(){this.list&&this.list.length>0&&("list"===this.isLoop&&this.listPosition.current===this.list.length-1?(this.setListPosition(0),this.loadTrack(this.list[this.listPosition.current])):this.listPosition.current>=0&&this.listPosition.current<this.list.length-1&&(this.setListPosition(this.listPosition.current+1),this.loadTrack(this.list[this.listPosition.current])))},pause(){this.widget.pause(),this.isPlaying=!1,this.$emit("pause")},play(){this.widget&&Object.keys(this.currentTrack).length>0&&(this.widget.play(),this.isPlaying=!0,this.$emit("play"))},previous(){this.list&&this.list.length>0&&this.widget.getPosition(t=>{if(t/1e3>10)return this.widget.seekTo(0);"list"===this.isLoop&&0===this.listPosition.current?(this.setListPosition(this.list.length-1),this.loadTrack(this.list[this.listPosition.current])):this.listPosition.current>0&&(this.setListPosition(this.listPosition.current-1),this.loadTrack(this.list[this.listPosition.current]))})},fastBackward(){this.widget.getPosition(t=>{this.seekToShortcutAvailable&&(t>=5e3?this.widget.seekTo(t-5e3):this.widget.seekTo(0),this.seekToShortcutAvailable=!1,setTimeout(()=>{this.seekToShortcutAvailable=!0},200))})},fastForward(){this.widget.getPosition(t=>{this.seekToShortcutAvailable&&(this.widget.seekTo(t+5e3),this.seekToShortcutAvailable=!1,setTimeout(()=>{this.seekToShortcutAvailable=!0},200))})},setListPosition(t){this.listPosition||(this.listPosition={}),this.listPosition.current=void 0!==t?t:this.listPosition.current,this.listPosition.first=this.listPosition.current<=0&&"list"!==this.isLoop,this.listPosition.last=this.listPosition.current===this.list.length-1&&"list"!==this.isLoop},setTime(t,e){this.widget.getDuration(i=>{this.widget.seekTo(parseInt(t.offsetX/e.offsetWidth*i))})},setVolume(t,e){this.volume=parseInt(t.offsetX/e.offsetWidth*100),this.widget.setVolume(this.volume),this.isMuted&&(this.isMuted=!1),0===this.volume&&(this.isMuted=!0)},unmute(){0===this.volume&&(this.volume=10),this.isMuted=!1,this.widget.setVolume(this.volume)},_handleMouseUp(){this.isDraggable=!1},_handleTimelineClick(t){this.isDraggable=!0,this.setTime(t,this.els.timeline)},_handleTimelineMove(t){this.isDraggable&&this.setTime(t,this.els.timeline)},_handleVolumeClick(t){this.isDraggable=!0,this.setVolume(t,this.els.volume)},_handleVolumeMove(t){this.isDraggable&&this.setVolume(t,this.els.volume)},_shortcuts(t){let e=t.which||t.keyCode;32===e?(t.preventDefault(),this.isPlaying?this.pause():this.play()):77===e?this.isMuted?this.unmute():this.mute():37===e&&t.shiftKey?this.previous():39===e&&t.shiftKey?this.next():37===e?this.fastBackward():39===e?this.fastForward():38===e&&t.shiftKey?(this.volume<=95?this.volume+=5:this.volume=100,this.widget.setVolume(this.volume)):40===e&&t.shiftKey&&(this.volume>=5?this.volume-=5:this.volume=0,this.widget.setVolume(this.volume))}},created(){t.prototype.$AudioSoundcloud={load:t=>this.load(t),pause:()=>this.pause(),play:()=>this.play()}},mounted(){this.volume=this.defaultVolume,this.widget=SC.Widget("soundcloud-iframe"),this.els.timeline=document.getElementById(this.elements.timeline),this.els.volume=document.getElementById(this.elements.volume),this.widget.bind(SC.Widget.Events.READY,()=>{this.widget.bind(SC.Widget.Events.FINISH,()=>{this.finished()}),this.widget.bind(SC.Widget.Events.PAUSE,()=>{this.isPlaying=!1,this.$emit("pause")}),this.widget.bind(SC.Widget.Events.PLAY,()=>{this.isPlaying=!0,this.$emit("play")}),this.widget.bind(SC.Widget.Events.PLAY_PROGRESS,t=>{this.progression=100*t.relativePosition,this.duration.current=e(t.currentPosition)}),this.els.timeline&&(this.els.timeline.addEventListener("mousedown",this._handleTimelineClick),this.els.timeline.addEventListener("mousemove",this._handleTimelineMove)),this.els.volume&&(this.els.volume.addEventListener("mousedown",this._handleVolumeClick),this.els.volume.addEventListener("mousemove",this._handleVolumeMove)),document.addEventListener("mouseup",this._handleMouseUp),document.addEventListener("keydown",this._shortcuts)})},beforeDestoy(){this.widget.unbind(SC.Widget.Events.FINISH),this.widget.unbind(SC.Widget.Events.PAUSE),this.widget.unbind(SC.Widget.Events.PLAY),this.widget.unbind(SC.Widget.Events.PLAY_PROGRESS),this.widget.unbind(SC.Widget.Events.READY),this.els.timeline&&(this.els.timeline.removeEventListener("mousedown",this._handleTimelineClick),this.els.timeline.removeEventListener("mousemove",this._handleTimelineMove)),this.els.volume&&(this.els.volume.removeEventListener("mousedown",this._handleVolumeClick),this.els.volume.removeEventListener("mousemove",this._handleVolumeMove)),document.removeEventListener("mouseup",this._handleMouseUp),document.removeEventListener("keydown",this._shortcuts)}};var s=function(){var t=this,e=t.$createElement,i=t._self._c||e;return i("div",[i("iframe",{attrs:{id:"soundcloud-iframe",width:"100%",height:"166",scrolling:"no",frameborder:"no",allow:"autoplay",src:"https://w.soundcloud.com/player/?url="}}),t._v(" "),t._t("default",null,null,{currentTrack:t.currentTrack,duration:t.duration,listPosition:t.listPosition,loop:t.loop,isLoading:t.isLoading,isLoop:t.isLoop,isMuted:t.isMuted,isPlaying:t.isPlaying,mute:t.mute,next:t.next,play:t.play,pause:t.pause,previous:t.previous,progression:t.progression,fastBackward:t.fastBackward,fastForward:t.fastForward,unmute:t.unmute,volume:t.volume})],2)};s._withStripped=!0;var o=function(t,e,i,s,o,n,l,d){const u=("function"==typeof i?i.options:i)||{};u.__file="/Users/flavio/Desktop/Projects/vue-audio-soundcloud/src/Player.vue",u.render||(u.render=t.render,u.staticRenderFns=t.staticRenderFns,u._compiled=!0,o&&(u.functional=!0)),u._scopeId=s;{let t;if(e&&(t=function(t){e.call(this,l(t))}),void 0!==t)if(u.functional){const e=u.render;u.render=function(i,s){return t.call(s),e(i,s)}}else{const e=u.beforeCreate;u.beforeCreate=e?[].concat(e,t):[t]}}return u}({render:s,staticRenderFns:[]},function(t){t&&t("data-v-dfb1f676_0",{source:"\n#soundcloud-iframe[data-v-dfb1f676] {\n  left: 99999px;\n  position: fixed;\n  top: 0;\n}\n",map:{version:3,sources:["/Users/flavio/Desktop/Projects/vue-audio-soundcloud/src/Player.vue"],names:[],mappings:";AA6BA;EACA,cAAA;EACA,gBAAA;EACA,OAAA;CACA",file:"Player.vue",sourcesContent:['<template>\n  <div>\n    <iframe id="soundcloud-iframe" width="100%" height="166" scrolling="no" frameborder="no" allow="autoplay" src="https://w.soundcloud.com/player/?url="></iframe>\n    <slot v-bind="{ \n      currentTrack,\n      duration,\n      listPosition,\n      loop,\n      isLoading,\n      isLoop,\n      isMuted,\n      isPlaying,\n      mute,\n      next,\n      play,\n      pause,\n      previous,\n      progression,\n      fastBackward,\n      fastForward,\n      unmute,\n      volume,\n    }"></slot>\n  </div>\n</template>\n\n<script src="./plugin.js"><\/script>\n\n<style scoped>\n  #soundcloud-iframe {\n    left: 99999px;\n    position: fixed;\n    top: 0;\n  }\n</style>']},media:void 0})},i,"data-v-dfb1f676",!1,0,function t(){const e=document.head||document.getElementsByTagName("head")[0],i=t.styles||(t.styles={}),s="undefined"!=typeof navigator&&/msie [6-9]\\b/.test(navigator.userAgent.toLowerCase());return function(t,o){if(document.querySelector('style[data-vue-ssr-id~="'+t+'"]'))return;const n=s?o.media||"default":t,l=i[n]||(i[n]={ids:[],parts:[],element:void 0});if(!l.ids.includes(t)){let i=o.source,d=l.ids.length;if(l.ids.push(t),s&&(l.element=l.element||document.querySelector("style[data-group="+n+"]")),!l.element){const t=l.element=document.createElement("style");t.type="text/css",o.media&&t.setAttribute("media",o.media),s&&(t.setAttribute("data-group",n),t.setAttribute("data-next-index","0")),e.appendChild(t)}if(s&&(d=parseInt(l.element.getAttribute("data-next-index")),l.element.setAttribute("data-next-index",d+1)),l.element.styleSheet)l.parts.push(i),l.element.styleSheet.cssText=l.parts.filter(Boolean).join("\n");else{const t=document.createTextNode(i),e=l.element.childNodes;e[d]&&l.element.removeChild(e[d]),e.length?l.element.insertBefore(t,e[d]):l.element.appendChild(t)}}}});const n={install:function(t){t.component("vue-audio-soundcloud",o)}};return"undefined"!=typeof window&&window.Vue&&window.Vue.use(n),n}(Vue);
  