Old 20th January 2010, 13:25   #1
-ex-
Junior Member
 
-ex-'s Avatar
 
Join Date: Nov 2009
Location: Malaysia
Posts: 45
Hi again.. If I want to create plugin that generate playlist, should it be a General Purpose or a Media Library plugin?
And then how do I use this SDK to create playlist, access the songs, etc?
-ex- is offline   Reply With Quote
Old 20th January 2010, 14:52   #2
DrO
 
Join Date: Sep 2003
Posts: 27,873
you can do it in either plug-in style though as a general purpose plug-in you're not limited to having to have the media library installed unless you're relying on data from it.

it also depends on what you're looking to do as generally if you're wanting to do your own handling on the playlist then it's better to do what you need yourself as from what i remember the interfaces for the media library playlists is really only for adding/removing playlists and not the direct handling of what they contain (though has been a while since i looked at the files offered to do with the playlists).

-daz
DrO is offline   Reply With Quote
Old 20th January 2010, 16:36   #3
-ex-
Junior Member
 
-ex-'s Avatar
 
Join Date: Nov 2009
Location: Malaysia
Posts: 45
Quote:
Originally posted by DrO
you can do it in either plug-in style though as a general purpose plug-in you're not limited to having to have the media library installed unless you're relying on data from it.

it also depends on what you're looking to do as generally if you're wanting to do your own handling on the playlist then it's better to do what you need yourself as from what i remember the interfaces for the media library playlists is really only for adding/removing playlists and not the direct handling of what they contain (though has been a while since i looked at the files offered to do with the playlists).

-daz
Thanks for the enlightenment!

Well basically, I want to create playlists based on user's choice of BPM level. I want Winamp to pick songs from Media Library or folder and put them in the playlist. So what do u think? Any better suggestion?

And now I don't understand how can I tell the plugin to do that..

Please help me.. This is my Final Year Project..

Thanks a lot..
-ex- is offline   Reply With Quote
Old 25th January 2010, 07:57   #4
DrO
 
Join Date: Sep 2003
Posts: 27,873
well there's nothing stopping you from querying the ml or a specific folder (from a folder would have to be done by yuorself).

then you either create the playlist manually and enqueue it into the playlist editor or enqueue the file(s) one at a time and tell winamp to write the playlist out and copy the winamp.m3u(8) playlist saved to a folder of your choice (if you were looking to keep a copy of the files). manually creating is probably better as you then have control over the file and can keep a copy if you need to do so (otherwise direct enqueue of each item is better but is a bit slower).

the only issue is really how you're determining the bpm of the files as i think you can query metadata with "bpm" on v5.51 clents if recorded in the file (and if the format supports the tag). but i'd hope you'd have worked out how to do that before starting on such a project.

-daz
DrO is offline   Reply With Quote
Old 25th January 2010, 15:13   #5
-ex-
Junior Member
 
-ex-'s Avatar
 
Join Date: Nov 2009
Location: Malaysia
Posts: 45
Yeah, i had the BPM thing figured out.

So now, how do I create the playlist manually?
I really do not understand how to use the SDK..
Which header files should I include and which APIs should I use?

thanks
-ex- is offline   Reply With Quote
Old 25th January 2010, 15:26   #6
DrO
 
Join Date: Sep 2003
Posts: 27,873
if you want to use Winamp's playlist editor to create things then wa_ipc.h and IPC_ENQUEUEFILE and IPC_DELETE should be enough.

otherwise if creating it before using IPC_ENQUEUEFILE then you can use any method of creating the playlist (just needs to be filepaths in a file at the most basic level).

as for header files, depends on the features being used as to what is needed though along wias wa_ipc.h, you'd need ml.h and possibly ml_ipc_0313.h (depending on the client you're targetting as things work differently on different client versions). though really without implementing it all myself (which goes against it being your final project) then i can't say for certain which files/exact api's are required.

-daz
DrO is offline   Reply With Quote
Old 25th January 2010, 15:41   #7
-ex-
Junior Member
 
-ex-'s Avatar
 
Join Date: Nov 2009
Location: Malaysia
Posts: 45
okay, thanks a lot, really appreciate it..

i will try working on it again, and if i find any problem, i will get back to you..

regards..
-ex- is offline   Reply With Quote
Old 25th January 2010, 15:52   #8
DrO
 
Join Date: Sep 2003
Posts: 27,873
good luck with it all

-daz
DrO is offline   Reply With Quote
Old 26th January 2010, 08:26   #9
-ex-
Junior Member
 
-ex-'s Avatar
 
