[Resolved] Remove the "Play Music" Actions

So, I been looking around the forum, and I see a lot of Don’t use the play music action, use play sound", and I remember hearing that it is buggy or something and that is why it shouldn’t be used. Well I think it would be good to remove those actions completely as to avoid confusion for new users, as I also ran into that when I was a noob. And, if there would be a problem of ruining some existing projects, you could automatically switch it to play sound when the game file is loaded with a new version.

Thanks,
Inusitatus

Some time ago, there was information on the wiki itself that the actions to play music should not be used in new projects, but the actions to play sounds. But it’s been a while since wiki updated and that information disappeared: Audio - GDevelop documentation

So… Does “Play Music” no longer have a bug or did they just forget to put that information in after the wiki update? (or maybe I’m not looking in the right place :eyes:).

Yeah, I’m confused. Should I use that for music? Or should I use play music for sounds?

It’s not that play music has a bug, they are just using different backends and most people will prefer the tradeoffs made by the sound actions.

Advantages of the music actions:

  • It uses streaming when playing the audio file, so if you have a large audio file that you want to play on a low performance device you can do so without taking too much RAM, and can start playing as soon as the first chunks of the file start to load
  • It is older, technically more widely supported

Advantages of the sound actions:

  • Requires completely preloading a sound in memory before playing, thus it is guaranteed to play fully without pauses or distortions
  • The backend is compatible with a post processing pipeline that allows to for example use the positional sound extension
  • Not 100% sure about that one but it might be less strict bout playing sound? The music actions will require a click being made on the game before being able to play, whereas I think sound only need the game to be focused?

Back when they were added, there was no preloading of sound Files, they were re-downloaded and loaded every time you played them, so the rationale behind the naming was that you’d want to use music actions for background music tracks, since they are usually very long and big, so they’d take a few seconds to fully load, so the streaming loading would allow the music to start playing instantly, whereas sound effect like a jump sound would be small enough to be loaded within an unnoticeable delay, thus the sound action would be used as no streaming ensures the integrity of the sound.

However, things have changed. Most devices and browsers have a lot of RAM available, and I’ve since reworked the sound system to not redownload and load every sound file everytime: now, you can chose to preload as a sound or music a sound resource in the resources manager, which will fully load the file while on the loading screen, and when you play a sound or music, it remains permanently loaded for subsequent plays.

As such, the main difference between both has pretty much become irrelevant, since the sound/music will already be fully loaded and ready to play in it’s entirety when played. You probably will want to use the sound actions since it is technically more powerful and modern, and if I am not mistaken about the strictness of it’s rules for allowing playback it is more likely to actually play the sound when requested. Sound resources are only preloaded for sound actions by default, so you need to go in the resources panel and change for every resource the preloading to preload as music if you really wanted to use music actions with instant playback.

However, there is a niche that the music actions are still filling: we know at least one user targets very old devices (Android 4 I think?), and those not only didn’t always support the sound actions backend but also didn’t have enough RAM to keep multiple musics loaded at the same time. So they unload the music after every play, and play it with the music actions to get instant playback through streaming loading.

So tl;dr

Yes you most likely will want to use sound actions exclusively for most games, but removal of the music actions would not be practical, since the differences between both are a more complicated set of tradeoffs than “one is always better”, and some users will need or prefer to use the music actions.

3 Likes

Ah, thank you for the clarification, I had no clue.

1 Like