Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaFx Audio Output Selection

I'm looking for a way to specify an output device with JavaFx

I have a similar issue as this question: JavaFX specific Audio Output, but with different needs.

I need a way to get a list of all possible Audio Output devices (like the one you see in your user preferences) and allow the user to select which one they want the audio to come out of in JavaFx. This seems like a really basic feature that should be in any music/media API, and is essential for most audio software.

I'm using the MediaPlayer in JavaFx, though if there is another class I'm happy to use it. Note though that I need the same functionality for video (specifying audio output), so I need a class/solution that works for both.

If there's something in JavaFx 8 that will help, I can always wait until it is released.

What I really expected there to be was the same thing as the Screens class:

Screen.getScreens() // Gets an observable list of all screens.

I'm fine with hackish solutions. Really, anything that works.

like image 532
sinθ Avatar asked Aug 06 '13 13:08

sinθ


2 Answers

For years it has been a very unfortunate limitation of the Java implementation for OS X, being BTW particular for that platform, that "Java Sound Audio Engine" is the only programmatically available output audio line. In consequence, whatever you send to this line, i.e. out from any java application that you make, will always be routed to what has been set as the default output in the OS X, typically internal speakers. So the JSAE is just Java terminology for "default audio out". To our understanding - sadly - this is still the case with latest release.

Why unfortunate ? Because it effectively disables even humble audio routing. We are working with these matters on a daily basis, and it calls for all sorts of added complexity. There are work arounds, but via third party apps as SoundFlower and HiJack Pro. www.soundPimp.com for example.

like image 119
Alec. Avatar answered Sep 24 '22 20:09

Alec.


As assylias has pointed out getmixerinfo method can help you

        Info[] mixerInfo =  AudioSystem.getMixerInfo();

    for(int i = 0; i < mixerInfo.length; i++)
    {
         System.out.println(mixerInfo[i].getName());
    }

You can explore further details here

like image 40
MARK Avatar answered Sep 22 '22 20:09

MARK