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() {
|
||||
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>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue