Esempio n. 1
0
  @Override
  public void start(Stage primaryStage) throws MalformedURLException {

    initialize();

    primaryStage.setTitle("Media Player");
    Group root = new Group();
    Scene scene = new Scene(root, 540, 241);

    // create media player
    File file = new File(MEDIA_URL);
    Media media = null;
    try {
      if (file.exists()) {

        System.out.println("FILE EXISTS");
        media = new Media(file.toURI().toURL().toExternalForm());
        MediaPlayer mediaPlayer = new MediaPlayer(media);
        mediaPlayer.setAutoPlay(false);
        MediaControl mediaControl = new MediaControl(mediaPlayer);
        scene.setRoot(mediaControl);

        primaryStage.setScene(scene);
        primaryStage.show();
      } else {
        Dialogs.showErrorDialog(
            null, null, "Instrumental file not found. Please contact the administrator.", "ERROR");
      }
    } catch (Exception e) {
      System.out.println("FILE DOES NOT EXIST");
      // FileChooser fileChooser = new FileChooser();

      // Set extension filter
      // FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("MP3 files
      // (*.mp3)", "*.mp3");
      // fileChooser.getExtensionFilters().add(extFilter);

      // Show open file dialog
      // file = fileChooser.showOpenDialog(null);
      // String url =
      // "http://mp3crow.mobi/dl/aHR0cDovL2FwaS5zb3VuZGNsb3VkLmNvbS90cmFja3MvNjg4ODI2OTUvc3RyZWFtP2NsaWVudF9pZD1mZmEwYzc5YmY4YWVkYzBkOWIwYmIwNzQyNzhjZjI1MQ==yFRzUi1GcmVzaCAmIFNjcmF0Y2gtRCBvZiBEeW5hbWl4IElJIC0gUm9ja2luIHRvIHRoZSBCZWF0IHRoYXQgaXMgc28gRnJlc2hoaGhoaGho.mp3";
      // media = new Media(file.toURI().toURL().toExternalForm());
      // MediaPlayer mediaPlayer = new MediaPlayer(media);
      // mediaPlayer.setAutoPlay(false);
      // MediaControl mediaControl = new MediaControl(mediaPlayer);
      // scene.setRoot(mediaControl);

      String content = open();

      root.getChildren().add(new Button(content));

      primaryStage.setScene(scene);
      primaryStage.show();
      // Dialogs.showErrorDialog(null, null, "Instrumental file not found. Please contact the
      // administrator.", "ERROR");
    }
  }
  private void init(Stage primaryStage) {
    Group root = new Group();
    primaryStage.setScene(new Scene(root));
    mediaPlayer = new MediaPlayer(new Media(MEDIA_URL));
    mediaPlayer.setAutoPlay(true);

    MediaControl mediaControl = new MediaControl(mediaPlayer);
    mediaControl.setMinSize(480, 280);
    mediaControl.setPrefSize(480, 280);
    mediaControl.setMaxSize(480, 280);
    root.getChildren().add(mediaControl);
  }
Esempio n. 3
0
  @Override
  public void initialize(URL url, ResourceBundle rb) {
    // TODO
    VideoHelper vh = new VideoHelper();
    CurVideoClick cvc = null;
    Video v = null;
    try {
      cvc = vh.getCurrentVideo();
      v = vh.getVideoDetailsCache(cvc.getVid());
    } catch (IOException ex) {
      Logger.getLogger(ViewVideoController.class.getName()).log(Level.SEVERE, null, ex);
    } catch (ClassNotFoundException ex) {
      Logger.getLogger(ViewVideoController.class.getName()).log(Level.SEVERE, null, ex);
    }

    File file = new File("E:\\NetBeansProjects\\BigCoStandalone\\videos\\" + v.getVideopath());
    MEDIA_URL = file.toURI().toString();
    // String path = v.getVideopath().replace(" ", "%20");
    // System.out.println(path+"...........");

    // MEDIA_URL="http://localhost:8084/BigCo/videos/"+path;
    // System.out.println(MEDIA_URL+"..........");

    try {
      vh.insertInCache(v);
    } catch (IOException ex) {
      Logger.getLogger(ViewOfflineController.class.getName()).log(Level.SEVERE, null, ex);
    } catch (ClassNotFoundException ex) {
      Logger.getLogger(ViewOfflineController.class.getName()).log(Level.SEVERE, null, ex);
    }
    mediaPlayer = new MediaPlayer(new Media(MEDIA_URL));
    mediaPlayer.setAutoPlay(true);
    ViewOfflineController.MediaControl mediaControl =
        new ViewOfflineController.MediaControl(mediaPlayer);
    mediaControl.setMinSize(730, 395);
    mediaControl.setPrefSize(730, 395);
    mediaControl.setMaxSize(730, 395);
    viewvideo.getChildren().add(mediaControl);
  }