Old 6th June 2010, 16:20   #1
Stuvning
Junior Member
 
Join Date: May 2010
Posts: 37
Question about timer/thread

I need to check the progress in a song at least every second. What would be the best way to do this? Should I use a timer or maybe a timer in a different thread? Does anyone have a good example of how to implement this in a Winamp plugin?

Thanks in advance!
Stuvning is offline   Reply With Quote
Old 7th June 2010, 07:30   #2
DrO
 
Join Date: Sep 2003
Posts: 27,873
you'd be best subclassing Winamp and looking for the play starting/stopping commands and then doing SetTimer/KillTimer as appropriate but it's better i've found to use the callback feature of the SetTimer api.

though why do you need to poll Winamp as if it's just for played/paused/stopped state then that can all be done via handling callback events via a subclass though i'm guessing it'll be for getting playback position? (have to ask as polling should only be done when there's no other choice).

-daz
DrO is offline   Reply With Quote
Old 7th June 2010, 09:42   #3
Stuvning
Junior Member
 
Join Date: May 2010
Posts: 37
Quote:
Originally Posted by DrO View Post
you'd be best subclassing Winamp and looking for the play starting/stopping commands and then doing SetTimer/KillTimer as appropriate but it's better i've found to use the callback feature of the SetTimer api.

though why do you need to poll Winamp as if it's just for played/paused/stopped state then that can all be done via handling callback events via a subclass though i'm guessing it'll be for getting playback position? (have to ask as polling should only be done when there's no other choice).

-daz
Thanks for the answer!
What I want to do is to have a set of predefined times to pause the playback, for example at: 01:30, 05:00 and so on. When the playback has reached one of these it should pause.
Could you explain a little bit about the subclassing and the polling? I'm not sure what polling entails.
Stuvning is offline   Reply With Quote
Old 8th June 2010, 16:23   #4
DrO
 
Join Date: Sep 2003
Posts: 27,873
polling in this case is just querying Winamp everytime you get a timer event.

i'd suggest having a look at the gen_lang_example which shows how the subclassing of Winamp works (and using the code in that plug-in example ensures compatability across different Winamp clients).

-daz
DrO is offline   Reply With Quote
Old 24th June 2010, 12:11   #5
Stuvning
Junior Member
 
Join Date: May 2010
Posts: 37
I'm trying to get the hang of subclassing. I've been reading this thread:
http://forums.winamp.com/showthread....ighlight=timer
I get two errors when I try this example, guess I haven't declared the variables properly?
Where do I declare them?

PHP Code:
1>.\gen_myplugin.cpp(47) : error C2065'oldSubclass' undeclared identifier
1
>.\gen_myplugin.cpp(47) : error C2065'MySubclass' undeclared identifier 
Stuvning is offline   Reply With Quote
Old 24th June 2010, 14:26   #6
DrO
 
Join Date: Sep 2003
Posts: 27,873
normally they'd need to be declared globally and before they are used. however it's a lot easier to use a working example -> http://nunzioweb.com/daz/gen_lang_example/ (and that also makes sure that if you do subclassing it will be compatible with 5.34+ clients and higher.

-daz
DrO is offline   Reply With Quote
Old 29th August 2010, 16:28   #7
vroo
Junior Member
 
Join Date: Aug 2010
Posts: 1
I tried to build this code, but it makes winamp crash

http://forums.winamp.com/showthread....ighlight=timer

code:

WNDPROC oldWinampProc=NULL;
WNDPROC oldSubclass=NULL;
LRESULT MySubclass(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
return CallWindowProc(oldWinampProc,hwnd,uMsg,wParam,lParam);
}
int init() {
oldSubclass = (WNDPROC)SetWindowLong(plugin.hwndParent, GWL_WNDPROC, (LONG)MySubclass);
return 0;
}



what is wrong?
vroo is offline   Reply With Quote
Old 29th August 2010, 16:54   #8
DrO
 
Join Date: Sep 2003
Posts: 27,873
you're using oldWinampProc when you should be using oldSubclass.

also you're not doing it in a unicode compatible way, have a look at how it's done in http://nunzioweb.com/daz/gen_lang_example/ so you don't cause people to have to install http://nunzioweb.com/daz/unicodetaskbarfix/

-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