Control CD audio tray, play MP3 fileTag(s): WinAPI/Registry
[external function declaration] FUNCTION ULong MciSendString(String lpszCommand, & ref String lpszReturnString, & ULong cchReturn, ULong hwndCallback) & LIBRARY "winmm.dll" & ALIAS FOR "mciSendStringA" [openCD function] String lpszReturnString ULong cchReturn, ll_rc lpszReturnString = Space(100) ll_rc = MciSendString & ( 'set cdaudio door open wait', lpszReturnString, cchReturn, 0) // ll_rc = 0 Ok [closeCD function] String lpszReturnString ULong cchReturn, ll_rc lpszReturnString = Space(100) ll_rc = MciSendString & ('set cdaudio door closed wait', lpszReturnString, cchReturn, 0) //ll_rc = 0 Ok
MCI (Media Control Interface) provides the ability to play and record (as appropriate) on any supported multimedia device. To start the music from CD, you need to send the string "play audio" and "close cdaudio" to stop the music.
See http://www.compguy.com/cwtip05.htm for a command list.
To play MP3 (remember to declare the MciSendString external function!)
String lpszReturnString string ls_mp3 = "C:\MP3\25. David Bowie - Heroes.mp3" ULong cchReturn, ll_rc lpszReturnString = Space(100) ll_rc = MciSendString & ('close MP3_Device', lpszReturnString, cchReturn, 0) ll_rc = MciSendString & ("open ~"" + ls_mp3 + "~" type MPEGVideo alias MP3_Device", & lpszReturnString, cchReturn, 0) ll_rc = MciSendString & ("play Mp3_Device", lpszReturnString, cchReturn, 0) // ll_rc = 0 Ok!
ll_rc = MciSendString & ('close MP3_Device', lpszReturnString, cchReturn, 0)
If you have multiple CD drives, you can define alias for each one ofthem.
mciSendString("open E:\\ type cdaudio alias cdaudio1", 0, 0, 0); mciSendString("open F:\\ type cdaudio alias cdaudio2", 0, 0, 0);
(MSDN) Multimedia Command Strings : http://msdn2.microsoft.com/en-us/library/ms712587.aspx
For a VBScript/Powershell solution, see this HowTo