text: !function(a,b,c){"use strict";function d(){this.frameReady=!1,this.ready=!1}function e(){return this.streamingPlayer=void 0,this.queued=[],this.played=[],this.repeat=!1,this.frameReady=!1,this.ready=!1,this}if(d.prototype.auth=function(){m.api.consumerKey&&m.member.accessToken&&m.windows(this.win).post("auth",{consumerKey:m.api.consumerKey,accessToken:m.member.accessToken})},d.prototype.play=function(a){return m.previewer.pause(),m.windows(this.win).post("play",a),this},d.prototype.pause=function(){return m.windows(this.win).post("pause"),this},d.prototype.resume=function(){},d.prototype.next=function(){m.windows(this.win).post("playNext")},d.prototype.previous=function(){m.windows(this.win).post("playPrevious")},d.prototype.queue=function(){return m.windows(this.win).post("queue",o),this},d.prototype.clearQueue=function(){m.windows(this.win).post("clearQueue")},d.prototype.toggleShuffle=function(){m.windows(this.win).post("toggleShuffle")},d.prototype.toggleClass=function(){m.windows(this.win).post("toggleRepeat")},d.prototype.seek=function(){m.windows(this.win).post("seek",t)},d.prototype.setVolume=function(){m.windows(this.win).post("setVolume",n)},d.prototype.fire=function(a){window.parent.postMessage({type:a},"*")},d.prototype.on=function(a,b){var c=this;return window.addEventListener("message",function(d){if("playerframeready"===d.data.type?c.frameReady=!0:"ready"===d.data.type?c.ready=!0:"playsessionexpired"===d.data.type&&(c.paused=!1,c.playing=!1),c.frameReady&&c.ready&&!c.authed&&(c.authed=!0,c.auth()),d.data.type===a){if(d.data.data&&d.data.data.id){d.data.data.id=d.data.data.id.replace("tra","Tra");var e=d.data.data.code,f="PlayStarted"===e||"PlayComplete"!==e&&"Paused"!==e&&"BufferEmpty"!==e&&"NetworkDropped"!==e&&"PlayInterrupted"!==e&&"IdleTimeout"!==e,g="Paused"===e||"NetworkDropped"===e||"PlayInterrupted"===e||"IdleTimeout"===e;c.playing=d.data.data.playing=f,c.paused=d.data.data.paused=g,c.currentTrack=c.playing||c.paused?d.data.data.id:null}b.call(this,d.data)}}),this},e.prototype.auth=function(){var a=this;this.streamingPlayer=new DrmStreamingPlayer({id:"napster-streaming-player",apikey:h,token:m.member.accessToken,bitrate:192,downgrade:!0,currentUser:{},env:"production"}),this.streamingPlayer.callbackHandler("trackEnded",function(){window.parent.postMessage({type:"playevent",data:{id:a.currentTrack,code:"PlayComplete",playing:!1}},"*"),!1===a.repeat?a.next():a.streamingPlayer.play(a.currentTrack,"UNKNOWN")}),this.streamingPlayer.callbackHandler("trackProgress",function(){window.parent.postMessage({type:"playtimer",data:{id:a.currentTrack,code:"trackProgress",currentTime:a.streamingPlayer.currentTime(),totalTime:a.streamingPlayer.track.duration}},"*")}),this.streamingPlayer.callbackHandler("sessionExpired",function(){window.parent.postMessage({type:"playsessionexpired",data:{id:a.currentTrack,code:"sessionExpired"}},"*")}),this.streamingPlayer.callbackHandler("trackLoaded",function(){window.parent.postMessage({type:"trackLoaded",data:{id:a.currentTrack,code:"trackLoaded"}},"*")})},e.prototype.play=function(a){this.streamingPlayer.play(a,{context:"UNKNOWN"}),this.played.push(a),window.parent.postMessage({type:"playevent",data:{id:a,code:"PlayStarted",playing:!0}},"*")},e.prototype.pause=function(){this.streamingPlayer.pause(),window.parent.postMessage({type:"playevent",data:{id:this.currentTrack,code:"Paused",playing:!1}},"*")},e.prototype.resume=function(){this.streamingPlayer.resume(this.currentTrack,{context:"UNKNOWN"}),window.parent.postMessage({type:"playevent",data:{id:this.currentTrack,code:"PlayStarted",playing:!0}},"*")},e.prototype.next=function(){this.pause(),this.queued.length>=1&&this.play(this.queued.pop())},e.prototype.previous=function(){this.pause(),1===this.played.length?(this.streamingPlayer.play(this.played[0],{context:"UNKNOWN"}),window.parent.postMessage({type:"playevent",data:{id:this.played[0],code:"PlayStarted",playing:!0}},"*")):(this.queued.push(this.played.pop()),this.play(this.played.pop()))},e.prototype.queue=function(a){this.queued.push(a)},e.prototype.clearQueue=function(){this.queued=[],this.played=[]},e.prototype.toggleShuffle=function(){this.queued=this.queued.map(function(a){return[Math.random(),a]}).sort(function(a,b){return a[0]-b[0]}).map(function(a){return a[1]})},e.prototype.toggleRepeat=function(){this.repeat=!1===this.repeat},e.prototype.showQueue=function(){return this.queued},e.prototype.showPlayed=function(){return this.played},e.prototype.seek=function(a){this.streamingPlayer.seek(this.currentTrack,a)},e.prototype.setVolume=function(a){this.streamingPlayer.setVolume(a)},e.prototype.fire=function(a){window.parent.postMessage({type:a},"*")},e.prototype.on=function(a,b){var c=this;return window.addEventListener("message",function(d){if("playerframeready"===d.data.type?c.frameReady=!0:"ready"===d.data.type?c.ready=!0:"playsessionexpired"===d.data.type&&(c.paused=!1,c.playing=!1),c.frameReady&&c.ready&&!c.authed&&(c.authed=!0,c.auth()),d.data.type===a){if(d.data.data&&d.data.data.id){d.data.data.id=d.data.data.id.replace("tra","Tra");var e=d.data.data.code,f="PlayStarted"===e||"PlayComplete"!==e&&"Paused"!==e,g="Paused"===e;c.playing=d.data.data.playing=f,c.paused=d.data.data.paused=g,c.currentTrack=c.playing||c.paused?d.data.data.id:null}b.call(this,d.data)}}),this},a&&b&&b.ajax&&c){var f=c.stringify;c.stringify=function(a){return f(a,function(a,b){return"genre"===a?{id:b.id,name:b.name}:b})};var g,h,i=function(a,b,c){var d=a[b];a[b]=function(){return c.length===arguments.length?c.apply(this,arguments):"function"==typeof d?d.apply(this,arguments):void 0}},j="napster.member.accessToken",k="napster.member.refreshToken",l=function(a){for(var b in a)this[b]=a[b]},m={init:function(a){function c(){if(!0===a.isHTML5Compatible)return!0}this.api.consumerKey=a.consumerKey,h=a.consumerKey,this.api.version=a.version||this.api.version,this.api.catalog=a.catalog||this.api.catalog;var f=a.player||"player-frame";if(f&&"string"==typeof f){var i=this,j=b("#"+f);if(c())g="HTML5_PLAYER",i.player=new e,b("<video-js id='napster-streaming-player' class='video-js' playsinline></video-js>").appendTo(b(document.body)),b("#napster-streaming-player").css("display","none"),b.ajax({url:"https://api.napster.com/v2/streaming-player.js",dataType:"script",async:!0,success:function(){m.player.fire("ready")}});else if(g="FLASH_PLAYER",i.player=new d,0===j.length)b(function(){var c=b("<iframe></iframe>").attr("id",f).attr("name",f).attr("src","http://api.napster.com/v1.1/player/index.html?apikey="+a.consumerKey).attr("frameborder","no").attr("style","display:none;").appendTo(b(document.body)).load(function(){i.player.win=c.get(0)})});else{if(!(j.get(0)instanceof HTMLIFrameElement))throw new Error('The element "'+f+'" is not an HTMLIFrameElement.');i.player.win=j.get(0)}}}};m.api={host:"api.napster.com",catalog:"US",version:"v2.2",endpoint:function(a){return(a?"https://":"http://")+[this.host,this.version].join("/")},headers:function(a){var b={};return a&&m.member.accessToken&&(b.Authorization="Bearer "+m.member.accessToken),b},dataType:function(){return"json"},get:function(a,c,d){var e={apikey:this.consumerKey};b.ajax({type:"GET",dataType:this.dataType(),data:e,headers:this.headers(a),url:this.endpoint(a)+c,success:function(a,b,c){d(a)},error:function(a){d({status:a.status,error:a.statusText,response:a.responseJSON})}})},post:function(a,c,d,e){d||(d={}),b.ajax({type:d._method||"POST",data:d,dataType:this.dataType(),headers:this.headers(a),url:this.endpoint(a)+c+(a?"":"?apikey="+this.consumerKey),success:function(a,b,c){e(a)},error:function(a){e({status:a.status,error:a.statusText,response:a.responseJSON})}})},put:function(a,b,c,d){c._method="PUT",this.post.call(this,a,b,c,d)},del:function(a,b,c,d){c._method="DELETE",this.post.call(this,a,b,c,d)}},m.member=new function(){return new l({accessToken:a.localStorage[j],refreshToken:a.localStorage[k]})},m.previewer={play:function(){return this},pause:function(){return this}},m.windows=function(a){return{post:function(b,c){if(!a)throw new Error("An iframe was not found at that reference.");a.contentWindow.postMessage({method:b,args:m.util.jsonClean(c||{})},"*")}}},m.on=function(a,b){window.addEventListener(a,b)},m.util={secondsToTime:function(a){if(!isNaN(a)){var b=Math.floor(a/60),c=Math.floor(a)%60;return b+":"+(c<10?"0"+c:c)}return"0:00"},jsonClean:function(a){return c.parse(c.stringify(a,function(a,b){return"genre"===a?{id:b.id,name:b.name}:b}))}},i(l.prototype,"set",function(b){b&&b.accessToken&&b.refreshToken&&(this.accessToken=a.localStorage[j]=b.accessToken,this.refreshToken=a.localStorage[k]=b.refreshToken,m.player.auth(b.accessToken))}),i(l.prototype,"unset",function(){this.accessToken=this.refreshToken=null,a.localStorage.removeItem(j),a.localStorage.removeItem(k)}),i(l.prototype,"load",function(){return this.accessToken=a.localStorage[j],this.refreshToken=a.localStorage[k],this}),i(l.prototype,"signedIn",function(){return null!=this.accessToken&&null!=this.refreshToken}),a.Napster=m,a.Member=l}}(window,jQuery,JSON);