Old 30th March 2001, 17:51   #1
chinyue
Junior Member
 
Join Date: Mar 2001
Location: Kaohsiung, Taiwan
Posts: 2
Send a message via ICQ to chinyue
I'm writing a plug-in, and try to do some actions when Winamp starts playing a file.
Is there any way to know that Winamp is starting to play a new file?
chinyue is offline   Reply With Quote
Old 30th March 2001, 19:49   #2
Sawg
Guest
 
Posts: n/a
you check here?
http://www.winamp.com/nsdn/winamp2x/dev/sdk/api.jhtml
  Reply With Quote
Old 10th April 2001, 18:33   #3
schweitn
Winamp3 Component Guuuru
Beta Team
 
schweitn's Avatar
 
Join Date: Dec 2000
Location: Milwaukee, WI
Posts: 1,068
Send a message via AIM to schweitn Send a message via Yahoo to schweitn
Although you can capture when someone hits play, stop, etc. Those functions won't tell you when the next song starts playing in a playlist...

I am writing a plugin that needs that ability, so I simply set a windows timer, and then poll Winamp for what the current song is and whether winamp is currently playing. If the song changed from the last time I did it - then I perform my action.

Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.
- Albert Einstein

Winamp 3 Projects | Winamp 2x Plugin Manager | Explorer Playlist | FileSystem Object | Shoutcast List | Sashimi
schweitn is offline   Reply With Quote
Old 10th April 2001, 19:40   #4
Abraxa
Senior Member
 
Join Date: Nov 2000
Location: germany
Posts: 201
If you hook into winamp's wndProc() and catch the WM_USER+2 message then the input plugin tells winamp that the data stream has ended. After ~50ms winamp's internal buffer is then empty, too, and it will go on with the next file (if any).

So you can catch the 'stream has ended' notification, wait about 50ms and if winamp is playing after the timer fired you know that winamp is playing the next track.

Regards,
-Søren
Abraxa is offline   Reply With Quote
Old 10th April 2001, 19:54   #5
schweitn
Winamp3 Component Guuuru
Beta Team
 
schweitn's Avatar
 
Join Date: Dec 2000
Location: Milwaukee, WI
Posts: 1,068
Send a message via AIM to schweitn Send a message via Yahoo to schweitn
But then how do you capture when someone double clicks on a song in the playlist...

That does not send a Play Event the same way as hitting the Play button.

Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.
- Albert Einstein

Winamp 3 Projects | Winamp 2x Plugin Manager | Explorer Playlist | FileSystem Object | Shoutcast List | Sashimi
schweitn is offline   Reply With Quote
Old 10th April 2001, 20:08   #6
Abraxa
Senior Member
 
Join Date: Nov 2000
Location: germany
Posts: 201
Well... then capture the WM_SETTEXT message, since winamp sets its text when a new song is played.

...BUT...

If 'scroll song title in taskbar' is enabled then the message will be sent a couple of times every second. That's not the problem - the problem is that each time the window caption is different
So you can't make a simple string comparion to see whether there is a new title being played...

Regards,
-Søren

PS: I just noticed that the playlist editor notifies winamp when the user wants to play a track using the WM_USER message with wParam being 0x0000029A and lParam containing the ID the track has in the playlist. I think that if you catch the [WM_USER+2 (track ends)], [WM_USER & wParam = 0x29A (new song from playlist)] and [WM_COMMAND & wParam = 40045 (user starts playing by clicking on the PLAY button or pressing the X key)] messages you don't miss any song changes.

[Edited by Abraxa on 04-10-2001 at 04:24 PM]
Abraxa is offline   Reply With Quote
Old 10th April 2001, 20:41   #7
schweitn
Winamp3 Component Guuuru
Beta Team
 
schweitn's Avatar
 
Join Date: Dec 2000
Location: Milwaukee, WI
Posts: 1,068
Send a message via AIM to schweitn Send a message via Yahoo to schweitn
Excellent - Thanks a lot.

I'll give that a shot, I'd rather not suck time away from winamp with a timer going off every 1/4 second...

Not to mention the fact that when I query Winamp for bitrate/sample rate info of the current track, it doesn't always return valid data when I do it based off of a timer. Maybe Winamp will be more ready if I do this.

Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.
- Albert Einstein

Winamp 3 Projects | Winamp 2x Plugin Manager | Explorer Playlist | FileSystem Object | Shoutcast List | Sashimi
schweitn is offline   Reply With Quote
Old 10th April 2001, 22:28   #8
A Plugin Developer
Senior Member
 
A Plugin Developer's Avatar
 
