Play sound(repeat playing)

sintaq

New Member
hi all...first of all Basic4ppc rocks! hehehe

i tired searching for free alaram software for my O2 mini (WM2003SE) so i decided to build my own alarm. hehehehe! (still learning). i know how to play sound using Sound("music.wav"). can anyone guide me how to repeatedly play the sound untill i click a button to stop it.

p/s: i'm newbie...please be gentle. thanx!
 

Louis

Active Member
Licensed User
Longtime User
Hi there, and welcome to the B4ppc community! To repeated play a sound, use the FMOD library. Follow these steps:
From the Basic4ppc IDE, go to Tools - Conponents, and press the Add DLL button, the one where it adds dlls to both list boxes. Next, select fmodDesktop.dll (to build this app on the desktop) or FMODDevice.dll (to build it on the device) from the Open File Dialog box. Next, press OK.
Go back into Tools - Add Object, choose FMOD then give it a name so you can call it in your program.
Click the Close button then where you want the sound to play repeatedly, just write the name you typed inside the object name field followed by a period, click PlayLoop and in parenthesis type (AppPath & "\Filename.wav")
When you click the stop button, on the sub that is activated on the click event, inside the sub type objectname followed by a period, and click on Stop1. Here's an example program:

Sub Globals
'Declare variables here.
End Sub

Sub App_Start
'MySound is a FMOD object added in Tools - Add Object after referencing FMODDesktop.DLL for the desktop. If I want device, I'd reference FMODDevice.dll from the Tools - Components dialog box.
MySound.New1 'Initialize FMOD to get ready to play a sound.
addform("Test", "Repeating Sound")
addbutton(test, "Stop", 40, 40, 5, 5, "Stop") 'You will have to change the left, top, width, and height properties listed as numbers in between the commas, or use the Forms' Designer.
test.show
MySound.PlayLoop(AppPath & "\Alarm.wav") 'Use apppath to get the relevant path of the application.
End Sub
Sub Stop_click
MySound.Stop1
End Sub


Hope that helps.
 
Top