Old 2nd December 2010, 10:56   #1
Stuvning
Junior Member
 
Join Date: May 2010
Posts: 37
Using IPC_SETPLAYLISTPOS

Hey again!
I need some help using "IPC_SETPLAYLISTPOS". I want to set the playlist position to 2 for example and then play that song. Right now I'm trying to it this way:

Step 1. Pause the current song with WM_Command 40046 (pause/unpause)

Step 2. set the playlist position using
SendMessage(plugin.hwndParent,WM_WA_IPC,2,IPC_SETPLAYLISTPOS);

Step 3. Here I want to start playing the song that has position 2.

Any hints?
Stuvning is offline   Reply With Quote
Old 2nd December 2010, 11:26   #2
DrO
 
Join Date: Sep 2003
Posts: 27,873
Quote:
#define IPC_SETPLAYLISTPOS 121
/* (requires Winamp 2.0+)
** SendMessage(hwnd_winamp,WM_WA_IPC,position,IPC_SETPLAYLISTPOS)
** IPC_SETPLAYLISTPOS sets the playlist position to the specified 'position'.
** It will not change playback status or anything else. It will just set the current
** position in the playlist and will update the playlist view if necessary.
**
** If you use SendMessage(hwnd_winamp,WM_COMMAND,MAKEWPARAM(WINAMP_BUTTON2,0),0);
** after using IPC_SETPLAYLISTPOS then Winamp will start playing the file at 'position'.
*/
so there isn't a need to pause the current song and will act the equivalent of clicking on the item in the playlist editor normally.

-daz
DrO is offline   Reply With Quote
Old 2nd December 2010, 11:38   #3
Stuvning
Junior Member
 
Join Date: May 2010
Posts: 37
Thanks! I totally missed that about SETPLAYLISTPOS. But I keep getting "undeclared identifier" when trying to use "WINAMP_BUTTON2" for some reason.
Stuvning is offline   Reply With Quote
Old 2nd December 2010, 12:03   #4
DrO
 
Join Date: Sep 2003
Posts: 27,873
WINAMP_BUTTON2 should be defined in wa_msgids.h (was in an unofficial sdk i did and is something that is otherwise defined in the internal Winamp code). http://nunzioweb.com/daz/winamp/sdk/winamp/wa_msgids.h should be what you want.

-daz
DrO is offline   Reply With Quote
Old 2nd December 2010, 15:50   #5
Stuvning
Junior Member
 
Join Date: May 2010
Posts: 37
Further problems, just using SETPLAYLISTPOS and WINAMP_BUTTON2 the following code is stuck on the first song in the playlist. It should progress to the next song in the playlist but it doesn't.

