|
-
Oct 19th, 2005, 01:41 AM
#1
Thread Starter
New Member
Attaching a sound
Hi all could someone teach me how to attach a sound clip (wav) to my vb6 program? its like after i click this button i want it to play a specific audio file
-
Oct 19th, 2005, 03:05 AM
#2
Re: Attaching a sound
Welcome to the forums.
Is this what you're looking for?
VB Code:
Private Const SND_APPLICATION = &H80 ' look for application specific association
Private Const SND_ALIAS = &H10000 ' name is a WIN.INI [sounds] entry
Private Const SND_ALIAS_ID = &H110000 ' name is a WIN.INI [sounds] entry identifier
Private Const SND_ASYNC = &H1 ' play asynchronously
Private Const SND_FILENAME = &H20000 ' name is a file name
Private Const SND_LOOP = &H8 ' loop the sound until next sndPlaySound
Private Const SND_MEMORY = &H4 ' lpszSoundName points to a memory file
Private Const SND_NODEFAULT = &H2 ' silence not default, if sound not found
Private Const SND_NOSTOP = &H10 ' don't stop any currently playing sound
Private Const SND_NOWAIT = &H2000 ' don't wait if the driver is busy
Private Const SND_PURGE = &H40 ' purge non-static events for task
Private Const SND_RESOURCE = &H40004 ' name is a resource name or atom
Private Const SND_SYNC = &H0 ' play synchronously (default)
Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Private Sub Form_Load()
'KPD-Team 2000
'URL: [url]http://www.allapi.net/[/url]
PlaySound "C:\WINDOWS\MEDIA\TADA.WAV", ByVal 0&, SND_FILENAME Or SND_ASYNC
End Sub
This world is not my home. I'm just passing through.
-
Nov 7th, 2005, 02:44 AM
#3
Thread Starter
New Member
Re: Attaching a sound
there seems to be something wrong with this line :
Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
There was a pop up error msg...
-
Nov 7th, 2005, 02:52 AM
#4
Re: Attaching a sound
This keeps repeating until you press the button again to stop it.
Add a command button, and erase everything in the form, before you paste this code in. (Make sure that your wave file is in the right folder)
VB Code:
Option Explicit
Private Const SND_APPLICATION = &H80 ' look for application specific association
Private Const SND_ALIAS = &H10000 ' name is a WIN.INI [sounds] entry
Private Const SND_ALIAS_ID = &H110000 ' name is a WIN.INI [sounds] entry identifier
Private Const SND_ASYNC = &H1 ' play asynchronously
Private Const SND_FILENAME = &H20000 ' name is a file name
Private Const SND_LOOP = &H8 ' loop the sound until next sndPlaySound
Private Const SND_MEMORY = &H4 ' lpszSoundName points to a memory file
Private Const SND_NODEFAULT = &H2 ' silence not default, if sound not found
Private Const SND_NOSTOP = &H10 ' don't stop any currently playing sound
Private Const SND_NOWAIT = &H2000 ' don't wait if the driver is busy
Private Const SND_PURGE = &H40 ' purge non-static events for task
Private Const SND_RESOURCE = &H40004 ' name is a resource name or atom
Private Const SND_SYNC = &H0 ' play synchronously (default)
Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Dim flag As Boolean
Private Sub Command1_Click()
If Not flag Then
Command1.Caption = "Stop"
PlaySound "C:\WINDOWS\MEDIA\TADA.WAV", ByVal 0&, SND_ASYNC Or SND_LOOP
Else
Command1.Caption = "Play"
PlaySound "C:\WINDOWS\MEDIA\TADA.WAV", ByVal 0&, SND_MEMORY
End If
flag = Not flag
End Sub
Private Sub Form_Load()
'KPD-Team 2000
'URL: [url]http://www.allapi.net/[/url]
Command1.Caption = "Play"
End Sub
-
Nov 7th, 2005, 04:20 AM
#5
Re: Attaching a sound
there seems to be something wrong with this line :
Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
There was a pop up error msg...
Start a new project. Paste in the code I gave you. Do you still get the message?
This world is not my home. I'm just passing through.
-
Nov 9th, 2005, 08:54 PM
#6
Thread Starter
New Member
Re: Attaching a sound
Oh Great its working already, thanks alot guys
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
|