• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] [Music] How to smooth switch music? Game hang up when "PlayMusic"/"PlayMusicEx"

Status
Not open for further replies.
Level 3
Joined
Mar 27, 2018
Messages
23
Hi there.

I'm trying to make a BGM switching system in my map.
I want to dynamic switch specific music when player enter the different area.

But the question is when I call "PlayMusic" or "PlayMusicEx" to play my custom imported music file, the game will "hang up" for about 2 seconds.
I think it's because the game is loading my music data, but is there any function that I could use to "preload" my "music data"?
I want to make a "smooth music switching".

If you have any idea about this, thank you for any help!

Update

* I just tried to use "Preload(...)" but its still laggy when I switch music.
* And I tried to convert music file format to ".wav" but that does not make it work as a bgm.
 
Last edited:
Level 3
Joined
Mar 27, 2018
Messages
23
Solved.

I converted the music as .wav file, and play it as a sound.
It works fine.


Please read RG00's reply below.
 
Last edited:
Level 6
Joined
Jun 4, 2017
Messages
172
Solved.

I converted the music as .wav file, and play it as a sound.
It works fine.
Wav files are much bigger than mp3 files because they aren't compressed so you should avoid using them if possible. If you have many musics I suggest you to convert them into mp3 to avoid having a map with a huge file size. Other than that, if you play your music as a sound and the player wants to disable the in-game music he won't be able to do it without disabling all the sounds too.
The small lag that happens when changing mp3 music is easily avoidable by using this:
  • Sound - Stop music Immediately
and then change the music.
If you don't like the music to stop immediately you can do something like this:
  • Sound - Stop music After the fade
  • Wait 1.00 second
  • Sound - Stop music Immediately
  • Sound - Play some music
 
Level 3
Joined
Mar 27, 2018
Messages
23
Wav files are much bigger than mp3 files because they aren't compressed so you should avoid using them if possible. If you have many musics I suggest you to convert them into mp3 to avoid having a map with a huge file size. Other than that, if you play your music as a sound and the player wants to disable the in-game music he won't be able to do it without disabling all the sounds too.
The small lag that happens when changing mp3 music is easily avoidable by using this:
  • Sound - Stop music Immediately
and then change the music.
If you don't like the music to stop immediately you can do something like this:
  • Sound - Stop music After the fade
  • Wait 1.00 second
  • Sound - Stop music Immediately
  • Sound - Play some music

Thank you! This perfectly solved the problem and it works great!
 
Status
Not open for further replies.
Top