hallo zusammen, möchte gerne eine Wave Datei abspielen und deren Länge ermitteln. Aus vielen Tips und Tricks aus den Foren, habe ich mir etwas zusammengestellt und ausprobieren wollen. Mein Problem besteht darin, das die Wave Date nicht abgespielt bzw. deren Länge angezeicht wird. Letzeres als Beispiel.
Im GetShortPath Pad bleibt immer ein freizeichen übrig (...\Service Helper\...) und daran denke ich mal, scheitert es. Ein Fehler, keine Zeitangabe
Ich habe schon verschiedene Methoden ausprobiert, mit Chr(34) vor udn danach, manuell " am Anfang und Ende gesetzt aber immer wieder der gleiche Fehler, warum? Was mache ich falsch?
Danke für Eure Hilfe in vorab
Gruß Oly
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 lBuffer As Long) As Long
Public Function GetShortPath( _
ByVal sLongPath As String) _
As String
Dim sShortPath As String
sShortPath = VBA.String(260, 0)
If GetShortPathName(sLongPath, _
sShortPath, Len(sShortPath)) Then
GetShortPath = _
VBA.Left(sShortPath, _
VBA.InStr(sShortPath, vbNullChar) - 1)
End If
End Function
Function Wave_Länge(Dateiname)
Dim i As Long, RS As String, cb As Long, s As Single
Wave_Länge = 0
RS = Space$(128)
i = mciSendString("stop sound", RS, 128, cb)
i = mciSendString("close sound", RS, 128, cb)
i = mciSendString("open waveaudio!" & _
Dateiname & " alias sound", RS, 128, cb)
If i Then Wave_Länge = -1
i = mciSendString("status sound length", RS, 128, cb)
If Wave_Länge = 0 Then Wave_Länge = RS / 1000
i = mciSendString("stop sound", RS, 128, cb)
i = mciSendString("close sound", RS, 128, cb)
End Function
Private Sub Command1_Click()
MsgBox GetShortPath(C:\Dokumente und _
Einstellungen\Ich.ICH-1A7E557965B\Desktop\Service Helper\rooster.wav))
l = Wave_Länge("C:\Dokumente und" & _
"Einstellungen\Ich.ICH-1A7E557965B\Desktop\Service Helper\rooster.wav")
If l = -1 Then
MsgBox "Fehler"
Else
MsgBox "Länge: " & l & " Sekunden"
End If
End Sub |