예제 #1
0
  public MediaPanel(URL mediaURL) {
    setLayout(new BorderLayout()); // use a BorderLayout

    // Use lightweight components for Swing compatibility
    Manager.setHint(Manager.LIGHTWEIGHT_RENDERER, true);

    try {
      // create a player to play the media specified in the URL
      Player mediaPlayer = Manager.createRealizedPlayer(mediaURL);

      // get the components for the video and the playback controls
      Component video = mediaPlayer.getVisualComponent();
      Component controls = mediaPlayer.getControlPanelComponent();

      if (video != null) add(video, BorderLayout.CENTER); // add video component

      if (controls != null) add(controls, BorderLayout.SOUTH); // add controls

      mediaPlayer.start(); // start playing the media clip
    } // end try
    catch (NoPlayerException noPlayerException) {
      System.err.println("No media player found");
    } // end catch
    catch (CannotRealizeException cannotRealizeException) {
      System.err.println("Could not realize media player");
    } // end catch
    catch (IOException iOException) {
      System.err.println("Error reading from the source");
    } // end catch
  } // end MediaPanel constructor
예제 #2
0
  /** Crea Ftes new form PanelFilm */
  public PanelFilm(URL mediaUrl) throws IOException {
    initComponents();
    setLayout(new BorderLayout());
    Manager.setHint(Manager.LIGHTWEIGHT_RENDERER, true);

    drawFilm = new JPanel();

    try {

      mediaPlayer = Manager.createRealizedPlayer(mediaUrl);
      System.out.println(Manager.createRealizedPlayer(mediaUrl).toString());
      video = mediaPlayer.getVisualComponent();
      System.out.println(mediaPlayer.getVisualComponent());
      controls = mediaPlayer.getControlPanelComponent();

      if (video != null) {
        drawFilm.add(video, BorderLayout.CENTER);
      }

      if (controls != null) {
        drawFilm.add(controls, BorderLayout.SOUTH);
      }
      this.setVisible(false);
      drawFilm.setVisible(true);

      mediaPlayer.start();

    } catch (NoPlayerException noPlayerException) {
      noPlayerException.printStackTrace();
    } catch (CannotRealizeException cannotRealizeException) {
      cannotRealizeException.printStackTrace();
    }
  }
예제 #3
0
  // Constructor
  public MediaPlayer(URL mediauUrl) {

    setLayout(new BorderLayout()); // use a BorderLayout

    // Use lightweight components for Swing compatibility
    Manager.setHint(Manager.LIGHTWEIGHT_RENDERER, true);

    try {
      // create a player to play the media specified in the URL
      Player mediaPlayer = Manager.createRealizedPlayer(mediauUrl);

      // get the components for the video and the playback controls
      Component video = mediaPlayer.getVisualComponent();
      Component control = mediaPlayer.getControlPanelComponent();

      if (video != null) {
        add(video, BorderLayout.CENTER); // place the video component in the panel
      }

      if (control != null) {
        add(control, BorderLayout.SOUTH); // place the control component in  the panel
      }
      mediaPlayer.start(); // start playing the media clip
    } catch (NoPlayerException noPlayerException) {
      System.err.println("No media player found: " + noPlayerException);
    } catch (CannotRealizeException cannotRealizeException) {
      System.err.println("Could not realize media player: " + cannotRealizeException);
    } catch (IOException iOException) {
      System.err.println("Error reading from the source: " + iOException);
    }
  }
예제 #4
0
 protected void initJMF() {
   Manager.setHint(Manager.LIGHTWEIGHT_RENDERER, true);
 }