AW: OT Nepumuk
06.09.2008 09:55:00
Tino
Hallo,
habe auch mal mit mp3 in VB6 was gemacht.
Hier der Code (aus VB6),
in Excel muss aus "App.Path", ThisWorkbook.Path oder ActiveWorkbook.Path warden.
Option Explicit
Private Declare Function mciSendString Lib "winmm.dll" _
Alias "mciSendStringA" (ByVal lpszCommand As String, _
ByVal lpszReturnString As String, _
ByVal cchReturnLength 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
Dim strPfadMusik As String
Public Function MP3_Play(ByVal sFile As String, ByVal sAlias As String) As Boolean
Dim bResult As Boolean
Dim sBuffer As String
Dim lResult As Long
sBuffer = Space$(255)
lResult = GetShortPathName(sFile, sBuffer, Len(sBuffer))
If lResult <> 0 Then
sFile = Left$(sBuffer, InStr(sBuffer, vbNullChar) - 1)
lResult = mciSendString("open " & sFile & " type MPEGVideo alias " & sAlias, 0, 0, 0)
If lResult = 0 Then
If mciSendString("play " & sAlias & " from 0", 0, 0, 0) = 0 Then
bResult = True
End If
End If
End If
MP3_Play = bResult
End Function
Sub MP3_Stop(ByVal sAlias As String)
mciSendString "stop " & sAlias, 0, 0, 0
mciSendString "close " & sAlias, 0, 0, 0
End Sub
Sub Mach_Musik(strDatei As String)
MP3_Play strDatei, "MyAlias"
End Sub
Private Sub Form_Load()
strPfadMusik = IIf(Right$(App.Path, 1) = "\", App.Path, App.Path & "\")
End Sub
Private Sub Command1_Click() 'start Musik
Mach_Musik (strPfadMusik & "01 Ronan Keating - If Tomorrow Never Comes.mp3")
End Sub
Private Sub Command2_Click() 'stop Musik
MP3_Stop "MyAlias"
End Sub
Mit dem Verpackungsassistent von VB6,
kannst du ja die MP3 mit in den Ordner Installieren lassen.
Gruß Tino
www.VBA-Excel.de