I have a action listener on a media player using vlcj. When i run the program in debug mode the action listener triggers when the video is finished but when I run it normally in eclipse it does not trigger.
My action listener
public static void youtubeGui(){
Main.playing = true;
final JFrame f = new JFrame();
f.setLocation(100,100);
f.setSize(1000,600);
f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
f.setVisible(true);
Canvas c = new Canvas();
c.setBackground(Color.black);
JPanel p = new JPanel();
p.setLayout(new BorderLayout());
p.add(c);
f.add(p);
NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(),"C:\\Program Files\\VideoLAN\\VLC");
Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class);
MediaPlayerFactory mpf = new MediaPlayerFactory();
EmbeddedMediaPlayer emp = mpf.newEmbeddedMediaPlayer(new Win32FullScreenStrategy(f));
emp.setVideoSurface(mpf.newVideoSurface(c));
emp.setPlaySubItems(true);
String str = Insert.videoQueue.peek();
emp.prepareMedia(str);
emp.play();
Main.playing = true;
try {
TimeUnit.SECONDS.sleep(4);
} catch (InterruptedException e) {
e.printStackTrace();
}
emp.addMediaPlayerEventListener(new MediaPlayerEventAdapter() {
@Override
public void finished(MediaPlayer mediaPlayer) {
Insert.videoQueue.remove();
System.out.println("aaaaa");
f.setVisible(false);
f.dispose();
Main.playing = false;
}
});
}
Checking for new inserts method
public static void addCheck(String locationIn) throws IOException {
String fileLine = "";
String a = "";
while (true) {
Scanner inFile = new Scanner(new FileReader(
locationIn));
while (inFile.hasNext()) {
fileLine = inFile.nextLine();
}
if (fileLine.contains("watch?v=") && fileLine.contains("!add") && !fileLine.equals(a)) {
a = fileLine;
String result = fileLine.substring(fileLine.indexOf("[URL]") + 5, fileLine.indexOf("[/URL]"));
videoQueue.add(result);
result = "";
if(Main.playing == false){
Gui.youtubeGui();
}
}
inFile.close();
}
}