var player,$player,volume=55,is_playing=!1;function stopAllPlayers(){player.pause(),player.src="",is_playing=!1,$(".btn-audio").removeClass("playing").find("i").removeClass("zmdi-stop").addClass("zmdi-play"),$("#radio-player-controls").removeClass("jp-state-playing")}function setVolume(e){volume=e;var l=Math.round(100*volume);$(".jp-volume-bar-value").css("width",l+"%"),player.volume=Math.pow(volume,3),store.enabled&&store.set("player_volume",100*volume)}function playAudio(e){player.src=e,player.play()}function handlePlayClick(e){btn=$('.btn-audio[data-url="'+e+'"]'),btn.hasClass("playing")?stopAllPlayers():(is_playing&&stopAllPlayers(),playAudio(e),btn.addClass("playing").find("i").removeClass("zmdi-play").addClass("zmdi-stop"))}$(function(){store.enabled&&void 0!==store.get("player_volume")&&(volume=store.get("player_volume",volume)),$(".btn-audio").on("click",function(e){return e.preventDefault(),handlePlayClick($(this).data("url")),!1}),player=document.createElement("audio"),$player=$(player),setVolume(volume/100),$player.on("play",function(e){is_playing=!0,$(".jp-unmute").hide(),$("#radio-player-controls,#radio-embedded-controls").addClass("jp-state-playing");var l=Math.round(100*$player.volume);$(".jp-volume-bar-value").css("width",l+"%")}),$player.on("ended",function(e){$("#radio-player-controls,#radio-embedded-controls").removeClass("jp-state-playing")}),"mediaSession"in navigator&&navigator.mediaSession.setActionHandler("pause",function(){stopAllPlayers()}),$(".jp-pause").on("click",function(e){stopAllPlayers()}),$(".jp-mute").on("click",function(e){player.volume=0,$(".jp-unmute").show(),$(".jp-mute").hide()}),$(".jp-unmute").on("click",function(e){setVolume(volume),$(".jp-unmute").hide(),$(".jp-mute").show()}),$(".jp-volume-bar").on("click",function(e){var l=$(e.currentTarget),a=l.offset(),o=e.pageX-a.left,t=l.width();l.height(),e.pageY,a.top,l.height();setVolume(o/t)}),$('.btn-audio[data-autoplay="true"]:first').click()});
//# sourceMappingURL=data:application/json;charset=utf8;base64,[encoded data, 7404 characters]
