Article View: comp.lang.basic.visual.misc
Article #273Playing a wav file through MCI
From: Curious Student
Date: Sat, 19 Jun 2004 13:37
Date: Sat, 19 Jun 2004 13:37
72 lines
3316 bytes
3316 bytes
I get an error while playing a wav file. I am using VB6 and the MCI
(winmm.dll) interface. But the front end doesn't matter. I need help
resolving an error that MCI throws back on me when I open the device.
The error comes as a return value to the "Open" string message.
[CODE]
Private Sub Form_Load()
BoolRecordingOn = False
If waveOutGetNumDevs() <= 0 Then MsgBox "Your system can't play
sounds.", vbCritical, "Sound Card Not Available"
End Sub
Private Sub cmdOpen_Click()
c.CancelError = False
c.ShowOpen
StrFile = vbNullString
If Trim(c.FileName) <> vbNullString Then StrFile =
GetShortFileName(c.FileName)
End Sub
Private Sub cmdPlay_Click()
If StrFile = vbNullString Then Exit Sub
BoolRecordingOn = False
cmdRecord.Enabled = False
StrCommand = "Open " & StrFile & " type waveaudio alias StrFile1"
LngRetVal = mciSendString(StrCommand, vbNullString, 0&, 0&)
If LngRetVal <> 0 Then DisplayError (LngRetVal)
StrCommand = "Play StrFile1"
LngRetVal = mciSendString(StrCommand, 0, 0, 0)
If LngRetVal <> 0 Then DisplayError (LngRetVal)
End Sub
Private Sub DisplayError(ByVal errcode As Long)
Dim errstr As String
Dim retval As Long
errstr = Space(255)
retval = mciGetErrorString(errcode, errstr, Len(errstr))
errstr = Left(errstr, InStr(errstr, vbNullChar) - 1)
retval = MsgBox(errstr, vbOKOnly Or vbCritical)
End Sub
Public Function GetShortFileName(ByVal FileName As String) As String
Dim StrShortFileName As String
Dim LngRetVal As Long
GetShortFileName = vbNullString
StrShortFileName = Space(255)
LngRetVal = GetShortPathName(FileName, StrShortFileName,
Len(StrShortFileName))
Debug.Assert LngRetVal <> 0
StrShortFileName = Left(StrShortFileName, LngRetVal)
GetShortFileName = Trim(StrShortFileName)
End Function
[/CODE]
I get this error message:
[QUOTE][B]No wave device that can play files in the current format is
installed. Use the Add/Remove Hardware Wizard in Control Panel to
install the wave device.[/B][/QUOTE]
If I didn't the device to support the WAV file, how is it that other
programs like WinAmp can play the same WAV file. Surely I have the
necessary stuff on my system. What do I do?
Technical Details
Message-ID:
<c520b56a.0406190537.16054229@posting.google.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!postnews2.google.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 110e3b,2c9122eb691bb6cd,start X-Google-Thread: 115960,15636ed7f848530e,start X-Google-Thread: 11493c,8f82aaf06c0da2aa,start X-Google-Thread: fa7d6,4ef6ea2241c4e51f,start X-Google-Attributes: gid110e3b,gid115960,gid11493c,gidfa7d6,public Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews2.google.com!not-for-mail From: estudiantin@rediffmail.com (Curious Student) Newsgroups: comp.lang.basic.visual.misc,comp.os.ms-windows.programmer.multimedia,microsoft.public.vb.general.discussion,borland.public.delphi.multimedia Subject: Playing a wav file through MCI Date: 19 Jun 2004 06:37:40 -0700 Organization: http://groups.google.com Lines: 72 Message-ID: <c520b56a.0406190537.16054229@posting.google.com> NNTP-Posting-Host: 203.190.143.244 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1087652267 22619 127.0.0.1 (19 Jun 2004 13:37:47 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 19 Jun 2004 13:37:47 +0000 (UTC)