![]() |
#1 |
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! |
![]() |
![]() |
![]() |
#2 |
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 |
![]() |
![]() |
![]() |
#3 | |
Junior Member
Join Date: May 2010
Posts: 37
|
Quote:
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. |
|
![]() |
![]() |
![]() |
#4 |
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 |
![]() |
![]() |
![]() |
#5 |
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:
|
![]() |
![]() |
![]() |
#6 |
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 |
![]() |
![]() |
![]() |
#7 |
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: what is wrong? |
![]() |
![]() |
![]() |
#8 |
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 |
![]() |
![]() |
![]() |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|