|
-
January 31st, 2000, 11:00 AM
#1
.wav file
i want to put a wav file on my prime number project for school. preferably Jeopardy. just want to see if anyone knows code to insert for a looping wav.
-
January 31st, 2000, 12:10 PM
#2
Re: .wav file
Well, I guess the easiest way is to insert an MCI control (using the Microsoft Multimedia Controls -- MCI32.OCX). Then insert the following code:
private Sub Form_Load()
MMControl1.Notify = true
MMControl1.Wait = false
MMControl1.Shareable = false
MMControl1.DeviceType = "WaveAudio"
MMControl1.FileName = "C:\WINDOWS\Desktop\soundtest\tada.wav"
MMControl1.Command = "open"
End Sub
If you don't want to use the play button on the control (say you set MMControl1.Visible = False) then you can still start playing the wav file by picking whatever even you want to trigger it and saying:
MMControl1.Command = "play"
Then, because we set MMControl1.Notify = True, after it's done playing the MMControl1_Done event is triggered. Place the MMControl1.Command = "play" in that event to keep the sound looping.
Two other ways to do this (actually I think easier 'cause there's less code) use API's, which probably creates less overhead than using the MCI control anyway. The code looks like this:
private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (byval lpszName as string, byval hModule as Long, byval dwFlags as Long) as Long
Dim ret as Long
ret = PlaySound("YOUR_FILENAME_HERE", 0, &H20000 Or &H1 Or &H2 Or &H8 ' causes it to loop)
ret = PlaySound("", 0, &H40 Or &H2 'causes it to stop playing)
The other one looks like this:
' Note: sndPlaySound is obsolete because it is superseded by PlaySound function.
private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (byval lpszSoundName as string, byval uFlags as Long) as Long
Dim ret as Long
ret = sndPlaySound("YOUR_FILENAME_HERE", &H1 Or &H8 'causes it to loop)
ret = sndPlaySound("", &H1 Or &H8 'causes it to stop playing)
And that's pretty much all there is to it.
xxMariusxx
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|