Valhalla Legends Forums Archive | Visual Basic Programming | winamp play wildcard

AuthorMessageTime
Tass
Like stealthbot has the /play * command, how did he do that?
November 27, 2005, 2:34 AM
LivedKrad
I'm pretty sure he used some sort of API to remotely control or manipulate a Winamp instance (maybe in the older versions?). I'm not sure about the new Stealthbot, does it still open up Winamp to play the songs or do the songs play on their own? If the latter, then an API would still be used to play the external file. I believe to manipulate Winamp there is some sort of developer SDK though.
November 27, 2005, 3:33 AM
rabbit
I'm not sure how it's done in StealthBot, but I tell Winamp to open the "jump to file" window, and then I grab the handle of the listbox, the textbox, and the enter button.  I tell the textbox to contain the text I want (IE: the song's name), and check to make sure there is something in the listbox, and if so, I "use" the enter button.
November 27, 2005, 5:49 AM
l2k-Shadow
You can also open up the playlist file inside the winamp folder, parse it, and figure out which position in the playlist is the song you want it to play. Then you just set the winamp playlist to that position and play. The tricky part about doing this though is that the playlist saves in the file after you exit winamp out... So if you make a new playlist while winamp is running and then try to use this method it will not work and you will probably need to use some memory reading API to get the song names, however, once you exit winamp the method should work.
November 27, 2005, 8:17 AM
Tass
Rabbit, know where I can get a good api. I can't find any with this..
November 27, 2005, 4:34 PM
shadypalm88
[quote author=l2k-Shadow link=topic=13353.msg135459#msg135459 date=1133079420]
You can also open up the playlist file inside the winamp folder, parse it, and figure out which position in the playlist is the song you want it to play. Then you just set the winamp playlist to that position and play.[/quote]Yep, that's how I do it, anyway.  Just a reminder, when you read it in VB, make sure you use Line Input #n, SomeStringVar instead of Input #n, SomeStringVar.

[quote author=Tass link=topic=13353.msg135481#msg135481 date=1133109287]
Rabbit, know where I can get a good api. I can't find any with this..
[/quote]Go to the NSDN website and download the SDK.  The definitions for the Windows messages that you can send to Winamp to get information or to make it do things are in winamp/wa_ipc.h inside that archive.  Declare the SendMessage function in VB, define some constants if you want and go.

In order to send the messages to Winamp you first need to acquire its window handle (HWND).  If you only want to support Winamp 2.x, you can just use FindWindow to search for "Winamp 1.x" (literally an 'x' character there).  If you want Winamp 5 support, you'll need to use EnumWindows and scan for it, because the window title in 5 is either "Winamp 5.##" when there's nothing playing or loaded, or "#. Artist - Title - Winamp" when there is.
November 27, 2005, 5:10 PM
rabbit
[quote author=l2k-Shadow link=topic=13353.msg135459#msg135459 date=1133079420]
You can also open up the playlist file inside the winamp folder, parse it, and figure out which position in the playlist is the song you want it to play. Then you just set the winamp playlist to that position and play. The tricky part about doing this though is that the playlist saves in the file after you exit winamp out... So if you make a new playlist while winamp is running and then try to use this method it will not work and you will probably need to use some memory reading API to get the song names, however, once you exit winamp the method should work.
[/quote]I did that with RaBBiTBot (the source is around), and it really....really didn't work/was fugly.
November 27, 2005, 6:42 PM
LivedKrad
[quote author=shadypalm88 link=topic=13353.msg135484#msg135484 date=1133111420]
[quote author=l2k-Shadow link=topic=13353.msg135459#msg135459 date=1133079420]
You can also open up the playlist file inside the winamp folder, parse it, and figure out which position in the playlist is the song you want it to play. Then you just set the winamp playlist to that position and play.[/quote]Yep, that's how I do it, anyway.  Just a reminder, when you read it in VB, make sure you use Line Input #n, SomeStringVar instead of Input #n, SomeStringVar.

[quote author=Tass link=topic=13353.msg135481#msg135481 date=1133109287]
Rabbit, know where I can get a good api. I can't find any with this..
[/quote]Go to the NSDN website and download the SDK.  The definitions for the Windows messages that you can send to Winamp to get information or to make it do things are in winamp/wa_ipc.h inside that archive.  Declare the SendMessage function in VB, define some constants if you want and go.

In order to send the messages to Winamp you first need to acquire its window handle (HWND).  If you only want to support Winamp 2.x, you can just use FindWindow to search for "Winamp 1.x" (literally an 'x' character there).  If you want Winamp 5 support, you'll need to use EnumWindows and scan for it, because the window title in 5 is either "Winamp 5.##" when there's nothing playing or loaded, or "#. Artist - Title - Winamp" when there is.
[/quote]

I so already suggested the SDK. Is it common procedure to post massive information (which is very helpful as always, Eric) and the corresponding links now? I'm behind the times.
November 28, 2005, 11:48 PM
Topaz
Does the SDK include information on how to load a playlist?
November 28, 2005, 11:58 PM
JoeTheOdd
I doubt it, but seeing as how the Winamp Library is a M3U (it is, right?), I'm sure that format is highly documented, and you should be able to figure it out extremely easy.

I looked into the StealthBot source code (the released version, I have no way of viewing the current SB code, don't ask me for it =p), and the play function only sent the command to winamp to begin the playing of the last MP3 to be selected. Playing specific tracks (even by number) wasn't implemented until later.
November 29, 2005, 12:39 AM
rabbit
Winamp can handle M3U and PLS, and another (I think).
November 29, 2005, 1:27 AM
l2k-Shadow
[quote author=rabbit link=topic=13353.msg135489#msg135489 date=1133116925]
[quote author=l2k-Shadow link=topic=13353.msg135459#msg135459 date=1133079420]
You can also open up the playlist file inside the winamp folder, parse it, and figure out which position in the playlist is the song you want it to play. Then you just set the winamp playlist to that position and play. The tricky part about doing this though is that the playlist saves in the file after you exit winamp out... So if you make a new playlist while winamp is running and then try to use this method it will not work and you will probably need to use some memory reading API to get the song names, however, once you exit winamp the method should work.
[/quote]I did that with RaBBiTBot (the source is around), and it really....really didn't work/was fugly.
[/quote]

Then your parsing was incorrect. Mine works flawlessly with the exception, like i already said, of not being able to parse the current playlist if you make it while winamp is running.
November 29, 2005, 2:27 AM
rabbit
Well, you failed.  There is an API to save the playlist to a specific file (defaults to X:\installpath\Winamp.pls, but can be changed with another API), so that you can parse it.
November 29, 2005, 2:55 AM
l2k-Shadow
I'm sure there is, I didn't really spend too much time with this...
November 29, 2005, 5:36 AM
PaiD
Also on the SDK there are a few api calls that are only accessible to plugins. They include some APIs like getting the title and the path of the playing file. To get access to these APIs you need to get into the memory of Winamp (Worth it :p)
November 29, 2005, 6:43 PM
Stealth
[quote author=shadypalm88 link=topic=13353.msg135484#msg135484 date=1133111420]
[quote author=l2k-Shadow link=topic=13353.msg135459#msg135459 date=1133079420]
You can also open up the playlist file inside the winamp folder, parse it, and figure out which position in the playlist is the song you want it to play. Then you just set the winamp playlist to that position and play.[/quote]Yep, that's how I do it, anyway.  Just a reminder, when you read it in VB, make sure you use Line Input #n, SomeStringVar instead of Input #n, SomeStringVar.

[quote author=Tass link=topic=13353.msg135481#msg135481 date=1133109287]
Rabbit, know where I can get a good api. I can't find any with this..
[/quote]Go to the NSDN website and download the SDK.  The definitions for the Windows messages that you can send to Winamp to get information or to make it do things are in winamp/wa_ipc.h inside that archive.  Declare the SendMessage function in VB, define some constants if you want and go.

In order to send the messages to Winamp you first need to acquire its window handle (HWND).  If you only want to support Winamp 2.x, you can just use FindWindow to search for "Winamp 1.x" (literally an 'x' character there).  If you want Winamp 5 support, you'll need to use EnumWindows and scan for it, because the window title in 5 is either "Winamp 5.##" when there's nothing playing or loaded, or "#. Artist - Title - Winamp" when there is.
[/quote]

Rabbit, that's exactly what happens.

Shady, as far as I can remember, I didn't have to make any code changes to support Winamp 5. The Winamp5 parent window class name remains "Winamp 1.x" -- for third-party compatibilty, apparently.
November 29, 2005, 8:43 PM

Search