Doug Posted March 6, 2018 Share Posted March 6, 2018 Hi all I am using Angular 4 and creating an interface which has a number of games. They load in a modal (i.e. no page refresh/change) and I then destroy them with this.phaserGame.destroy(true); I have background audio that I am playing with the following: preload () : void { this.load.audio('bg', [ this.p('audio/bg.mp3'), this.p('audio/bg.ogg') ]); } this.p() just gets the relative path. create () : void { this.sound_bg = this.sound.add('bg', { loop: true }); } When I destroy and reload the game, the background audio object seems to still be in the DOM and plays over itself on second game launch. I've had a look through the documentation and tried removeByKey() remove() and destroy() in the BaseSoundManager() namespace just before destroying the game. None of these seem to solve the problem though. What is best practice for completely destroying sounds please? Thank you! Link to comment Share on other sites More sharing options...
Doug Posted May 15, 2018 Author Share Posted May 15, 2018 @rich Sorry to bother you, but I'm still struggling with this one and it's causing me a lot of headaches. What is the best way to completely remove sound from the DOM please? Thanks! Link to comment Share on other sites More sharing options...
samme Posted May 15, 2018 Share Posted May 15, 2018 Make sure you're using latest Phaser. It seems to work correctly in http://labs.phaser.io/edit.html?src=src\audio\Web Audio\Reuse AudioContext.js. Link to comment Share on other sites More sharing options...
Doug Posted May 15, 2018 Author Share Posted May 15, 2018 Thanks very much @samme - I am actually using the latest version of Phaser, but I just had another look at my code. It's pretty complicated in there now and it looks like there was one instance where I wasn't destroying the game properly, but just closing the modal. I've amended it now and so far it appears to have done the trick. So I'll do some more testing. Thank you and sorry for wasting your time if it was this. Link to comment Share on other sites More sharing options...
Recommended Posts