stop other players on page playing when new one starts
This commit is contained in:
parent
613ec7dd08
commit
94d1269b9e
@ -92,6 +92,8 @@ export default {
|
|||||||
this.eqBarRotation = segmentWidth * (Math.PI / 180);
|
this.eqBarRotation = segmentWidth * (Math.PI / 180);
|
||||||
|
|
||||||
this.createBarData();
|
this.createBarData();
|
||||||
|
|
||||||
|
window.dispatchEvent(new CustomEvent("changetrack", { detail: this }));
|
||||||
} else {
|
} else {
|
||||||
// let audioCtx = new (window.AudioContext || window.webkitAudioContext)();
|
// let audioCtx = new (window.AudioContext || window.webkitAudioContext)();
|
||||||
this.source = this.audioCtx.createMediaStreamSource(
|
this.source = this.audioCtx.createMediaStreamSource(
|
||||||
@ -105,8 +107,16 @@ export default {
|
|||||||
this.initialised = false;
|
this.initialised = false;
|
||||||
this.drawUI();
|
this.drawUI();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
window.addEventListener('changetrack', this.changeTrack);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
changeTrack: function(e){
|
||||||
|
console.log();
|
||||||
|
if (e.detail._uid !== this._uid && this.playing) {
|
||||||
|
this.togglePlay();
|
||||||
|
}
|
||||||
|
},
|
||||||
createBarData: function() {
|
createBarData: function() {
|
||||||
this.drawBar(this.eqBarCache, "rgb(0, 0, 0)");
|
this.drawBar(this.eqBarCache, "rgb(0, 0, 0)");
|
||||||
this.drawBar(this.eqBarCacheWhite, "rgb(255, 255, 255)");
|
this.drawBar(this.eqBarCacheWhite, "rgb(255, 255, 255)");
|
||||||
@ -353,6 +363,7 @@ export default {
|
|||||||
this.audioElement.play();
|
this.audioElement.play();
|
||||||
this.playing = !this.playing;
|
this.playing = !this.playing;
|
||||||
this.draw();
|
this.draw();
|
||||||
|
window.dispatchEvent(new CustomEvent("changetrack", { detail: this }));
|
||||||
} else {
|
} else {
|
||||||
this.audioElement.pause();
|
this.audioElement.pause();
|
||||||
this.playing = !this.playing;
|
this.playing = !this.playing;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user