|
-
Oct 23rd, 2002, 06:38 PM
#1
Thread Starter
Fanatic Member
HELP! NO WEBSITES
ok i want to make an WAV play when my program begins, i made it to a custom resource file, how do i make it play with the windll or rundll32, whatever that built in thing is! thanks
PS! DONT TELL ME TO CHECK A WEBSITE, I NEED STEP BY STEP HELP
Last edited by duc; Oct 23rd, 2002 at 07:36 PM.
-
Oct 23rd, 2002, 07:33 PM
#2
Thread Starter
Fanatic Member
this is what i have
VB Code:
Private Declare Function sndPlaySound Lib "winmm" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Private Const SND_ASYNC = &H1 ' Play asynchronously
Private Const SND_NODEFAULT = &H2 ' Don't use default sound
Private Const SND_MEMORY = &H4 ' lpszSoundName points to a memory file
'Usage: PlayWavResource ResourceID
'Example: Call PlayWavResource(101)
Dim retVal As Long
Dim SoundBuffer As String
SoundBuffer = StrConv(LoadResData(pint101, "CUSTOM"), vbUnicode)
retVal = sndPlaySound(SoundBuffer, SND_ASYNC Or SND_NODEFAULT Or SND_MEMORY)
End Sub
and it says Invalid Outside Procedure and highlightd pint101
-
Oct 23rd, 2002, 07:40 PM
#3
Every command carried out by VB must be in a sub, function, or property. Only declarations can be outside of them.
VB Code:
Private Declare Function sndPlaySound Lib "winmm" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Private Const SND_ASYNC = &H1 ' Play asynchronously
Private Const SND_NODEFAULT = &H2 ' Don't use default sound
Private Const SND_MEMORY = &H4 ' lpszSoundName points to a memory file
'Usage: PlayWavResource ResourceID
'Example: Call PlayWavResource(101)
Private Sub PlayASound()
Dim retVal As Long
Dim SoundBuffer As String
SoundBuffer = StrConv(LoadResData(pint101, "CUSTOM"), vbUnicode)
retVal = sndPlaySound(SoundBuffer, SND_ASYNC Or SND_NODEFAULT Or SND_MEMORY)
End Sub
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Oct 23rd, 2002, 07:43 PM
#4
Thread Starter
Fanatic Member
cool that works, how do i make it play now when the form opens
-
Oct 23rd, 2002, 07:45 PM
#5
Just call PlayASound in the Form_Load, or Form_Activate event.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Oct 23rd, 2002, 07:46 PM
#6
PowerPoster
Put the code in the form_load event...
-
Oct 23rd, 2002, 07:48 PM
#7
Stuck in the 80s
If you would have posted this code in your other thread, Duc, you would have gotten help much faster.
-
Oct 23rd, 2002, 07:51 PM
#8
Thread Starter
Fanatic Member
wait wait, slow down. okay i have the first code in there. now what exactly do i put where to make it play when the prog begins. the res file is named 101
-
Oct 23rd, 2002, 07:53 PM
#9
Stuck in the 80s
VB Code:
Private Sub Form_Load()
PlayASound
End Sub
-
Oct 23rd, 2002, 07:54 PM
#10
PowerPoster
VB Code:
Private Declare Function sndPlaySound Lib "winmm" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Private Const SND_ASYNC = &H1 ' Play asynchronously
Private Const SND_NODEFAULT = &H2 ' Don't use default sound
Private Const SND_MEMORY = &H4 ' lpszSoundName points to a memory file
Private Sub Form_Load()
'Usage: PlayWavResource ResourceID
'Example: Call PlayWavResource(101)
Dim retVal As Long
Dim SoundBuffer As String
SoundBuffer = StrConv(LoadResData(101, "CUSTOM"), vbUnicode)
retVal = sndPlaySound(SoundBuffer, SND_ASYNC Or SND_NODEFAULT Or SND_MEMORY)
End Sub
-
Oct 23rd, 2002, 07:56 PM
#11
Thread Starter
Fanatic Member
Private Sub Form_Load()
PlayASound
End Sub
will play it? dont need to identify it? cool!
-
Oct 23rd, 2002, 08:04 PM
#12
Thread Starter
Fanatic Member
it says Resource with identifier 0 not found
VB Code:
Private Declare Function sndPlaySound Lib "winmm" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Private Const SND_ASYNC = &H1 ' Play asynchronously
Private Const SND_NODEFAULT = &H2 ' Don't use default sound
Private Const SND_MEMORY = &H4 ' lpszSoundName points to a memory file
'Usage: PlayWavResource ResourceID
'Example: Call PlayWavResource(101)
Private Sub PlayASound()
Dim retVal As Long
Dim SoundBuffer As String
SoundBuffer = StrConv(LoadResData(pint101, "CUSTOM"), vbUnicode)
retVal = sndPlaySound(SoundBuffer, SND_ASYNC Or SND_NODEFAULT Or SND_MEMORY)
End Sub
Private Sub Form_Load()
PlayASound
End Sub
-
Oct 23rd, 2002, 08:06 PM
#13
Thread Starter
Fanatic Member
HOLY FLUNKING TOADS I GOT IT TO Werk
-
Oct 23rd, 2002, 08:12 PM
#14
Thread Starter
Fanatic Member
no wait....i have
VB Code:
Private Declare Function sndPlaySound Lib "winmm" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Private Const SND_ASYNC = &H1 ' Play asynchronously
Private Const SND_NODEFAULT = &H2 ' Don't use default sound
Private Const SND_MEMORY = &H4 ' lpszSoundName points to a memory file
Private Sub Form_Load()
'Usage: PlayWavResource ResourceID
'Example: Call PlayWavResource(101)
Dim retVal As Long
Dim SoundBuffer As String
SoundBuffer = StrConv(LoadResData(101, "CUSTOM"), vbUnicode)
retVal = sndPlaySound(SoundBuffer, SND_ASYNC Or SND_NODEFAULT Or SND_MEMORY)
End Sub
Private Sub about_Click()
shouts.Show
End Sub
Private Sub area51_Click()
area.Show
End Sub
Private Sub close_Click()
Unload Me
End Sub
Private Sub gett_Click()
Shell "explorer [url]http://www.streamaudio.com/stations/player/pages/register1.asp?[/url]"
End Sub
Private Sub killed_Click()
aim.Show
End Sub
Private Sub link_Click()
Shell "explorer [url]http://www.schenectadychristian.org[/url]"
End Sub
Private Sub off_Click()
Timer1.Enabled = False
Timer2.Enabled = False
End Sub
Private Sub on_Click()
Timer1.Enabled = True
Timer2.Enabled = True
End Sub
Private Sub Timer1_Timer()
Me.Left = Me.Left - 10
Timer1.Enabled = False
Timer2.Enabled = True
End Sub
Private Sub Timer2_Timer()
Me.Left = Me.Left + 10
Timer2.Enabled = False
Timer1.Enabled = True
End Sub
Where do i put the PlayASound thing
-
Oct 23rd, 2002, 08:17 PM
#15
Stuck in the 80s
Originally posted by duc
Where do i put the PlayASound thing
You don't need it with the approach you're taking.
-
Oct 23rd, 2002, 08:18 PM
#16
Thread Starter
Fanatic Member
now that i figured it out, can i make it loop?
Last edited by duc; Oct 23rd, 2002 at 08:24 PM.
-
Oct 23rd, 2002, 08:30 PM
#17
Thread Starter
Fanatic Member
like i want the sound to keep repeating. should i use a timer or what? sorry for not editing
-
Oct 23rd, 2002, 08:45 PM
#18
PowerPoster
Originally posted by duc
like i want the sound to keep repeating. should i use a timer or what? sorry for not editing
Just plop the code that is in the form_load event in a timer event instead.
-
Oct 24th, 2002, 12:47 PM
#19
Stuck in the 80s
Originally posted by MidgetsBro
Just plop the code that is in the form_load event in a timer event instead.
Then he'd have to time the timer perfectly to match the end of the song/sound bite.
Try adding this constant:
VB Code:
Private Const SND_LOOP = &H8
and replace this line as follows:
VB Code:
'replace:
retVal = sndPlaySound(SoundBuffer, SND_ASYNC Or SND_NODEFAULT Or SND_MEMORY)
'with:
retVal = sndPlaySound(SoundBuffer, SND_LOOP Or SND_NODEFAULT Or SND_MEMORY)
I haven't tested it, so I'm not sure if it'll work.
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
|