Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: identifying FB2K multiple instances (Read 9176 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

identifying FB2K multiple instances

FB2K developers,

I want to run multiple instances of FB2K (via installations in separate directories) which are each bound to separate soundcards. I have a .NET application working for winamp which will play selected songs on specific winamp instances by changing the classname for each winamp instance via command line. I want to do the same thing with foobar - had a quick look in the SDK & various addons and it is not obvious how to:

- start multiple versions of FB2K with different classnames (or if there is any way to easily identify multiple Fb2K instances programmatically).

- Add a file to the playlist programmatically (I dont want to shell out to run the Fb2K command line) for a specific instance

- Clear the playlist for a specific instance.

Note I have some c++ experience but am not expert (or this would be easier). Appreciate any pointers or code samples to get me started. I am keen to replace winamp 

Regards,
Dean

identifying FB2K multiple instances

Reply #1
Easier than you might think. You can launch the appropriate executable with parameters to control it. /help will show you a partial list, but there are also a few undocumented commands:

"/command:blah"

"/playlist_command:blah"

"/playlist:blah"

identifying FB2K multiple instances

Reply #2
Thanks for the feedback.

Any chance of doing this programatically without having to shell out to run the command line? Ideally I'd like to send windows messages (eg. WM_COMMAND) to foobar to PLAY, STOP, ADD to playlist, CLEAR playlist. I saw a winamp API wrapper for foobar a little while ago but it did not manipulate the playlist.

Regards.
Dean

identifying FB2K multiple instances

Reply #3
Sorry to revive an old topic, but I'm trying to do the same thing as deandob, but using the commandline and I'm having no luck. I think it must be because foobar uses a mutex now? kode54 mentioned it on this newer thread. (I'm not sure because I thought a mutex was supposed to prevent two instances of the same application running, like DC++ does).

To recap, I'd like to have two installs of foobar2000, say D:\fb2k-1 and D:\fb2k-2. If I run "fb2k-1" as the first instance and then run "fb2k-2" with a directory as a commandline parameter, the files get loaded on a second instance properly. Any further attempts to pass parameters to the first instance are "taken over" by the second one, even when using the full path to the first install.

Does anybody know of a way to achieve this? I'm no good at C/C++, but I know some VB, in case it can be done programatically.

TIA.

edit: silly typo

identifying FB2K multiple instances

Reply #4
Multi-instance is not a feature that the foobar developers are interested in. I went ahead and wrote my own DirectX player with multi-instance capability using the DirectX SDK. The samples are pretty good to hack if you have some C++ experience.

I still use Foobar for another music application that I wrote a .NET front end for, but it shells to foobar on the command line, not very sophisticated. I have found with this method that:
1) I have a single song playlist that when you reset the playlist from the command line and play the new song the first 200 seconds of the old song play before the new one starts. I suspect this is a problem with a foobar internal buffer not being cleared properly.
2) To recognize when a song has completed in foobar and its time to load another one, I look for the foobar window title to change from the song title back to foobar, however occassionally the song title stays in the title bar once the song finishes, which stops my front end from loading the next song.

This method is pretty primitive, if anyone has any better ideas, let me know.

Regards,
Dean

identifying FB2K multiple instances

Reply #5
Aren't there functions in win32 to enumerate all windows? You could get each instance of the foobar window class, and from there work out which is which, maybe by reading the home directory for the parent process of each foobar window. Then simply sendmessage() to whatever window handle you find.

My win32 is a bit rusty i'm afraid...

identifying FB2K multiple instances

Reply #6
Neither the window class nor any windows messages are part of the foobar2000 SDK. This is thus not a reliable or recommended way to interface with foobar2000.

identifying FB2K multiple instances

Reply #7
Quote
Neither the window class nor any windows messages are part of the foobar2000 SDK. This is thus not a reliable or recommended way to interface with foobar2000.
[a href="index.php?act=findpost&pid=297292"][{POST_SNAPBACK}][/a]


It did seem a bit hacky. They seemed resigned to having to do it that way unfortunately due to the limitations.

identifying FB2K multiple instances

Reply #8
Hi.

I got an idea of building a FM transmitter, connect it to a secondary sound card in order to listen to downloaded music without recording CDs. (I know, it's a bit stupid, but I'm sick of having to switch CDs. This way, I can make a 500 files playlist and let it play). Then, I found out Foobar v0.9.3.1 can't open multiple instances. So I opened OllyDbg, hacked the mutex name and <i>pronto</i>, although the "main" foobar "steals" all the command line messages (play, stop, etc).

The whole point of this post is to remind you can control the other Foobar2k using the HTTP Writer.

Oh, and excuse my english: I'm portuguese.