Join Date: Nov 2009
Location: Malaysia
Posts: 45
Hi DrO,

In the wa_ipc.h, all the SendMessage() functions have a hwnd_winamp as one of its parameters. I want to use it in the user interface, but I always get an error that says it is an undeclared identifier.
I know that in the gen_myplugin.cpp, I can use plugin.hwndParent as the parameter, but how about outside of it? I always get two errors, one is
Quote:
error C2065: 'plugin' : undeclared identifier
and another is
Quote:
error C2228: left of '.hwndParent' must have class/struct/union

Last edited by -ex-; 26th January 2010 at 09:38.
-ex- is offline   Reply With Quote
Old 26th January 2010, 10:24   #10
DrO
 
Join Date: Sep 2003
Posts: 27,873
typically to use it in other source files you'd need to define the plugin struct as an extern variable in a shared header file and then include that file in the related source files ie extern winampGeneralPurposePlugin plugin; and then the body of plugin is initialised correctly in your main source file.

also you say you're using gen_myplugin as a basis, i'd suggest using the as a basis for a plug-in now as it is a complete example for a current style plug-in (as you can ignore the localisation stuff if required but it has a few api calls shown to make the plug-in better compatible (unicode issues) with current clients.

-daz
DrO is offline   Reply With Quote
Old 26th January 2010, 14:54   #11
-ex-
Junior Member
 
-ex-'s Avatar
 
Join Date: Nov 2009
Location: Malaysia
Posts: 45
Quote:
extern winampGeneralPurposePlugin plugin
It works! Thank you so much..

Oh I got another error from the SendMessage(), it says:
Quote:
error C2661: 'System::Windows::Forms::Control::SendMessage' : no overloaded function takes 4 arguments
Then my friend googled it and he said I should add double colons in front of the function, and it worked, can you explain about this? Is there any way to tidy this up?
-ex- is offline   Reply With Quote
Old 26th January 2010, 15:29   #12
DrO
 
Join Date: Sep 2003
Posts: 27,873
going against what you've pasted i guess you're using WinForms maybe and it's trying to override the standard Win32 SendMessage(..) which a :: in front will allow it to be used instead of being taken from a class (though i'm really not sure on the correct terminology for it all, heh).

-daz
DrO is offline   Reply With Quote
Old 26th January 2010, 15:37   #13
-ex-
Junior Member
 
-ex-'s Avatar
 
Join Date: Nov 2009
Location: Malaysia
Posts: 45
Oh I see..

So now I suppose I should work on querying Media Library or a specific folder for desired songs. Now can you help me on how to do this?

Thanks
-ex- is offline   Reply With Quote
Old 26th January 2010, 16:02   #14
DrO
 
Join Date: Sep 2003
Posts: 27,873
code:
LPARAM libhwndipc = -1;
HWND mlplugin = 0;
int use_atf = 0;

HWND GetMLHwnd(HWND parent){
if(IsWindow(mlplugin)){
return mlplugin;
}
else{
if(!libhwndipc){
libhwndipc = (LONG)SendMessage(parent,WM_WA_IPC,WPARAM)"LibraryGetWnd",IPC_REGISTER_WINAMP_IPCMESSAGE);
}
return (mlplugin = (HWND)SendMessage(parent,WM_WA_IPC,-1,(LPARAM)libhwndipc));
}
}

wchar_t* GetFormattedTitleFromWinampW(HWND winamp, void* p){
waFormatTitleExtended fmt_title = {0};
static wchar_t temp[2048];
temp[0] = 0;
fmt_title.out = temp;
fmt_title.out_len = 2048;
fmt_title.filename = (const unsigned short *)(fmt_title.p = p);
SendMessage(winamp,WM_WA_IPC,(WPARAM)&fmt_title,IPC_FORMAT_TITLE_EXTENDED);
return (temp[0]?temp:0);
}

void DoMLSearchQuery(wchar_t* query){
// need to advance one so it won't include the ? that's needed at the front
mlQueryStructW mqs={query,0,};
itemRecordListW *ico = (itemRecordListW*)&mqs.results;

if(SendMessage(GetMLHwnd(plugin.hwndParent),WM_ML_IPC,(WPARAM)&mqs,ML_IPC_DB_RUNQUERYW) == 1){
int i = 0;
// only go into this if we had success
for(i = 0; i < ico->Size; i++){
// don't pass anything in the title to force winamp to get the correct title (is quicker than me reparsing)
enqueueFileWithMetaStructW eFWMS = {ico->Items[i].filename,!use_atf?0:GetFormattedTitleFromWinampW(plugin.hwndParent,ico->Items[i].filename),ico->Items[i].length};
SendMessage(plugin.hwndParent,WM_WA_IPC,(WPARAM)&eFWMS,IPC_ENQUEUEFILEW);
}
}
SendMessage(mlplugin,WM_ML_IPC,(WPARAM)&mqs,ML_IPC_DB_FREEQUERYRESULTSW);
}

