Merge branch '179-audio-play-only-one-audio-message-track-at-a-time' into 'dev'

Only one audio play at a time

Closes #179

See merge request keanuapp/keanuapp-weblite!66
This commit is contained in:
N Pex 2022-04-11 12:09:51 +00:00
commit 957e8e28d9

View file

@ -45,6 +45,7 @@ export default {
};
},
mounted() {
this.$root.$on('playback-start', this.onPlaybackStart);
this.player = this.$refs.player;
this.player.addEventListener("timeupdate", this.updateProgressBar);
this.player.addEventListener("play", () => {
@ -58,6 +59,9 @@ export default {
this.playing = false;
});
},
beforeDestroy() {
this.$root.$off('playback-start', this.onPlaybackStart);
},
computed: {
currentTime() {
return util.formatDuration(this.playTime);
@ -80,6 +84,7 @@ export default {
methods: {
play() {
if (this.player.src) {
this.$root.$emit("playback-start", this);
if (this.player.paused) {
this.player.play();
} else if (this.player.ended) {
@ -107,6 +112,11 @@ export default {
updateDuration() {
this.duration = 1000 * this.player.duration;
},
onPlaybackStart(item) {
if (item != this && this.playing) {
this.pause();
}
}
},
};
</script>