PHP Code:
for(int i=0;i<sizeof(marker)/sizeof(int);i++) {
                if (
pos == marker[i]/*marker is an array of ints/) {        

                                    SendMessage(plugin.hwndParent,WM_WA_IPC,i,IPC_SETPLAYLISTPOS);
                                    SendMessage(plugin.hwndParent,WM_COMMAND,MAKEWPARAM(WINAMP_BUTTON2,0),0);



                                    }
                                    } 
"pos" refers to a timer, so if the first value in "marker" is 5 the code above should run after 5 seconds and so on.
Stuvning is offline   Reply With Quote
Old 2nd December 2010, 16:00   #6
DrO
 
Join Date: Sep 2003
Posts: 27,873
what do you mean by 'stuck' ? do you mean it only ever plays the first playlist item or is it causing Winamp to lock up.

not too sure about the code you posted and the mention of the timer stuff and sounds more like the logic for calling the action is wrong. what is it you're actually trying to achieve?

-daz
DrO is offline   Reply With Quote
Old 2nd December 2010, 16:48   #7
Stuvning
Junior Member
 
Join Date: May 2010
Posts: 37
It only plays the first song in the playlist. I want to skip to the next song after a set amount of time, these times are stored in the array
Stuvning is offline   Reply With Quote
Old 2nd December 2010, 18:25   #8
DrO
 
Join Date: Sep 2003
Posts: 27,873
well there has to be an issue with the indexing that you're trying to do. best to see if your code is actually working in the way expected which i don't think it will ever do as your pos is probably matching the first result in marker[] everytime the loop is run, causing the first item to play.

wouldn't it be better to just use a fixed timer via the SetTimer(..) and when the event for that happens then just get the current playlist position, increment that value and then use the IPC_SETPLAYLISTPOS part (you'd also need to remember to deal with getting to the end of the playlist and possibly looping back to the start if desired otherwise it'll just keep playing the last item i think).

-daz
DrO is offline   Reply With Quote
Old 2nd December 2010, 20:14   #9
Stuvning
Junior Member
 
Join Date: May 2010
Posts: 37
That sounds like a good idea but I haven't been able to implement a proper timer. Right now I'm doing it this way which is obviously a bad idea. How would I go about doing it the proper way?
PHP Code:
// Global Variable that keeps original window procedure for Winamp.
WNDPROC lpWndProcOld NULL


LRESULT CALLBACK MainWndProc(HWND hwndUINT messageWPARAM wParamLPARAM lParam)
{

    
int pos;
    
int marker [5]= { 510101520 };


    if (
message==WM_TIMER)
    {
        
int playstatus SendMessage(hwnd,WM_WA_IPC,0,IPC_ISPLAYING);

        if(
playstatus==1){    

            
int length SendMessage(hwnd,WM_WA_IPC,0,IPC_GETLISTLENGTH);


            
pos=SendMessage(plugin.hwndParentWM_WA_IPC0IPC_GETOUTPUTTIME)/1000;
            

            for(
int i=0;i<sizeof(marker)/sizeof(int);i++) {
                if (
pos == marker[i]) {

                
                    
SendMessage(plugin.hwndParent,WM_WA_IPC,i,IPC_SETPLAYLISTPOS);
                    
SendMessage(plugin.hwndParent,WM_COMMAND,MAKEWPARAM(WINAMP_BUTTON2,0),0); 

                }
            }

        }

    }
    return 
CallWindowProc(lpWndProcOld,hwnd,message,wParam,lParam);

Stuvning is offline   Reply With Quote
Old 2nd December 2010, 20:29   #10
DrO
 
Join Date: Sep 2003
Posts: 27,873
first issue is that you're just responding to the WM_TIMER message without respecting the timer id i.e. you're just running on any call which is a bad thing to do (as some of the Winamp timers run on a small time delta which would make the cpu usgae increase a lot more than it should). you can still do it like you are but you'd need to make sure that you're using the timer id specified in the SetTimer(..) call.

i'd use SetTimer(..) with a 5000ms delay (assuming you want a 5 second delay) and set it to have a callback function so you know that it should just be for the event you've setup instead of any WM_TIMER action.

and then in the timer callback, just use the IPC_SETPLAYLISTPOS and WINAMP_BUTTON2 after using IPC_GETLISTPOS to get the current position or whatever item it is that you want to play next.

-daz
DrO is offline   Reply With Quote
Old 2nd December 2010, 21:16   #11
Stuvning
Junior Member
 
Join Date: May 2010
Posts: 37
OK! I think it's starting to get trough So first I need to set up the timer something akin to this:
PHP Code:
uResult SetTimer(hwnd,             // handle to main window 
    
IDT_MOUSETRAP,                   // timer identifier 
    
10000,                           // 10-second interval 
    
(TIMERPROCNULL);               // no timer callback 
And then I need a callback to do what I want (changing playlist position and so on)?
Stuvning is offline   Reply With Quote
Old 2nd December 2010, 21:24   #12
DrO
 
Join Date: Sep 2003
Posts: 27,873
yeah by setting a valid callback in the 4th param (the TIMERPROC), that would make it easier for you to have a timed event happening without having it interfere with other timers (the callback method also happens closer to the scheduled time delta than the message version i found in some setups).

-daz
DrO is offline   Reply With Quote
Old 2nd December 2010, 21:56   #13
Stuvning
Junior Member
 
Join Date: May 2010
Posts: 37
I figured out that the identifier just needed to be defined. And the timer works now! But I need it to correspond to the position in the song. So when 5 seconds has passed in the song it should skip to the next song. As it is now the song skips every 5 seconds regardless.
Stuvning is offline   Reply With Quote
Old 2nd December 2010, 22:14   #14
DrO
 
Join Date: Sep 2003
Posts: 27,873
whatever is said on msdn help page for it.

-daz
DrO 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