import { Howl } from 'howler'
import { PlayIcon } from 'vue-feather-icons'
export default {
props: {
audio: Object
},
data () {
return {
isTargeted: null,
isPulse: null
}
},
components: {
PlayIcon
},
computed: {
loading () {
return this.$store.getters.loading
}
},
methods: {
startAudio (audio) {
const audioTrack = new Howl({
xhr: { method: 'POST' },
src: [audio.audio],
onplay () {
this.isPulse = audio.id
},
onend () {
this.isTargeted = null
}
})
if (this.isTargeted === null) {
this.isTargeted = audio.id
audioTrack.play()
} else {
audioTrack.pause()
this.isTargeted = null
}
}
}
}