我目前正在研究可以播放mkv
格式的 java 媒体播放器。我正在使用VLCJ
,一切正常,除非我尝试更改不起作用的音轨。
这是代码
public class mediaplayer {
private static JFileChooser filechooser = new JFileChooser();
public mediaplayer() {
}
public static void main(String[] args) {
String vlcPath = "", mediaPath = "";
File ourfile;
filechooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
filechooser.showSaveDialog(null);
ourfile = filechooser.getSelectedFile();
mediaPath = ourfile.getAbsolutePath();
EmbeddedMediaPlayerComponent mediacom = new EmbeddedMediaPlayerComponent();
JFrame frame = new JFrame();
frame.setContentPane(mediacom);
frame.add(canvas);
frame.setLocation(100, 100);
frame.setSize(1050, 600);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
MediaPlayer mplayer = mediacom.getMediaPlayer();
mplayer.playMedia(mediaPath);
mplayer.setAudioTrack(1);
}
}