简体   繁体   English

从命令行运行应用程序时,JavaFX 8视频播放冻结

[英]JavaFX 8 video playback freeze when running application from command line

when I run this JavaFX 8 application (video playback test) from Eclipse IDE, everything is fine. 当我从Eclipse IDE运行此JavaFX 8应用程序(视频播放测试)时,一切都很好。 Application run video playback in loop indefinitely. 应用程序无限期地循环运行视频播放。 But when I run this application from command line: 但是,当我从命令行运行此应用程序时:

java -jar test-javafx8-video-playback-jar-with-dependencies.jar

it just playback for some seconds and then freeze the playback. 它只会播放几秒钟,然后冻结播放。 Here is a application source code: test-javafx8-video-playback 这是应用程序源代码: test-javafx8-video-playback

Please advise, thanks. 请指教,谢谢。

OK, here is a code snippet that plays video: 好的,这是播放视频的代码段:

private void playBallMixingAnimation() {
    Media media = new Media(KenoKaironMain.getResourceURIFromProperties(KenoKaironMain.BALL_MIXER_URI_KEY));
    MediaPlayer mediaPlayer = new MediaPlayer(media);
    mediaPlayer.setCycleCount(MediaPlayer.INDEFINITE);
    mediaPlayer.setMute(true);
    mediaPlayer.setAutoPlay(true);
    animMediaView.setMediaPlayer(mediaPlayer);
}

As I said, it works in indefinite loop in Eclipse, but not when I start application from command line. 就像我说过的那样,它在Eclipse中无限循环运行,但是当我从命令行启动应用程序时却无法运行。 Eclipse is using jdk1.8.0_51 and Windows/OSX is using jre1.8.0_51 and I have more than enough RAM for this small application. Eclipse使用jdk1.8.0_51,Windows / OSX使用jre1.8.0_51,对于这个小型应用程序,我拥有足够多的RAM。

Here is what I found out. 这是我发现的。

It is all about supported media formats. 这都是关于支持的媒体格式的。 As you might know JavaFX supports this video formats: 您可能知道JavaFX支持以下视频格式:

  1. FLV container with MP3 and VP6 带有MP3和VP6的FLV容器

  2. MPEG-4 container with either AAC, H.264, or both 带有AAC,H.264或两者的MPEG-4容器

Only FLV video file with On2's VP6 encoding will play in indefinitely loop both started from Eclipse IDE or from command line. 从Eclipse IDE或从命令行开始,只有具有On2 VP6编码的FLV视频文件才能无限循环播放。

MPEG-4 container with either AAC or H.264 will play in indefinitely loop only from Eclipse IDE and will freeze after first loop when started from command line. 带有AAC或H.264的MPEG-4容器只能从Eclipse IDE无限循环播放,并且从命令行启动时,在第一次循环后将冻结。

This I tested using Oracle FLV sample: http://download.oracle.com/otndocs/products/javafx/oow2010-2.flv and confirmed by using this FLV sample: http://www.mediacollege.com/video-gallery/testclips/20051210-w50s.flv 我使用Oracle FLV示例进行了测试: http : //download.oracle.com/otndocs/products/javafx/oow2010-2.flv,并通过使用以下FLV示例进行了确认: http : //www.mediacollege.com/video-gallery /testclips/20051210-w50s.flv

For the MPEG-4 you can try by your self and make sure that it won't work in indefinitely loop from command line. 对于MPEG-4,您可以自己尝试并确保它不会在命令行中无限期地循环工作。

My test configuration is: OS X 10.9.5, Java JDK 1.8.0_51, Eclipse Luna (4.4.1) and code snippet I posted above. 我的测试配置是:OS X 10.9.5,Java JDK 1.8.0_51,Eclipse Luna(4.4.1)和上面发布的代码段。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM