我似乎无法将新文件加载到我的媒体播放器中。知道为什么吗?我已经尝试使用Jfilechooser进行摆动,但它不兼容,我不能让FX版本工作。我能够将文件打开栏显示出来。我甚至可以看到打开的按钮,但是在选中时 - 没有任何反应。
我的场景有问题吗?
package jjcg;
import java.io.File;
import java.net.MalformedURLException;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.scene.Scene;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.control.MenuItem;
import javafx.scene.paint.Color;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
/**
*
* @author Jarai
*/
public class JJCG extends Application {
Player player;
FileChooser filechooser;
@Override
public void start(final Stage primaryStage) {
MenuItem open = new MenuItem("Open");
Menu file = new Menu("File");
MenuBar menu = new MenuBar();
file.getItems().add(open);
menu.getMenus().add(file);
filechooser = new FileChooser();
open.setOnAction((ActionEvent e) -> {
player.player.pause();
File file1;
file1 = filechooser.showOpenDialog(primaryStage);
if (file1 != null) {
try {
player = new Player(file1.toURI().toURL().toExternalForm());
Scene scene = new Scene(player, 1400,750, Color.BLACK);
primaryStage.setScene(scene);
}catch (MalformedURLException e1) {
}
}
});
Player player2;
player2 = new Player("file:///C:/Users/Jarai/Videos/BL.mp4");
player2.setTop(menu);
Scene scene = new Scene(player2, 1400, 750, Color.BLACK);
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}