0
我使用VLCJ在運行我的程序時播放視頻。視頻結束時有什麼方法可以自動關閉它嗎?我不會讓Keylistener關閉視頻用VLCJ播放器結束視頻?
謝謝!
代碼:
String file = "Estopa.mp4";
public Test(){
f.setLocation(100,100);
f.setSize(alto,ancho);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
c.setBackground(Color.black);
p.setLayout(new BorderLayout());
p.add(c);
f.add(p);
// Read video file
// load native library
NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(),"C:/Program Files/VideoLAN/VLC");
Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class);
// initialize the media player
MediaPlayerFactory mpf = new MediaPlayerFactory();
// control all the interactions with the user
EmbeddedMediaPlayer emp = mpf.newEmbeddedMediaPlayer(new Win32FullScreenStrategy(f));
emp.setVideoSurface(mpf.newVideoSurface(c));
// full screen
emp.toggleFullScreen();
//hide the cursor
emp.setEnableMouseInputHandling(true);
//able keyboard
emp.setEnableKeyInputHandling(true);
//prepare file to read
emp.prepareMedia(file);
// read the file
emp.play();
}