Playlist randomization

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • rryk
    Junior Member
    • Oct 2009
    • 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...
  • DrO
    • Sep 2003
    • 27868

    #2
    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
    WACUP Project <‖> "Winamp Ramblings" - Indie Winamp Dev Blog

    Comment

    • rryk
      Junior Member
      • Oct 2009
      • 2

      #3
      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; 3 October 2009, 14:20.

      Comment

      • eo.rojas
        Junior Member
        • Jul 2010
        • 5

        #4
        Any chance you can point me at same code you found. I'm looking to create a playlist change notifier.

        Comment

        Working...
        X