Join Date: Jun 2000
Location: Home
Posts: 269
Quote:
Originally posted by Abraxa
PS: I just noticed that the playlist editor notifies winamp when the user wants to play a track using the WM_USER message with wParam being 0x0000029A and lParam containing the ID the track has in the playlist. I think that if you catch the [WM_USER+2 (track ends)], [WM_USER & wParam = 0x29A (new song from playlist)] and [WM_COMMAND & wParam = 40045 (user starts playing by clicking on the PLAY button or pressing the X key)] messages you don't miss any song changes.
[Edited by Abraxa on 04-10-2001 at 04:24 PM]
Abraxa almost had it... it's just a little simpler than what he described. All you need to do is follow Abraxa's first piece of advice: subclass the playlist editor and catch WM_USER messages with wParam=666. This catches ALL song changes (x key, pressing play, clicking a new song, even dragging a file over winamp). What kind of plugin are you peeps making anyway? Good luck with whatever it is...
A Plugin Developer is offline   Reply With Quote
Old 11th April 2001, 03:23   #9
schweitn
Winamp3 Component Guuuru
Beta Team
 
schweitn's Avatar
 
Join Date: Dec 2000
Location: Milwaukee, WI
Posts: 1,068
Send a message via AIM to schweitn Send a message via Yahoo to schweitn
Even Better! I'll give that a try later...

As far as what I'm writing, its no big deal. Its an IRC notification plugin. Yes, I know there are a dozen of em - but they're all for mIRC and I use dIRC. So I'm writing one that connects to dIRC as a COM server and is very customizable.

Thanks for the help.

Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.
- Albert Einstein

Winamp 3 Projects | Winamp 2x Plugin Manager | Explorer Playlist | FileSystem Object | Shoutcast List | Sashimi
schweitn is offline   Reply With Quote
Old 17th April 2001, 09:04   #10
]mAdMaTt[
Junior Member
 
Join Date: Apr 2001
Posts: 9
Send a message via ICQ to ]mAdMaTt[
Where do you catch Winamp event ?

hi everyone

i'm writing a very simple plugin which has only one purpose for now: sending the name of the song playing to another program.
It's working now with a function like this:

DWORD WINAPI ThreadProc(LPVOID lpParameter) {
char* title;
while (1) {
getSongName(title);
sendSongName(title);
Sleep(1000);
}

return 0;
}

I don't like this solution and I'd prefer the one with Winamp events, but I can't find where do you catch them...

thanks in advance
]mAdMaTt[ is offline   Reply With Quote
Old 17th April 2001, 17:23   #11
Abraxa
Senior Member
 
Join Date: Nov 2000
Location: germany
Posts: 201
Check this out: http://www1.inetmail.de/Bitfummler/gen_skeleton.zip

This small example just hooks itself into winamp's WndProc. So in order to catch some of the messages winamp receives, just place an appropriate switch()-instruction into the WndProc() function.

Regards,
-Søren
Abraxa is offline   Reply With Quote
Old 17th April 2001, 22:54   #12
]mAdMaTt[
Junior Member
 
Join Date: Apr 2001
Posts: 9
Send a message via ICQ to ]mAdMaTt[
thanks again for your help my plugin is now working just fine.

I use this method to detect a song change:

code:
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
if(message == WM_SETTEXT)
if(SendMessage(plugin.hwndParent,WM_WA_IPC,0,IPC_ISPLAYING) == 1 || SendMessage(plugin.hwndParent,WM_WA_IPC,0,IPC_ISPLAYING) == 3)
sendSongName();

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



but i'm curious and i like to see how your method works...
Quote:
subclass the playlist editor and catch WM_USER messages with wParam=666. This catches ALL song changes (x key, pressing play, clicking a new song, even dragging a file over winamp)
how do you do this ?
]mAdMaTt[ is offline   Reply With Quote
Old 18th April 2001, 11:55   #13
Abraxa
Senior Member
 
Join Date: Nov 2000
Location: germany
Posts: 201
I would have posted the code here, but as this board's CODE tag sucks ass I put it here: http://www1.inetmail.de/Bitfummler/wParam666Example.c

The code should be quite clear

Regards,
-Søren
Abraxa is offline   Reply With Quote
Old 18th April 2001, 13:08   #14
schweitn
Winamp3 Component Guuuru
Beta Team
 
schweitn's Avatar
 
Join Date: Dec 2000
Location: Milwaukee, WI
Posts: 1,068
Send a message via AIM to schweitn Send a message via Yahoo to schweitn
However...

It looks as if WM_USER with a wParam == 666 can be sent more then once during a song change.

So you might want to keep track of which song is currently playing, and then compare the one that is playing when the message is sent to make sure it isn't the same.

Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.
- Albert Einstein

Winamp 3 Projects | Winamp 2x Plugin Manager | Explorer Playlist | FileSystem Object | Shoutcast List | Sashimi
schweitn is offline   Reply With Quote
Old 18th April 2001, 13:36   #15
Abraxa
Senior Member
 
Join Date: Nov 2000
Location: germany
Posts: 201
Yes, I've also noticed this...

One thing I forgot to mention in my last msg:
It's better to use CallWindowProc() then using SendMessage() if you want to send messages to the window you hooked into - especially if you hook into winamp where you will send many messages to.

Regards,
-Søren
Abraxa is offline   Reply With Quote
Old 18th April 2001, 14:29   #16
]mAdMaTt[
Junior Member
 
Join Date: Apr 2001
Posts: 9
Send a message via ICQ to ]mAdMaTt[
great
thanks, now i think i understand how all this is working.
]mAdMaTt[ is offline   Reply With Quote
Old 18th April 2001, 14:39   #17
]mAdMaTt[
Junior Member
 
Join Date: Apr 2001
Posts: 9
Send a message via ICQ to ]mAdMaTt[
CallWindowProc() ?

by using callwindowproc you're sure that the message you send will not be catch by the function i use to intercept winamp message ?? i'm not sure about it
]mAdMaTt[ is offline   Reply With Quote
Old 18th April 2001, 15:56   #18
Abraxa
Senior Member
 
Join Date: Nov 2000
Location: germany
Posts: 201
Well... it's exactly the other way round

So you now found out yourself why I suggest you to use CallWindowProc(), otherways you might run into problems with SendMessage() calling your own customized WndProc()

Regards,
-Søren
Abraxa is offline   Reply With Quote
Old 19th April 2001, 15:08   #19
]mAdMaTt[
Junior Member
 
Join Date: Apr 2001
Posts: 9
Send a message via ICQ to ]mAdMaTt[
thanks for all your advices Abraxa.

i went to your page with yume and i'm very interested in your project as i also have a project to do for my school which is to connect a lcd display (it's a varitronix too )to a parallel port in order to monitor programs running and system resources. that's why i needed to build this winamp plugin to get info about the song to display them...

