by $t0rm (1 Submission)
Category: Sound/MP3
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (3 Votes)
Play, stop, and pause MP3's with these simple functions!
While browsing PSC to figure out how to make an MP3 player, all I saw were big huge ZIP files with skins and stuff. After sifting through that code, I made a library to simplify the playing/pausing/stopping of MP3s. Put all this in a module called MP3Player:
==========================================
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
Public Sub PlayMP3(filename As String)
mciSendString "Open " & filename & " Alias MM", 0, 0, 0
mciSendString "Play MM", 0, 0, 0
End Sub
Public Sub PauseMP3()
mciSendString "Stop MM", 0, 0, 0
End Sub
Public Sub StopMP3()
mciSendString "Stop MM", 0, 0, 0
mciSendString "Close MM", 0, 0, 0
End Sub
==========================================
When playing a file, if it has spaces in the name, be sure to surround it with Chr(34)!
If you can't figure out how to use those, then you obviously aren't worthy of using them :)