Fix playback bug on first load
Also, don't replay our own messages when just sent.
This commit is contained in:
parent
db3679a91c
commit
3853f21f90
1 changed files with 31 additions and 16 deletions
|
|
@ -98,8 +98,26 @@ export default {
|
||||||
document.body.classList.add("dark");
|
document.body.classList.add("dark");
|
||||||
this.$root.$on('playback-start', this.onPlaybackStart);
|
this.$root.$on('playback-start', this.onPlaybackStart);
|
||||||
this.player = this.$refs.player;
|
this.player = this.$refs.player;
|
||||||
|
this.player.autoplay = false;
|
||||||
this.player.addEventListener("timeupdate", this.updateProgressBar);
|
this.player.addEventListener("timeupdate", this.updateProgressBar);
|
||||||
this.player.addEventListener("play", () => {
|
this.player.addEventListener("play", () => {
|
||||||
|
if (!this.analyser) {
|
||||||
|
|
||||||
|
const audioCtx = new (window.AudioContext || window.webkitAudioContext)();
|
||||||
|
let audioSource = null;
|
||||||
|
if (audioCtx) {
|
||||||
|
audioSource = audioCtx.createMediaElementSource(this.player);
|
||||||
|
this.analyser = audioCtx.createAnalyser();
|
||||||
|
audioSource.connect(this.analyser);
|
||||||
|
this.analyser.connect(audioCtx.destination);
|
||||||
|
|
||||||
|
this.analyser.fftSize = 128;
|
||||||
|
const bufferLength = this.analyser.frequencyBinCount;
|
||||||
|
this.analyzerDataArray = new Uint8Array(bufferLength);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
this.playing = true;
|
this.playing = true;
|
||||||
this.updateVisualization();
|
this.updateVisualization();
|
||||||
if (this.currentAudioEvent) {
|
if (this.currentAudioEvent) {
|
||||||
|
|
@ -116,19 +134,6 @@ export default {
|
||||||
this.clearVisualization();
|
this.clearVisualization();
|
||||||
this.onPlaybackEnd();
|
this.onPlaybackEnd();
|
||||||
});
|
});
|
||||||
|
|
||||||
const audioCtx = new (window.AudioContext || window.webkitAudioContext)();
|
|
||||||
let audioSource = null;
|
|
||||||
if (audioCtx) {
|
|
||||||
audioSource = audioCtx.createMediaElementSource(this.player);
|
|
||||||
this.analyser = audioCtx.createAnalyser();
|
|
||||||
audioSource.connect(this.analyser);
|
|
||||||
this.analyser.connect(audioCtx.destination);
|
|
||||||
|
|
||||||
this.analyser.fftSize = 128;
|
|
||||||
const bufferLength = this.analyser.frequencyBinCount;
|
|
||||||
this.analyzerDataArray = new Uint8Array(bufferLength);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
document.body.classList.remove("dark");
|
document.body.classList.remove("dark");
|
||||||
|
|
@ -204,7 +209,17 @@ export default {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.src = null;
|
this.src = null;
|
||||||
|
const autoPlayWasSet = this.autoPlayNextEvent;
|
||||||
this.autoPlayNextEvent = false;
|
this.autoPlayNextEvent = false;
|
||||||
|
|
||||||
|
if (value.getSender() == this.$matrix.currentUserId) {
|
||||||
|
// Sent by us. Don't autoplay if we just sent this (i.e. it is ahead of our read marker)
|
||||||
|
if (this.room && !this.room.getReceiptsForEvent(value).includes(value.getSender())) {
|
||||||
|
this.player.autoplay = false;
|
||||||
|
this.autoPlayNextEvent = autoPlayWasSet;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.loadAudioAttachmentSource();
|
this.loadAudioAttachmentSource();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue