好吧,我有这个方法,应该运行一个视频,等到它结束,然后播放第二个视频。
我的问题是程序似乎没有等待第一个视频结束,因此直接跳转到第二个视频。
我添加了 wait() 方法,它会导致第一个视频播放,但随后它停止,第二个视频永远不会开始。
任何帮助将不胜感激!
private void test(ActionEvent event) throws InterruptedException {
File fi= new File("test\\firstVideo.mp4");
String filePath= fi.toURI().toString();
openFile(filePath);
wait(5000); //even wait(0) has the same effect
fi= new File("test\\secondVideo.mp4");
filePath= fi.toURI().toString();
openFile(filePath);
}
最佳答案
我认为您混淆了 wait() 和 sleep() ( Difference between wait() and sleep() )
就您而言,您可能想监听一些文件/视频事件并在那里处理它。
关于Java,如何让程序等待视频结束然后继续,wait()使程序停止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44334182/