Jump to content

Background audio doesn't stops after loop


Recommended Posts

EDIT: It seems to happen only in version 2.4.8. In 2.4.7 works perfectly. I will submit an issue to github.

Hi, guys.

I'm having a trouble with a background music that plays on my game playState.
It works well if the player dies before the audio loops (the audio duration is 21 seconds), but 

if the player survives more than 21 seconds and the audio loops, I can't stop the music. Instead,

when the create function of my playState comes on, it creates another audio and plays simultaneously.


I have read many post related to audio here, but can't solve the problem.

This is how I do it:

Audio preload in load.js:


game.load.audio('music', 'assets/background_music.mp3');

And in play.js in the create function:

game.music = this.add.audio('music', 0.2, true);

And finally, in the gameOver function:


I had tried many approaches described here in the forum, as:
Change the this.music variable to game.music, check if the game.music.isPlaying before create, stop it before call destroy, restart, but nothing helps.

Thanks for your attention

Phaser version 2.4.8

Edited by Flacor
Works fine in version 2.4.7
Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...