|
|
#1 |
|
Junior Member
Join Date: Apr 2002
Posts: 5
|
Problem telling Winamp to play a file in Delphi
Hi,
I'm wanting to tell Winamp to play a file/add a file to the playlist in Delphi. Has anyone got a reliable Procedure to do this? I do have this, which came from a freeware component to control winamp: procedure AddMp3ToPlayList(mp3ToAdd:string); Var x : integer; begin Mp3ToAdd:=MP3ToAdd+#0; GethWnd_WinAmp; for x:=0 to Length(MP3ToAdd) do PostMessage(hwnd_winamp,wm_user,ord(mp3toadd[x]),IPC_PLAYFILE); // also crashes if I comment the line below out PostMessage(hwnd_winamp,wm_user,0,IPC_PLAYFILE); end; But this unfortunately works when adding the first time, for some weird reason it causes Winamp to crash with "This application performed an illegal operation", on tryiing to add a second file. Thanks |
|
|
|
|
|
#2 |
|
Junior Member
Join Date: Apr 2002
Posts: 5
|
IPC_PLAYFILE = 100;
by the way
|
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Feb 2002
Location: The backside of the universe on the trailing edge of eternity
Posts: 238
|
maybe your problem is the use of PostMessage, instead of SendMessage? I dunno, that seems strange behavior, it's hard to determine it when it works one time and not another. BTW, I dont know if you can, but try stepping through your code and checking out the values you get, see if maybe something is failing. if you pass 0 to one of those, that could be it.
|
|
|
|
|
|
#4 |
|
Junior Member
Join Date: May 2002
Location: out there
Posts: 30
|
Well, all I can give you is this piece of C++ code. But I think you can translate it into Delphi-Pascal.
bool __fastcall TWinamp::AddSong(AnsiString File) { typedef struct { char file[MAX_PATH]; int index; } fileinfo; COPYDATASTRUCT cds; fileinfo f; HWND hwndWinamp = FindWindow("Winamp v1.x",NULL); HWND hwndWinampPlaylist = FindWindow("Winamp PE",NULL); if(hwndWinampPlaylist && hwndWinamp) { cds.dwData = 106; strcpy(f.file, File.c_str()); // Path to the new entry // Get # of Songs, add file to the end of current playlist f.index = SendMessage(hwndWinamp, WM_USER, 0, 124) + 1; cds.lpData = (void *)&f; cds.cbData = sizeof(fileinfo); SendMessage(hwndWinampPlaylist ,WM_COPYDATA, (WPARAM)NULL, (LPARAM)&cds); // select inserted song SendMessage(hwndWinamp,WM_USER, f.index, 121); //now start playing SendMessage(hwndWinamp,WM_COMMAND, 40045, 0); return true; } return false; } |
|
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|