thanks again
]mAdMaTt[ is offline   Reply With Quote
Old 19th April 2001, 15:27   #20
Abraxa
Senior Member
 
Join Date: Nov 2000
Location: germany
Posts: 201
Cool thing!
I wish I would have had the chance to do such projects for school...

Good luck!

Regards,
-Søren

PS: what resolution does your LCD have? Just being curious, you know
Abraxa is offline   Reply With Quote
Old 19th April 2001, 15:35   #21
]mAdMaTt[
Junior Member
 
Join Date: Apr 2001
Posts: 9
Send a message via ICQ to ]mAdMaTt[
i'm not sure of the exact model of the lcd as it's one of my friend who got it in an electronic shop where the shopkeeper gave him this screen i think it's a 128x128... i'll tell you exactly next week if you want
]mAdMaTt[ is offline   Reply With Quote
Old 19th April 2001, 15:54   #22
Abraxa
Senior Member
 
Join Date: Nov 2000
Location: germany
Posts: 201
Yeah, would be cool

Regards,
-Søren
Abraxa is offline   Reply With Quote
Old 31st March 2002, 08:05   #23
wa21guy
Member
 
Join Date: Nov 2000
Location: Seattle, WA USA area
Posts: 87
Send a message via AIM to wa21guy Send a message via Yahoo to wa21guy
Hi all. Great topic about the timer. I dont know C or C++ at all, so I don't understand a whole lot about whats going on. What I do know is Visual Basic 6 and I have almost completed my plug-in with it. Unfortunately for me, a timer is just too much of a hog on resources in VB6 and if I run it every second, sometimes the song skips the first second when I have to stop and restart due to an ID3 tag change.

Anyway, is there anyway you could port over a function that does the above for VB6? I'd like to have something like this:

Private Sub Winamp_SongChanged()
...do whatever
End Sub

I would be forever greatful.

Ethan
wa21guy is offline   Reply With Quote
Old 14th October 2009, 18:20   #24
AndreTheDark
Junior Member
 
Join Date: Oct 2009
Location: Netherlands
Posts: 1
pauze event?

@wa21guy: I do now know any VB, but as far as I know, it's possible to use windows api functions from VB6, so it should be possible.

But I have another question. I have hooked the windows, and I can see the 0x29A(666) messages when a song starts or stops playing.

But when I pause the song, there is no message. Can I catch the pause event somehow. I would like to detect when the users pauses the playback. (without constant polling)
AndreTheDark is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Winamp > Winamp Technical Support

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