"use strict";(self["webpackChunkcarabi_x2"]=self["webpackChunkcarabi_x2"]||[]).push([[1852],{8829:function(a,i,t){t.r(i),t.d(i,{default:function(){return r}});var e=function(){var a=this,i=a._self._c;return i("div",{staticClass:"car-audio-player",style:a.style},[i("div",{staticClass:"car-audio-player__action",class:a.buttonClass,attrs:{role:"button"},on:{click:function(i){return a.playToggle()}}},[a.media.play?i("img",{attrs:{src:"/img/icons/pause.svg",width:"20",height:"20","uk-svg":""}}):i("img",{attrs:{src:"/img/icons/play.svg",width:"20",height:"20","uk-svg":""}})]),i("div",{staticClass:"car-audio-player__meta"},[i("div",{staticClass:"car-audio-player__title",domProps:{textContent:a._s(a.data)}}),i("div",{staticClass:"car-audio-player__duration",domProps:{textContent:a._s(a.media.duration)}})]),i("div",{staticClass:"car-audio-player__close",attrs:{role:"button"},on:{click:function(i){return a.close()}}},[i("img",{attrs:{src:"/img/icons/icon__close.svg",width:"16",height:"16","uk-svg":""}})]),i("audio",{ref:"audio",staticClass:"car-audio-player-",attrs:{hidden:""}})])},s=[],l={name:"AudioPlayer",props:{src:{type:String,default(){}},data:{type:String,default(){}},position:{type:String,default:"bottom"}},data(){return{media:{audio:null,currentTime:null,duration:null,play:!1,canplay:null}}},computed:{style(){const a=[`${this.position}: 15px`];return a.join(" ")},buttonClass(){if(this.media.audio)return this.media.play?"play":"pause"}},mounted(){this.playAudio()},methods:{close(){this.clearPlayer(),this.$emit("close")},playToggle(){this.media.audio.paused?(this.media.audio.play(),this.media.play=!0,console.log("play",this.media.audio.currentTime)):(this.media.currentTime=this.media.audio.currentTime,this.media.audio.pause(),this.media.play=!1,console.log("play",this.media.audio.currentTime))},clearPlayer(){this.media.audio=null,this.media.duration=null,this.media.canplay=null,this.media.play=!1},playAudio(){this.media.audio=this.$refs.audio,this.media.audio.src=this.src,this.media.canplay=this.media.audio.canPlayType(this.src),console.log("playAudio",this.media.audio);let a=this.media.audio;a.addEventListener("playing",(a=>this.media.play=!0)),a.addEventListener("paused",(a=>this.media.play=!1)),a.addEventListener("ended",(()=>this.close())),this.media.audio.play(),this.media.canplay}}},d=l,o=t(1656),u=(0,o.A)(d,e,s,!1,null,null,null),r=u.exports}}]);
//# sourceMappingURL=AudioPlayer.9514a6fa.js.map