Not a Member Yet,
Click here to Register
How do you like the new design?






ID: 400
Viewed: 2973
Added: Aug 19, 2002
Version:
Snippet uploaded by: snippet
Written By: Unknown
Demo: Sorry, no demo



User Rated at: 0 Stars
Rate This:

Thank you for your vote. Please wait...

It appears you already voted for this snippet

It appears your vote value was empty

ok two ways to do this. one is to goto components and
instert the mmcontrol "microsoft mutlimedia control 6.0."
where ever you want to play a sound put this code.

Highlight all by clicking in box
<!---Declaration--->
none

Highlight All
<!---Code--->
'code: 
cdsave.ShowOpen 'You dont have to put this in it just is to 'open a wav file
MMControl1.FileName = cdsave.FileName 'or put in ex '"c:wav.wav" your file name
'stops mmcontrol
MMControl1.Command = "Stop"
'opens file
MMControl1.Command = "Open"
'plays file
MMControl1.Command = "Play"

'thats one way and it can play most sound files but ive 'only 'used wav and mp3's.

'********************************************************************8
'if you want to do it threw api put this code in, but its 'hard
'code:

Private Declare Function mciGetErrorString Lib "winmm.dll" Alias "mciGetErrorStringA" (ByVal dwError As Long, ByVal lpstrBuffer As String, ByVal uLength As Long) As Long
Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long
Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
Private TheFileName As String, RecordMode As Boolean, dwreturn(1 To 4) As Long
Private ret As String * 128, OpenFile As Boolean, playingfile As Boolean

Dim tmp As String * 255
Dim lenShort As Long
Dim ShortPathAndFie As String
mciSendString "close mpeg", 0&, 0&, 0&
'check for an existing playing song
If playingfile = True Then mciSendString "stop mpeg", 0&, 0&, 0&

'close any open files first, to use this the mcierror function should not be used
If OpenFile = True Then mciSendString "close mpeg", 0&, 0&, 0&

'I have included a common Dialog box so you can choose an mp3
Open1.FileName = "" 'remove any previous filenames
Open1.flags = cdlOFNExplorer 'explorer interface
Open1.Filter = "Supported Files|*.mp3;*.wav" 'allow wav's or mp3's
Open1.ShowOpen
FileName = Open1.FileName
If FileName = "" Then Exit Sub 'If the user clicks cancel then nothing to open

lenShort = GetShortPathName(FileName, tmp, 255)
ShortPathAndFie = Left$(tmp, lenShort)
dwreturn(1) = mciSendString("open " & ShortPathAndFie & " type MPEGVideo Alias mpeg", 0&, 0&, 0&)

If dwreturn(1) <> 0 Then 'not success
MCIError (dwreturn(1))
Exit Sub
End If
OpenFile = True
cmdPlay_Click

Dim dwreturn(1 To 2) As Long
Dim ret As String * 128
'is the record mode turned on
If RecordMode = True Then 'yes
dwreturn(1) = mciSendString("open new type waveaudio Alias tune", 0&, 0&, 0&)
dwreturn(2) = mciSendString("record tune", 0&, 0, 0) 'play the mp3 after this one
For i = 1 To 2
If dwreturn(i) <> 0 Then
MCIError dwreturn(i)
Exit Sub
End If
Next i
End If
'Now play the open mp3 or wav
dwreturn(1) = mciSendString("play mpeg from 0", 0&, 0&, 0&)

If dwreturn(1) <> 0 Then
MCIError dwreturn(1)
Exit Sub
End If


'ull probly have to fix that a little too.
'if ur a newbie i would use the first one cause api is 'hard. and u can make it invisable and tell it to do all 'the cmds. you can figer it out easly.

'o yea put this in your code in the exit sub.

'mmcontrol1
MMControl.Command = "Close"
'api
mciSendString "close mpeg", 0&, 0&, 0&
;


No Comments to show

Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.


Replying to a Comment...


Adding your comment. Please wait...

Thanks for adding your comment!. After further review it will be added.

There was a problem adding your comment. Please try again.

Please complete all the fields in the form before sending.

© 2002 - 2017 snippetlibrary.com All Rights Reserved. Conditions