您好我正在尝试在 JavaFx 中添加媒体我尝试了许多解决方案已经在堆栈溢出时可用,但它们似乎都不适合我,当我将文件放入 src 文件夹时我尝试了这个:
Media media = new Media("StartPageVideo.mp4");
// Create the player for playing media.
MediaPlayer mediaPlayer = new MediaPlayer(media);
//set player property to autoplay
mediaPlayer.setAutoPlay(true);
// Create the view and add it to the Scene.
MediaView mediaView = new MediaView(mediaPlayer);
Ap_MediaContainer.getChildren().add(mediaView);
当我将视频放入视频包时,我也尝试过:
Media media = new Media("/Video/StartPageVideo.mp4");
// Create the player for playing media.
MediaPlayer mediaPlayer = new MediaPlayer(media);
//set player property to autoplay
mediaPlayer.setAutoPlay(true);
// Create the view and add it to the Scene.
MediaView mediaView = new MediaView(mediaPlayer);
Ap_MediaContainer.getChildren().add(mediaView);