简体   繁体   中英

Set sound output device using vlcj

I would like to set my vlcj created player to output sound to virtual audio cable, is it possible? The vlcj player doesn't seem to inherit the options from the native player, so I dont really know how I could change the output. Thanks

edit: This is basically how far i've gotten, but nothing actually happens:

mediaPlayerComponent = new EmbeddedMediaPlayerComponent();
    mediaPlayerComponent.getMediaPlayer().setPlaySubItems(true);

    List<AudioOutput> outputs = mediaPlayerComponent.getMediaPlayerFactory().getAudioOutputs();

    for (AudioOutput i : outputs) {
        System.out.println(i);
        List<AudioDevice> devices = i.getDevices();
        if (!devices.isEmpty()) {
            for (AudioDevice itdev : devices) {
                System.out.println(itdev.getDeviceId());
            }
        }
    }
    mediaPlayerComponent.getMediaPlayer().setAudioOutputDevice(outputs.get(5).getDevices().get(3).toString(), outputs.get(5).getDevices().get(3).toString());

Presumably your "virtual audio cable" is a specific audio output device.

So, get the list of AudioOutput from the MediaPlayerFactory .

Enumerate that list of outputs to find the one you want, by name.

When you find the audio output you want, you can inspect the list of AudioDevice associated with that output.

When you find the audio device you want, set it on the MediaPlayer . There are setAudioOutput() and setAudioOutputDevice() methods there.

The associated vlcj-player project at github shows one way to build a menu of audio devices and allows you to select one.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM