17. marts 2003 - 22:40
#1
Søg på google: "music vb background"
Andet hit:
Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal
lpszSoundName As String, ByVal uFlags As Long) As Long
form:
Private Sub Form_Load()
Dim Mywav As String
Mywav = App.Path
If Right(Mywav, 1) <> "\" Then
Mywav = Mywav + "\"
End If
Mywav = Mywav + "Ahhh.wav"
sndPlaySound Mywav, SND_ASYNC
17. marts 2003 - 22:48
#3
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
Dim sFileName As String
Dim sBuffer As String
'Hard-coded for example purposes only
sFileName = "C:\My Documents\My Music\70s\STRANGLEHOLD - TED NUGENT.mp3"
sBuffer = String$(260, 0)
GetShortPathName sFileName, sBuffer, 260
sFileName = Left$(sBuffer, InStr(sBuffer, vbNullChar) - 1)
mciSendString "play " & sFileName, vbNullString, 0&, 0&
If you need to stop playback prior to the MP3 finishing, use the following:
mciSendString "close all", vbNullString, 0&, 0&