Re: ina bind: MULTIPLE playSound(async) vs setVisible
- Posted by Bernie Ryan <bwryan at PCOM.NET> Oct 29, 1999
- 560 views
This code works Bernie ------------------------------< cut >------------------------------------ -- demo of problem with .wav sound happening before setVisible, -- even though setVisible is commanded before playsound. include Win32Lib.ew without warning --- BELOW ARE MY ADDED CONSTANTS bernie constant True = -1, False = 0, ALWAYS_NULL = 0 global constant TheWindow = create( Window, "Sound/setVisible Problem", 0, 100, 100, 684, 388,0), LText2 = create( LText, "LText2", TheWindow, 132, 96, 444, 76, 0 ), Restart = create( PushButton, "RESTART", TheWindow, 248, 264, 132, 36, 0 ), DoTest = create( PushButton, "CLICK HERE", TheWindow, 248, 192, 132, 40, 0), LText5 = create( LText, "LText5", TheWindow, 136, 8, 408, 80, 0 ) --------------------------------------- -- TO PLAY A .WAV FILE: procedure playsound(sequence wave) atom file file = allocate_string(wave) c_proc(xPlaySound, {file, ALWAYS_NULL, SND_ASYNC}) free(file) end procedure ------------------------------------ procedure TheWindow_onOpen () -- TEST INSTRUCTIONS: setText(LText5,"THIS WORKS ON A AWE32 SOUNDCARD") --TEXT TO SHOW WHEN BUTTON CLICKED ; MAKE IT INVISIBLE FOR NOW: setFont(LText2,"Arial", 15,Bold) setText(LText2,"This text should have shown BEFORE anything was spoken!") setVisible(LText2,False) end procedure onOpen[TheWindow] = routine_id("TheWindow_onOpen") ----------------------------------- --DO THE TEST: procedure DoTest_onClick () setVisible(LText2,True)-- TEXT should become VISIBLE; playsound("test.wav") -- THEN sound should happen. end procedure onClick[DoTest] = routine_id("DoTest_onClick") ------------------------------------ -- RESET TO DO TEST AGAIN: procedure Restart_onClick () setVisible(LText2,False) end procedure onClick[Restart] = routine_id("Restart_onClick") ---------------------------------------------------------------------- WinMain( TheWindow ) -----------------------< cut >------------------------------------------