Winamp & Shoutcast Forums

Winamp & Shoutcast Forums (http://forums.winamp.com/index.php)
-   Winamp Development (http://forums.winamp.com/forumdisplay.php?f=14)
-   -   IPC_SETPLAYLISTPOS with IPC_CHANGECURRENTFILE (http://forums.winamp.com/showthread.php?t=330835)

Joel 23rd May 2011 15:21

IPC_SETPLAYLISTPOS with IPC_CHANGECURRENTFILE
 
I'm trying to move my playlist files path to another location and update the list with the new paths:
code:

p = (HWND)SendMessage(w, WM_WA_IPC, IPC_GETWND_PE, IPC_GETWND);
total = SendMessage(p,WM_WA_IPC,IPC_PE_GETINDEXTOTAL,0);

for ( ;index < total; index++)
{
sfos.pFrom = (TCHAR*)SendMessage(w,WM_WA_IPC,index,IPC_GETPLAYLISTFILE);
if (SHFileOperation(&sfos))
{
TCHAR new_path[MAX_PATH];
TCHAR path[128];
SendMessage(w,WM_WA_IPC,index,IPC_SETPLAYLISTPOS);
StripPath (sfos.pFrom, path);
wsprintf(new_path,"%s\\%s", sfos.pTo, path);
SendMessage(w,WM_WA_IPC,(WPARAM)new_path,IPC_CHANGECURRENTFILE);
}
}


the operation copy/move is done correctly, but seems that the playlist entry doesn't reflect the new path item, any helps?

Joel 23rd May 2011 16:37

Ok, I change my code to keep it "cleaner", now Winamp crash :(
code:

int do_op (HWND parent, int op, const TCHAR *src, const TCHAR *dist)
{
SHFILEOPSTRUCT sfos = {0};
sfos.hwnd = parent;
sfos.fFlags = FOF_NOCONFIRMATION|FOF_SILENT|FOF_NOERRORUI;
sfos.wFunc = op == COPY ? FO_COPY : FO_MOVE;
sfos.pTo = dist;
sfos.pFrom = src;
return SHFileOperation(&sfos);
}

void do_it (HWND w, HWND d, int op)
{

TCHAR dir[MAX_PATH];
int index;
int total;
HWND p;

GetDlgItemText (d, IDC_EDIT1, dir, sizeof(dir)+1);
index = 0;
p = (HWND)SendMessage(w, WM_WA_IPC, IPC_GETWND_PE, IPC_GETWND);
total = SendMessage(p,WM_WA_IPC,IPC_PE_GETINDEXTOTAL,0);

for ( ;index < total; index++)
{
TCHAR *src_file = (TCHAR*)SendMessage(w,WM_WA_IPC,index,IPC_GETPLAYLISTFILE);
TCHAR dist_file[MAX_PATH];
TCHAR path[128];
StripPath (src_file, path);
wsprintf(dist_file,"%s\\%s", dir, path);
if (!do_op (w, op, src_file, dist_file))
{
SendMessage(w,WM_WA_IPC,index,IPC_SETPLAYLISTPOS);
SendMessage(w,WM_WA_IPC,(WPARAM)dist_file,IPC_CHANGECURRENTFILE);
}
}
}


Joel 23rd May 2011 23:56

ok, my error was in my StripPath function, now works as expected :)

DrO 24th May 2011 07:31

heh, didn't i ask if it was stripping and forming the path correctly in irc ;)

-daz


All times are GMT. The time now is 21:12.

Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.