[英]JavaFX MediaView rendering a white video
TL;DR : Solution : Increase the JavaFX version to 15.0.1. TL;DR:解决方案:将 JavaFX 版本增加到 15.0.1。
I am re-writing the question I asked yesterday because it was poorly formulated and poorly explained.我正在重新编写我昨天问的问题,因为它的表述和解释都很糟糕。
What I do : I use JavaFX to create a Media and a MediaView to render a .mp4 video in a scene.我的工作:我使用 JavaFX 创建一个 Media 和一个 MediaView 在场景中渲染 .mp4 视频。
What happens : The screen stays blank.会发生什么:屏幕保持空白。
What should happen : The video should be rendered properly and visible by the user.应该发生什么:视频应该正确呈现并且用户可见。
What I've tried :我试过的:
My code :我的代码:
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import javafx.scene.media.MediaView;
import javafx.stage.Stage;
import java.io.File;
public class Application extends javafx.application.Application {
Stage window;
@Override
public void start(Stage primaryStage) {
window = primaryStage;
window.setWidth(2560);
window.setHeight(1440);
window.setX(0);
window.setY(0);
window.setResizable(false);
window.setFullScreen(true);
window.setFullScreenExitHint("");
Pane pane = new Pane();
// Example to show that adding a simple figure to the pane works fine.
javafx.scene.shape.Rectangle r = new javafx.scene.shape.Rectangle(0, 0, 150, 150);
Media media = new Media(new File(/*Insert file name you own for testing purposes*/).toURI().toString());
// The path I would use : "src\\main\\resources\\img\\Animated Titlescreen Background.mp4".
// This is obtained using other classes and methods that read the computer directories,
// so it works fine across different computers.
MediaPlayer mediaPlayer = new MediaPlayer(media);
mediaPlayer.setAutoPlay(true);
MediaView mediaView = new MediaView(mediaPlayer);
pane.getChildren().addAll(mediaView, r);
Scene scene = new Scene(pane, 2560, 1440);
window.setScene(scene);
window.show();
}
public static void main(String[] args) {
launch(args);
}
}
After reading more on this link , it says Windows 8 increase H.264 decoder resolution to 4096x2304 , which is available on JavaFX version 15.0.1.在此链接上阅读更多内容后,它说Windows 8 将 H.264 解码器分辨率提高到 4096x2304 ,可在 JavaFX 版本 15.0.1 上使用。 I was using version 12.0.1 because of a critical issue on Linux with version 15.0.1.
我使用的是 12.0.1 版本,因为 Linux 版本 15.0.1 上存在一个严重问题。
Solution : Increase the JavaFX version to 15.0.1.解决方案:将 JavaFX 版本增加到 15.0.1。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.