• 🏆 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!

Preloading music

Status
Not open for further replies.

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
I tried to preload music to make it start instantly when I want it.
  • play
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Game - Preload Farewell.mp3
      • Game - Begin preloading with a 0.00 second timeout
  • play Copy
    • Events
      • Time - Elapsed game time is 5.00 seconds
    • Conditions
    • Actions
      • Game - Display to (All players) the text: xxx
      • Sound - Play Farewell <gen>
The message is shown and the music starts 1 second later :-/
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
Nope, the file got sound right from the getgo.
2af5b74e2677b6ad7ea9477f2fdc43e6.png


Also my bad, it is used as a sound and not actually music.
I tried this though but it did not work.
  • Actions
    • Game - Display to (All players) the text: xxx
    • Sound - Stop (Last played sound) Immediately
    • Sound - Stop Farewell <gen> Immediately
    • Sound - Play Farewell <gen>
 
Level 17
Joined
Dec 11, 2014
Messages
2,004
Nope, the file got sound right from the getgo.
2af5b74e2677b6ad7ea9477f2fdc43e6.png


Also my bad, it is used as a sound and not actually music.
I tried this though but it did not work.
  • Actions
    • Game - Display to (All players) the text: xxx
    • Sound - Stop (Last played sound) Immediately
    • Sound - Stop Farewell <gen> Immediately
    • Sound - Play Farewell <gen>

Audacity image X)

I have no idea why your even is 5 sec and the music starts in 1 sec... but try to move your camera around to see if you are lagging or not.

Sounds can be preloaded if you play and then stop them (and not destroying the handle, unlike GUI) afaik.

I'm not sure if this will help but I've seen this preloading functions to create text files in your drive (used in Save-load systems)...
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
No it starts one second after the message is shown. So after 6 seconds.

I tried what you said.
  • play
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Sound - Play Farewell <gen>
      • Sound - Stop Farewell <gen> Immediately
  • play Copy
    • Events
      • Time - Elapsed game time is 5.00 seconds
    • Conditions
    • Actions
      • Game - Display to (All players) the text: xxx
      • Sound - Play Farewell <gen>
Did not work.
 
Level 17
Joined
Dec 11, 2014
Messages
2,004
You can do something smart and set the event to "Time - Elapsed game time is 4.00 seconds" but as a reason, you can check for possible lags. I'll look the BJ function to see if there's a wait.

EDIT: There isn't.

JASS:
function PlaySoundBJ takes sound soundHandle returns nothing
    set bj_lastPlayedSound = soundHandle
    if (soundHandle != null) then
        call StartSound(soundHandle)
    endif
endfunction

It's pretty hypothetical that 4 lines run in a second. The problem might be from the native.
 
Status
Not open for further replies.
Top