I cant seem to get a new file loaded into my media player. Any idea why? I have tried using the Jfilechooser for swing but it wasn't compatible and I cant get the FX version to work. I am able to get the file open bar to show up. I can even see the open button, but when selected- nothing happens.
Is there something wrong with my scenes?
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);
}
}