qwertyjustin
09-17-2000, 12:50 AM
hello,...i'm just asking how,...after pressing a button a .wav file will play,..how do i go about that exaclty?
that's all i want to happen to, i know very limited,..but that's just the way it is.. so, any help would be greatly appreciated..;)
thanx
BillSoo
09-17-2000, 06:07 AM
Much as I'd like to help you, I can't since all my code is at work. I remember that you use the multimedia DLL API calls but that's it. If nobody else helps, I'll upload my code on Monday.
"I have a plan so cunning you could put a tail on it and call it a weasel!" - Edmund Blackadder
johnjr
09-17-2000, 08:30 AM
TRY THIS.....FOLLOW INSTRUCTIONS
JOHN
'**************************************
' Name: Easily Play a WAV File
' Description:This source code will easi
' ly allow you to play a WAV file from wit
' hin your Visual Basic application WITHOU
' T using an ActiveX Control. The two most
' amazing facts about this source code tha
' t amazed me were:
• The value For the "flag." I had absolutely no idea what to Do for the flag. But I took a good guess at it, and I got it!
• It will actually play the WAV file from the Visual Basic environment (you don't need to compile it to hear the sound).
' By: Terrance Henry Shaw
'
'
' Inputs:None
'
' Returns:None
'
'Assumes:1) Create one (1) CommandButton
' Control on the Form, and set the Name pr
' operty to "cmdSound" (minus the quotes).
'
'
'Side Effects:None
'
'Warranty:
'Code provided by Planet Source Code(tm)
' (http://www.Planet-Source-Code.com) 'as
' is', without warranties as to performanc
' e, fitness, merchantability,and any othe
' r warranty (whether expressed or implied
' ).
'Terms of Agreement:
'By using this source code, you agree to
' the following terms...
' 1) You may use this source code in per
' sonal projects and may compile it into a
' n .exe/.dll/.ocx and distribute it in bi
' nary format freely and with no charge.
' 2) You MAY NOT redistribute this sourc
' e code (for example to a web site) witho
' ut written permission from the original
' author.Failure to do so is a violation o
' f copyright laws.
' 3) You may link to this code from anot
' her website, provided it is not wrapped
' in a frame.
' 4) The author of this code may have re
' tained certain additional copyright righ
' ts.If so, this is indicated in the autho
' r's description.
'**************************************
Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Private Sub PlayWav(Filename As String)
sndPlaySound (Filename), &H80
End Sub
Private Sub cmdSound_Click()
PlayWav "C:WINDOWSMediaChord.wav"
'Chord.wav is a file that comes along wi
' th both
'Windows 95 and 98 Operating Systems. If
' your
'system is missing this file, specify a
' different WAV.
End Sub
'Now, press F5, or the Run button in the
' Visual Basic
'Environment, and then click the button.
' If you enjoy
'this source code, please let me know by
' posting feedback.
'Thanks!
cbrewer
09-18-2000, 07:11 AM
In short, and without the terms of agreement.
Put this in the general section of you form:
Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Create a command button and use this:
Private Sub Command1_Click()
sndPlaySound ("C:WINDOWSMediaChord.wav"), 0
End Sub
You can change the path to find your wav file.
You can get all the API calls using the API viewer, a tool which I think comes with most versions of VB. Load the Win32api.txt or Win32api.mdb file.
Chuck