-->

Catching the sound played with vlcj

2019-08-12 04:34发布

问题:

After few reseach and many problems with the different audio formats, I'm trying to use vlcj. For playing sounds, it seems to be perfect. But, to follow another question I've asked, I'd like to catch the sound played in vlcj.

Someone told me that it's impossible for JavaSound to catch the sound played out of the JVM. Ok. But how to do with a sound played in the JVM, using vlcj ?

vlcj have methods to set the volume. But I didn't found anything to get the "level output" or to catch the sound and mix it with another sound for example.

Does someone may help me again ? Thank you very much.

Here is a very simple example of a player using vlcj, just with the help of the firsts tutorials.

import javax.swing.JFrame;
import javax.swing.SwingUtilities;

import uk.co.caprica.vlcj.component.EmbeddedMediaPlayerComponent;
import uk.co.caprica.vlcj.discovery.NativeDiscovery;

public class SimplePlayer {
private final JFrame frame;
private final EmbeddedMediaPlayerComponent mediaPlayerComponent;
private String[] playList = new String [] {
        "Donna Summer - Last Dance.mp3",
        "Bon Jovi - Bed Of Roses - YouTube.mp3",
        "Sam Brown - Stop (Official Music Video) - YouTube.mp3",
        };

public SimplePlayer() {
    frame = new JFrame("My First Media Player");
    frame.setBounds(100, 100, 600, 400);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    mediaPlayerComponent = new EmbeddedMediaPlayerComponent();
    frame.setContentPane(mediaPlayerComponent);
    frame.setVisible(true);
    mediaPlayerComponent.getMediaPlayer().playMedia(playList[2]);
}


public static void main(String[] args) {
    new NativeDiscovery().discover();
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            new SimplePlayer();
        }
    });       
}    
}