Old 2nd October 2009, 14:39   #1
rryk
Junior Member
 
Join Date: Oct 2009
Posts: 2
Playlist randomization

I would like to write a plugin to randomize playlist on load.

After some research online and through code of the Winamp API, I used code snippet to redefine WinProc function and was able to log all messages received by Winamp.

I found out, that IPC_PLAYLIST_MODIFIED is received whenever the playlist changes. I use this message to randomize list after adding files/directories to playlist. However Winamp receives this message for every item in the folder being added. Since I want to randomize only once after all elements are added - I wait for the last message. To find this last message I use timer and wait for 2 more seconds after each message. If no more messages come up - I consider the latter to be the trigger. Is there any better way to find out that whole directory was added?

I also want to randomize after Winamp load, but no IPC_PLAYLIST_MODIFIED. Therefore I wait for IPC_CB_OUTPUTCHANGED and then do the randomization. I also set up flag, so I won't react on similar message more then once. I decided to use this message since it was the last message in the log of Winamp message after startup and before it started to play first song. Is there are a better way to find out when Winamp is fully loaded?

Finally, as these two occasions I need to randomize list. I found playlist and plLoadEx folders in API. There is a class api_playlistmanager, which allows to randomize a list, however it requires a pointer to ifc_playlist. I couldn't find neither the class definition nor the way to get this pointer. Please advise...
rryk is offline   Reply With Quote
Old 3rd October 2009, 08:06   #2
DrO
 
Join Date: Sep 2003
Posts: 27,873
the api_playlistmanager/ifc_playlist stuff isn't used for the main playlist editor (as you appear to be working on). they're more aimed at playlist handling in the media library though i think they can be applied to arbitary playlists but that then requires you to save the current winamp playlist/manipulate winamp.m3u(8) and then re-load that back into the player.

for doing a randomise on load, you'd be best subclassing the winamp hwnd and then doing a PostMessage(..) of a custom message (ideally using IPC_REGISTER_WINAMP_IPCMESSAGE to generate that) and then when you receive that it is likely that Winamp should have loaded fully (or at least as much as is needed to have the playlist fully loaded). then you can randomise the playlist.

now for the randomising of the playlist you could use Winamp's standard randomise playlist action which can be initiated by sending the randomise playlist menu id to the playlist editor window (the hwnd for that can be accessed via IPC_GETWND) as a WM_COMMAND message in the PostMessage(..) handler mentioned above.

-daz
DrO is offline   Reply With Quote
Old 3rd October 2009, 13:59   #3
rryk
Junior Member
 
Join Date: Oct 2009
Posts: 2
Thanks a lot. I managed to register the message, post and receive it back after loading. I also managed to get playlist window handle. The only thing I am still missing is "Randomize playlist" menu option id.

PostMessage((IntPtr)hWnd, WM_COMMAND, 0, ID_MENU_ITEM);

How do I get ID_MENU_ITEM?

Update: I subclassed playlist window and experimentally found out that correct id for randomization menu item is 40212. Thank you. Now it works.

Last edited by rryk; 3rd October 2009 at 14:20.
rryk is offline   Reply With Quote
Old 21st July 2010, 21:27   #4
eo.rojas
Junior Member
 
Join Date: Jul 2010
Posts: 5
Any chance you can point me at same code you found. I'm looking to create a playlist change notifier.
eo.rojas 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