that is what i use in my TimeRestore plug-in to do a ml query like filename HAS money to be enqueued into the playlist editor (though that can be changed as required). for using it you can use whatever is defined as valid query syntax in the media library help.

and with querying a directory, if the folder isn't in the media library then you'd need to do your own search mechanism on a folder path (should be a fair few examples of doing this on Windows programming sites).

-daz
DrO is offline   Reply With Quote
Old 27th January 2010, 06:27   #15
-ex-
Junior Member
 
-ex-'s Avatar
 
Join Date: Nov 2009
Location: Malaysia
Posts: 45
Do I need to include anything?
It doesn't work in my set of codes.
Where is the media library help?

I'm so sorry to bother you with loads of questions, I'm really inexperienced in Winamp programming and I reallt need your help.

Thanks a lot..

Last edited by -ex-; 27th January 2010 at 06:44.
-ex- is offline   Reply With Quote
Old 27th January 2010, 09:30   #16
DrO
 
Join Date: Sep 2003
Posts: 27,873
you'd just need to include ml.h but not knowing how you've setup your sdk & plugin instgall i can't say if just adding #include "../gen_ml/ml.h" will be correct or not.

the medis library helps is available via the add view option when right-clicking the local media entry in the media library window and going to the 'advanced' view on the dialog shown.

-daz
DrO is offline   Reply With Quote
Old 27th January 2010, 10:27   #17
-ex-
Junior Member
 
-ex-'s Avatar
 
Join Date: Nov 2009
Location: Malaysia
Posts: 45
I copied "ml.h" into my project folder. I did the same thing with "wa_ipc.h" and it worked fine. I installed the SDK somewhere in my D drive, the same directory where my project folder is.

I got 23 errors. Some of them are about illegal local function definition, undeclared identifier, etc. Is it possible that the code won't work in the Windows Form?
-ex- is offline   Reply With Quote
Old 27th January 2010, 10:35   #18
DrO
 
Join Date: Sep 2003
Posts: 27,873
it's possible though i've never used WinForms so i don't know what sort of conflicts there will be with inserting plain Win32 api calls into it. all i can really suggest is working through the errors one at a time to resolve them or see if there is a WinForms help on integrating non-WinForms code into a project.

-daz
DrO is offline   Reply With Quote
Old 27th January 2010, 10:43   #19
-ex-
Junior Member
 
-ex-'s Avatar
 
Join Date: Nov 2009
Location: Malaysia
Posts: 45
My first type of error is error C2601:
Quote:
'GetMLHwnd' : local function definitions are illegal
'GetFormattedTitleFromWinampW' : local function definitions are illegal
'DoMLSearchQuery' : local function definitions are illegal
How am I suppose to solve those kind of errors? Is it about localization you told me to refer to your language plugin? I don't understand, I don't know how to learn from your codes.

Are there any ways to create an user interface other than using WinForms?
-ex- is offline   Reply With Quote
Old 27th January 2010, 10:55   #20
DrO
 
Join Date: Sep 2003
Posts: 27,873
add the following just below your #include block:
HWND GetMLHwnd(HWND parent);
wchar_t* GetFormattedTitleFromWinampW(HWND winamp, void* p);
void DoMLSearchQuery(wchar_t* query);

however i'm now wondering if your project is set to use ansi or unicode (as the code i pasted is for building in a unicode project).

personally i just code things directly via the Win32 apis as that is what was available when i learnt Windows UI programming in 1999/2000 and have kept on doing that so WinForms is something i'm alien to.

-daz
DrO is offline   Reply With Quote
Old 27th January 2010, 11:08   #21
-ex-
Junior Member
 
-ex-'s Avatar
 
Join Date: Nov 2009
Location: Malaysia
Posts: 45
Quote:
HWND GetMLHwnd(HWND parent);
wchar_t* GetFormattedTitleFromWinampW(HWND winamp, void* p);
void DoMLSearchQuery(wchar_t* query);
It doesn't work, DrO.. I still get the same error messages..

I'm not sure about that, how do I know whether it's set to use ansi or unicode?
-ex- is offline   Reply With Quote
Old 27th January 2010, 11:22   #22
DrO
 
