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:
commit
957e8e28d9
1 changed files with 10 additions and 0 deletions
|
|
@ -45,6 +45,7 @@ export default {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
this.$root.$on('playback-start', this.onPlaybackStart);
|
||||||
this.player = this.$refs.player;
|
this.player = this.$refs.player;
|
||||||
this.player.addEventListener("timeupdate", this.updateProgressBar);
|
this.player.addEventListener("timeupdate", this.updateProgressBar);
|
||||||
this.player.addEventListener("play", () => {
|
this.player.addEventListener("play", () => {
|
||||||
|
|
@ -58,6 +59,9 @@ export default {
|
||||||
this.playing = false;
|
this.playing = false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
beforeDestroy() {
|
||||||
|
this.$root.$off('playback-start', this.onPlaybackStart);
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
currentTime() {
|
currentTime() {
|
||||||
return util.formatDuration(this.playTime);
|
return util.formatDuration(this.playTime);
|
||||||
|
|
@ -80,6 +84,7 @@ export default {
|
||||||
methods: {
|
methods: {
|
||||||
play() {
|
play() {
|
||||||
if (this.player.src) {
|
if (this.player.src) {
|
||||||
|
this.$root.$emit("playback-start", this);
|
||||||
if (this.player.paused) {
|
if (this.player.paused) {
|
||||||
this.player.play();
|
this.player.play();
|
||||||
} else if (this.player.ended) {
|
} else if (this.player.ended) {
|
||||||
|
|
@ -107,6 +112,11 @@ export default {
|
||||||
updateDuration() {
|
updateDuration() {
|
||||||
this.duration = 1000 * this.player.duration;
|
this.duration = 1000 * this.player.duration;
|
||||||
},
|
},
|
||||||
|
onPlaybackStart(item) {
|
||||||
|
if (item != this && this.playing) {
|
||||||
|
this.pause();
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue