出现白屏,而不是播放视频

时间:2019-07-18 19:34:44

标签: javafx

尝试在窗口中加载视频文件。但是运行该应用程序后,视频(持续时间约1分钟)没有播放。我使用mediaview将文件添加到窗格中。但是视频没有以某种方式添加到窗格中。 它只是显示白色屏幕,而不是播放视频文件。



public void start(Stage primaryStage) throws Exception {


        primaryStage.setTitle("Chess game");
                Media media=new Media("file:///C:/Users/Avi/Desktop/intro.mp4");
                MediaPlayer videoplay=new MediaPlayer(media);
                 MediaView openView=new MediaView(videoplay);
                 //videoplay.setAutoPlay(true);
                 Scene scene =new Scene(root,1900,1000);
                 Button play=new Button("");
                 Image first=new Image("file:///C:/Users/Avi/Desktop/intro_image.jpg");
                ImageView firstView=new ImageView(first);
                firstView.setFitHeight(1000);
                firstView.setFitWidth(1900);
                 play.setOnAction(e->primaryStage.setScene(scene));
                 intro_pane.getChildren().add(openView);
                 intro_pane.getChildren().add(play);


                 Scene intro=new Scene(intro_pane,1900,1000);



                Image img1=new Image("file:///C:/Users/Avi/Desktop/background.jpg");
                ImageView view1=new ImageView(img1);
                view1.setFitHeight(1000+10);
                view1.setFitWidth(1900+10);

                BackWater.setLayoutX(0);
                BackWater.setLayoutY(0);

                root.getChildren().add(BackWater);
                root.getChildren().add(view1);



                StackPane main_pane=new StackPane(sp_mainlayout,watermark);
                main_pane.setPrefSize(950, 900);
                main_pane.setLayoutX(1950/2-500);
                main_pane.setLayoutY(50-5);


                main_pane.setBorder(new Border(new BorderStroke(SADDLEBROWN, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(20))));

                root.getChildren().add(main_pane);




        primaryStage.setScene(intro);
        primaryStage.setMinWidth(300);
        primaryStage.setMinHeight(300);
                primaryStage.setResizable(false);

        primaryStage.show();
    }


0 个答案:

没有答案