Join Date: Sep 2003
Posts: 27,873
it'd be specified in the project usually as UNICODE in the project's additional definitions (typically in the c/c++ settings with the MS compilers).

upload the project and either post it here or pm me with the link if you don't want other people seeing it and i'll have a look (will save the guesswork on my side). however i'm not going to be able to look into it until tomorrow due to prior commitments.

-daz
DrO is offline   Reply With Quote
Old 27th January 2010, 11:31   #23
-ex-
Junior Member
 
-ex-'s Avatar
 
Join Date: Nov 2009
Location: Malaysia
Posts: 45
Oh it's using Unicode, I've found it.

It's ok, take your time.
I have PMed you the link.
I really thank you for your help.
You are my only reference since I can't find any on the internet.
-ex- is offline   Reply With Quote
Old 30th January 2010, 15:17   #24
-ex-
Junior Member
 
-ex-'s Avatar
 
Join Date: Nov 2009
Location: Malaysia
Posts: 45
Argh I'm sorry for not realizing such things. I should have known where to declare functions and variables. Thank you for correcting it.

However, what is the parameter of the DoMLSearchQuery function? What is wchar_t*? Looks like you pass a string to enqueue songs whose BPM field isn't empty. But it doesn't work. I tried to query songs which contain specific word, it didn't work either.
-ex- is offline   Reply With Quote
Old 2nd February 2010, 10:48   #25
DrO
 
