PDA

View Full Version : Add file to library


Griffon
7th March 2008, 17:30
I write program and i need add files from some directory add to winamp library. How using SDK add files?
Please help.

Benski
18th March 2008, 03:39
Like most parts of the SDK, this only works "in-process", i.e. inside a plugin.

this code snippet should work


LMDB_FILE_ADD_INFO fi = {const_cast<char *>(filename), -1, -1};
// library == media library HWND
SendMessage(library, WM_ML_IPC, (WPARAM)&fi, ML_IPC_DB_ADDORUPDATEFILE);
// ML_IPC_DB_SYNCDB should be sent when you are done adding files
PostMessage(library, WM_ML_IPC, 0, ML_IPC_DB_SYNCDB);


Newer versions of Winamp with Unicode media library support also allow the following:


// in case these aren't in your SDK
typedef struct
{
wchar_t* fileName; // file name to add
int meta_mode; // metadata get mode (0 - don't use metadata, 1 - use metadata; -1 - read from user settings (ini file)
int gues_mode; // metadata guessing mode (0 - smart, 1 - simple; 2 - no, -1 - read from user settings (ini file)
} LMDB_FILE_ADD_INFOW;
#define ML_IPC_DB_ADDORUPDATEITEMW 0x1707

LMDB_FILE_ADD_INFOW fi = {const_cast<wchar_t *>(filename), -1, -1};
SendMessage(library, WM_ML_IPC, (WPARAM)&fi, ML_IPC_DB_ADDORUPDATEFILEW);
PostMessage(library, WM_ML_IPC, 0, ML_IPC_DB_SYNCDB);

videoBoy
17th February 2009, 22:25
Hi Benski,

I tried this piece of code and things didn't work for me -- meaning the new entries are not added to the ML view or the ML Database is updated. Any idea as to what could be going wrong ?

HWND hwndSomeHelper3 = ::FindWindow("Winamp Gen", "Winamp Library");
LMDB_FILE_ADD_INFOW fi = {const_cast<wchar_t *>(L"C:\\ws\\test.mp3"), 0, 0};

LRESULT lr1 = ::SendMessage(hwndSomeHelper3, WM_ML_IPC, (WPARAM)&fi, ML_IPC_DB_ADDORUPDATEFILEW);
// ML_IPC_DB_SYNCDB should be sent when you are done adding files
BOOL Br= ::PostMessage(hwndSomeHelper3, WM_ML_IPC, 0, ML_IPC_DB_SYNCDB);

DrO
17th February 2009, 22:44
that won't work as stated in your original thread (http://forums.winamp.com/showthread.php?threadid=303043) due to it being sent out of process. either change to a native plugin and ipc between it and your app or look at the winampmagic/readprocessmemory examples to 'hack' around the issue.

-daz