Discord
Login
Community
DARK THEME

How can I restart the music?

I'm working on a small project and I want to restart the music each time the player loses a life or moves to a new level.

If I do music.stop(), when go music.play("mytune") again it starts in the same point as it was stopped.

Also tried playing a different song (maybe an empty 1kb mp3, as a trick) and, in the next instruction, playing again the song, but no success.

Do you know any way to achieve this?

Thanks in advance!

music.setPosition(0) // stops the music and put it back to the second you choose (in this case 0)
music.play() // restart music

It works OK, Thanks!

I haven't seen this in the documentation. Next time I'll just try :)

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community