Join Date: Sep 2003
Posts: 27,873
a wchar_t is used with unicode strings (is why the string is L"..." so that it encodes it correctly as a wide string.

as for the query i included in the source back to you, that was just a simple example i used in a media library view so never properly tried it in code (as i wasn't able to get it to compile). so you'll need to find a query which works with the data that you have - would suggest using the query builder under the advanced tab on the add/edit view option as that is what is internally used by the media library views.

is all i can offer helpwise at the moment as i'm between homes and don't have a proper internet connection.

-daz
DrO is offline   Reply With Quote
Old 2nd February 2010, 16:35   #26
-ex-
Junior Member
 
-ex-'s Avatar
 
Join Date: Nov 2009
Location: Malaysia
Posts: 45
I've been trying to get it working by using the query builder. I passed !(bpm isempty), just like your example, but the playlist editor was still empty. Then I tried passing bpm ISNOTEMPTY, but there was still nothing in the playlist editor. But it worked when I used the query to add a smart view. Perhaps, we are missing something?
-ex- is offline   Reply With Quote
Old 3rd February 2010, 09:46   #27
DrO
 
Join Date: Sep 2003
Posts: 27,873
(now i've sort of got internet access again)

best thing to do is check that it is getting results in the DoMLSearchQuery(..) function that it is getting into the for loop and ensuring that ico->Size returns a number matching the number shown in the view. try to work it through that way - i've only included the enqueueing into the playlist as that was how my code was working in another plug-in and as i couldn't build it myself it's possible i've not included/changed something to work correctly in the context of your winforms setup.

-daz
DrO is offline   Reply With Quote
Old 3rd February 2010, 14:10   #28
-ex-
Junior Member
 
-ex-'s Avatar
 
Join Date: Nov 2009
Location: Malaysia
Posts: 45
Yeah, I think the DoMLSearchQuery(..) function isn't working.. The for loop isn't working either, because I tried it directly by commenting the if statement above it..
What does this ico do anyway? And what does ico->Size represent?

Honestly, a lot of variables and functions inside your code that I don't understand.. It makes debugging very hard for me..

And just wondering, where are all the APIs' definitions? How can they work?
-ex- is offline   Reply With Quote
Old 3rd February 2010, 14:34   #29
DrO
 
Join Date: Sep 2003
Posts: 27,873
i'd assumed i guess naively that all of the api usage was going to make sense but i guess not.

all of the media library functions you're using are defined in ml.h (pressing f12 on a defined item should go to the file where it is declared if you're using a msvc compiler).

ico is a pointer to a itemRecordListW structure which itself contains number number of itemRecords found and then a pointer to a list of them to work through (which is what the for loop is going through).

now i'm going to ask a stupid question but what version of Winamp are you using as unicode queries weren't properly added until the 5.3x series (though is safer to be running on a 5.5+ client either way). am asking that as if it's never working then it may be due to the api not being present on the client version you're using.

-daz
DrO is offline   Reply With Quote
Old 3rd February 2010, 14:54   #30
-ex-
Junior Member
 
-ex-'s Avatar
 
Join Date: Nov 2009
Location: Malaysia
Posts: 45
I'm using version 5.56
-ex- is offline   Reply With Quote
Old 3rd February 2010, 20:49   #31
DrO
 
Join Date: Sep 2003
Posts: 27,873
well that rules out that the api not being supported issue so that's something.

i'll sort out a working example plug-in that i know works so that you've got something to directly work against as i think that it going to be quicker to sort out as we're not getting anywhere otherwise with trying to debug this all.

-daz
DrO is offline   Reply With Quote
Old 4th February 2010, 01:20   #32
-ex-
Junior Member
 
-ex-'s Avatar
 
Join Date: Nov 2009
Location: Malaysia
Posts: 45
Yeah it's true, I'm getting nowhere because I don't understand the code well.. I really want to understand it, I wish you are here, so I can ask you to explain it to me line by line.. Thank you!
-ex- is offline   Reply With Quote
Old 6th February 2010, 13:35   #33
-ex-
Junior Member
 
-ex-'s Avatar
 
Join Date: Nov 2009
Location: Malaysia
Posts: 45
Umm, this kinda deviates from the issue, but i kind of want to try an alternative.. Which API should I use to play an existing playlist?
-ex- is offline   Reply With Quote
Old 6th February 2010, 13:40   #34
DrO
 
Join Date: Sep 2003
Posts: 27,873
IPC_ENQUEUEFILE and specifying the full playlist path with the calling of it. with that api, the inprocess (non-WM_COPYDATA version) can be used.

btw, haven't had a chance to sort out a working example yet.

-daz
DrO is offline   Reply With Quote
Old 6th February 2010, 14:13   #35
-ex-
Junior Member
 
-ex-'s Avatar
 
Join Date: Nov 2009
Location: Malaysia
Posts: 45
I created a playlist in the Winamp Library window. Where was it saved? I couldn't find it in the installation directory..
-ex- is offline   Reply With Quote
Old 6th February 2010, 16:26   #36
DrO
 
Join Date: Sep 2003
Posts: 27,873
it generally will be saved into %appdata%\winamp\Plugins\ml with playlists.xml specifying inside it the name of the playlist file against what is shown in the media library tree (allows different playlists to have the same name, etc).

i think there is a proper api to query the filename for getting the path of the playlist (if you know the playlist name as shown in the media library tree). however without checking out source code and what is available in the sdk i'm not too sure if i am correct on this.

am mentioning this as parsing the xml file isn't ideal and it isn't guaranteed that playlists.xml will exist on newer clients - as it all used to be specicifed in gen_ml.ini in earlier 5.x clients for example.

-daz
DrO is offline   Reply With Quote
Old 11th February 2010, 09:41   #37
-ex-
Junior Member
 
-ex-'s Avatar
 
Join Date: Nov 2009
Location: Malaysia
Posts: 45
Quote:
Originally posted by DrO
i think there is a proper api to query the filename for getting the path of the playlist (if you know the playlist name as shown in the media library tree). however without checking out source code and what is available in the sdk i'm not too sure if i am correct on this.

-daz
Is it in wa_ipc.h?

I only found IPC_GETM3UDIRECTORY to return the directory of the playlist file. But then, I don't know what else to do with it.
-ex- is offline   Reply With Quote
Old 22nd February 2010, 03:12   #38
-ex-
Junior Member
 
-ex-'s Avatar
 
Join Date: Nov 2009
Location: Malaysia
Posts: 45
I just found out that the filenames of the playlists and their corresponding names are saved in one .xml file. So what I need to do is read the .xml file, find the filename, and pass it to the function right?
-ex- is offline   Reply With Quote
Old 22nd February 2010, 11:43   #39
DrO
 
Join Date: Sep 2003
Posts: 27,873
the api isn't in wa_ipc.h (is in one of the api_playlist* files but i've really not had a chance to do anything to check that out) but you'd need to use IPC_GETINIDIRECTORY (%inidir%) to get the base of the folder so you can generate %inidir%\plugins\ml\playlists.xml

IPC_GETM3UDIRECTORY is used for a different purpose and returns the path of where winamp.m3u[8] is stored and not those related to the ml_playlist plug-in.

-daz
DrO is offline   Reply With Quote
Old 8th March 2010, 07:44   #40
-ex-
Junior Member
 
-ex-'s Avatar
 
Join Date: Nov 2009
Location: Malaysia
Posts: 45
Since you have not got a change to check the api, can I use XML parsing and query to get the playlist's filename instead?
Do you know how to do that?
-ex- is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > Winamp Development

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump