Play MP3 without WINAMP using Lotus Script

Do you remember “MP3 PlayMate ” for Lotus Notes written by Allan Reinhold Kildeby ?

Well, it is a very nice tool, but you need Winamp to play the mp3 files.
Today it is one of these boring sundays and I thougth to myself: “Wouldn’t it be nice to play the mp3s directly thru some nice API code ? “.

By using MCI, you can play most media files. but normaly, it doesn’t work for MP3. This is because mp3-data needs to be rendered specially. After a beer or two i had an idea while looking at the code using DirectShow: why not play the mp3-files as VIDEO? OK, here’s how it works:

(1.) Declare the Function

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

(2.) Use “mciSendString” to invoke the commands:

Syntax: mciSendString(sCommand, 0, 0, 0)

where sCommand is:

Load the mp3 file:=  “open ” & sMp3FileLocation & ” type MPEGVideo alias Mp3File”
Play the mp3 file (Now you can use the Alias):= “play Mp3File” from 0″
Pause:= “pause Mp3File””
Stop:= “stop Mp3File”
and unload from mem, unlock file:= “close Mp3File”

(3.) put the commands into a button for testing purpose

Sub Click(Source As Button)
	Dim sCommand As String
	Dim sMP3FileLocation As String
	sMP3FileLocation = "whateverMP3youlike.mp3"
	sCommand = "Open " & sMP3FileLocation & "  type MPEGVideo alias MP3File"
	Call mciSendString(sCommand, 0, 0, 0)
	scommand = "play MP3File from 0"
	Call mciSendString(sCommand, 0, 0, 0)
	Msgbox "OK"
	scommand = "stop MP3File"
	Call mciSendString(sCommand, 0, 0, 0)
	scommand ="close MP3File"
	Call mciSendString(sCommand, 0, 0, 0)
End Sub

(4.) tweak PlayMate
(5.) Have fun !!