TheProgrammingZone
TheProgrammingZone.com
Welcome, Guest. Please login or register.
January 05, 2009, 10:51:04 pm

Login with username, password and session length
Search:     Advanced search
Welcome to the TheProgrammingZone.com forums.
217 Posts in 83 Topics by 758 Members
Latest Member: joomlanews
* Home Help Search Staff List Login Register
Sponsored Links
+  TheProgrammingZone.com
|-+  Programming
| |-+  Visual Basic (5/6)
| | |-+  playing a .wav file in a VB6.0 program
« previous next »
Pages: [1] Print
Author Topic: playing a .wav file in a VB6.0 program  (Read 1770 times)
Capodice
Newbie
*
Posts: 1


View Profile
playing a .wav file in a VB6.0 program
« on: June 08, 2005, 02:05:46 pm »

I am creating a splashscreen for my program and all i want to do is play a .wav file when the splashscreen comes up. I don't want the user to have to click on a button or do anything at all, I just want the sound to play all by itself.
The path for the .wav file is:
c:\windows\media\explode.wav

I am totally a beginner and I am not getting any help from the book I have.
Please help me...
James
Logged
TheProgrammingZone
Administrator
Beginner
*****
Posts: 68



View Profile
playing a .wav file in a VB6.0 program
« Reply #1 on: June 08, 2005, 03:35:35 pm »

The easist way to play sound is to use the PlaySound api call.
Heres the example from api Guide
[vb]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: http://www.allapi.net/
    'E-Mail: KPDTeam@Allapi.net
    PlaySound "C:\WINDOWS\MEDIA\TADA.WAV", ByVal 0&, SND_FILENAME Or SND_ASYNC
End Sub[/vb]
Logged
AyoiMalaysian
Newbie
*
Posts: 3


View Profile
Elaboration Needed
« Reply #2 on: July 29, 2005, 05:11:54 am »

can someone elaborate more of this code??

i don understand... is that easy to code to play a music??
Logged
Qex
Newbie
*
Posts: 4


View Profile WWW
Re: Elaboration Needed
« Reply #3 on: September 18, 2005, 01:43:27 am »

Quote from: AyoiMalaysian
can someone elaborate more of this code??

i don understand... is that easy to code to play a music??


Yes, it is easy. Heres what you do.

Code:

Private Sub Form_Load()
   'KPD-Team 2000
   'URL: http://www.allapi.net/
   'E-Mail: KPDTeam@Allapi.net

   'Change the below C:\WINDOWS\MEDIA\TADA.WAV to the location of
   'the wav file you are wishing to use.
   PlaySound "C:\WINDOWS\MEDIA\TADA.WAV", ByVal 0&, SND_FILENAME Or SND_ASYNC
End Sub


If you want to play a sound when a user clicks a command button you will do this: (note: We will use Command1 as the control name.)

Code:

Private Sub Command1_Click()
Call PlaySound "C:\WINDOWS\MEDIA\TADA.WAV", ByVal 0&, SND_FILENAME Or SND_ASYNC
End Sub


You might have to change the Function to Public.

Also you can call the Command1_Click anywhere on the form.

Code:

Dim bPlay as Boolean
'You don't need End If if the If Statment is 1 line
If bPlay = True Then Call Command1_Click


Hope this helps you understand more.

Qex
Logged

Make peace not war, Make love not homos.
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP TheProgrammingZone.com | Powered by SMF 1.0.15.
© 2005, Simple Machines LLC. All Rights Reserved.
Valid XHTML 1.0! Valid CSS!
Seo urls funded by a mortgage broker | implemented by the treo smartphone guy.
© 2006, SMFSEO.org. All Rights Reserved.
TheProgrammingZone 2007
Site Map