Issue with playing music

Started by Starlock, January 18, 2018, 09:52:14 PM

Previous topic - Next topic
Whenever I go from one map to another, the song will restart despite it being the same song. I'm calling the sol.audio.play_music(music_id, [action]) from inside of the map:on_started() since there are three different songs that can play depending on your progress in the game. What do I need to do to stop the music from restarting?

Get the current music in a variable. Then you can do something like this:

if current_music ~= music_id then
  sol.audio.play_music(music_id, [action])
end
"If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you."

That didn't seem to work. The music still restarts whenever you go from one map to another. Isn't it not supposed to restart regardless if it's the same song, like what it says on the wiki?

"If you set the music name to the same music that is already playing, or to the special value "same", then this function does nothing: the music keeps playing (it does not restart) and the second parameter is ignored."

That is true, but I guess maybe you put no music in the map properties (in the left panel of the map editor). So the music stops when the map starts, and then your code starts it again.
Set the music to the one you want (or to "Same") in the map properties panel.