I use the LoadSound / Callback like this, which is perfectly fine. It lets temp be 10000.
Next steps are to stop, and remove the sound. When I like to load the same sound again, the Callback is not called.
Code: Select all
Procedure Loaded(Type, Filename$, ObjectId)
Case #PB_Loading_Sound
PlaySound ( ObjectId )
EndSelect
EndProcedure
temp = LoadSound ( #PB_Any, datadir + myorder )
Code: Select all
InitSound()
Global s1
Global s2
Procedure PlayLazerEvent()
PlaySound(s1)
EndProcedure
Procedure PlaySirenEvent()
PlaySound(s2)
FreeSound(s2)
LoadSound(#PB_Any, "Lazer 2.wav")
EndProcedure
Procedure Start()
If OpenWindow(0, 0, 0, 200, 90, "Sound example", #PB_Window_TitleBar | #PB_Window_SizeGadget | #PB_Window_ScreenCentered)
ButtonGadget(0, 10, 10, 180, 30, "Play Lazer !")
ButtonGadget(1, 10, 50, 180, 30, "Play Siren !")
BindGadgetEvent(0, @PlayLazerEvent())
BindGadgetEvent(1, @PlaySirenEvent())
EndIf
EndProcedure
Procedure Loading(Type, Filename$, ObjectId)
Static NbLoadedElements
Debug Filename$ + " loaded (id = " + ObjectId + ")"
NbLoadedElements+1
If NbLoadedElements = 2 ; Finished the loading of all sounds, we can start the application
Start()
EndIf
EndProcedure
Procedure LoadingError(Type, Filename$)
Debug Filename$ + ": loading error"
EndProcedure
; Register the loading event before calling any resource load command
BindEvent(#PB_Event_Loading, @Loading())
BindEvent(#PB_Event_LoadingError, @LoadingError())
s1 = LoadSound(#PB_Any, "Lazer.wav")
s2 = LoadSound(#PB_Any, "Lazer 2.wav")
Thanks!
Cheers
J.