简体   繁体   English

无法在MediaPlayer JavaFX中播放视频

[英]Not playing video in mediaPlayer javafx

I have problem with showing video in JavaFx Media: 我在JavaFx Media中显示视频时遇到问题:

public void showVideo(File videoFile) {
    scrollPane.setHvalue(scrollPane.getHmin());
    scrollPane.setVvalue(scrollPane.getVmin());

    Media media = new Media("http://download.oracle.com/otndocs/products/javafx/oow2010-2.flv");
    final MediaPlayer mediaPlayer = new MediaPlayer(media);
    final MediaView mediaContent = new MediaView(mediaPlayer);

    HBox menuBox = new HBox();
    menuBox.setAlignment(Pos.CENTER);
    menuBox.getChildren().addAll(playButton, stopButton);
    VBox videoBox = new VBox();
    videoBox.setAlignment(Pos.CENTER);
    videoBox.getChildren().addAll(mediaContent, menuBox);

    playButtonListener(mediaPlayer);
    stopButtonListener(mediaPlayer);

    mediaPlayer.setOnEndOfMedia(new Runnable() {
        @Override public void run() {
            playButton.setGraphic(WindowUtil.createIcon(IconsConstants.ICON_PLAYER_REPEAT));
            mediaPlayer.stop();
            playButtonListener(mediaPlayer);
        }
    });

    scrollPane.setContent(videoBox);
}

I know that the code isn't wrong because in my coworker system it shows. 我知道代码没有错,因为在我的同事系统中它可以显示。 I try to show flv file. 我尝试显示flv文件。 I saw question: JavaFX video not playing 我看到了一个问题: JavaFX视频无法播放

I have windows 10 N with K-Lite standart codec and jdk-8u65-windows-x64 Java and I installed feature pack for windows 10 like in link above. 我的Windows 10 N具有K-Lite标准编解码器和jdk-8u65-windows-x64 Java,并且已为Windows 10安装了功能包,如上面的链接所示。 And I don't know what can be the problem. 而且我不知道可能是什么问题。

Ok, problem solved. 好,问题解决了。 I update feature pack and now it's working. 我更新了功能包,现在可以正常工作了。 Probably previous version of feature pack for windows 10 N doesn't have codecs which I need. Windows 10 N的功能部件包的先前版本可能没有我需要的编解码器。

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

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