[VB6] - mcisendstring() api function delay problem
using mcisendstring() api function, when you play the sound, you see a delay(by some seconds). is possible avoid these delay?
there is another function so powerfull(only for audio) that can avoid these delay?
Re: [VB6] - mcisendstring() api function delay problem
Originally Posted by RhinoBull
Maybe you can post your code as I have no clue what delays are you talking about - it could be something in your own program.
ok.. heres my class.
and how use it:
Code:
Dim Sound As New Sound
Sound.FileName = CommonDialog1.FileName 'change the filename(string)
Sound.SoundPlay 'play's the audio file
sound.soundstop 'stop's the audio file
use my class and choose mp3 or wave or mid. then you will see 1 delay befor play it. and then tell me if it's normal or not.
thanks
Re: [VB6] - mcisendstring() api function delay problem
ok.. now works:
Code:
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 Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long
Const MAX_PATH As Long = 260
Dim strFileName As String
Private Sub Command1_Click()
CommonDialog1.ShowOpen
strFileName = GetShortFileName(CommonDialog1.FileName)
mciSendString "play " & strFileName, "", 0, 0
End Sub
Private Function GetShortFileName(ByVal sFileName As String) As String
Dim sBuffer As String
sBuffer = String$(MAX_PATH, vbNullChar)
Call GetShortPathName(sFileName, sBuffer, MAX_PATH)
GetShortFileName = Left$(sBuffer, InStr(sBuffer, vbNullChar) - 1)
End Function
Private Sub Command2_Click()
mciSendString "stop " & strFileName, "", 0, 0
End Sub
but the delay continues. why GetShortFileName() function?
is for i use the file name, or the mcisendstring() don't works.
in mcisendstring(), why a short file name instead a normal file name?
Last edited by joaquim; May 3rd, 2011 at 08:29 AM.