Exemplo n.º 1
0
 private void fullScreenButtonActionPerformed(java.awt.event.ActionEvent evt) {
   if (mediaPlayerComponent.getMediaPlayer().isFullScreen()) {
     mediaPlayerComponent.getMediaPlayer().setFullScreen(false);
   } else {
     mediaPlayerComponent.getMediaPlayer().setFullScreen(true);
   }
 }
Exemplo n.º 2
0
  // attach vidoe player + progress bar
  public void attachMediaPanel() {
    // MEDIA COMPONENT
    JPanel mediaPanel = new JPanel(new BorderLayout());

    EmbeddedMediaPlayerComponent mediaPlayerComponent = new EmbeddedMediaPlayerComponent();
    video = mediaPlayerComponent.getMediaPlayer();
    video.addMediaPlayerEventListener(
        new MediaPlayerEventAdapter() {
          @Override
          public void finished(uk.co.caprica.vlcj.player.MediaPlayer mediaPlayer) {
            vidOption.setIsPlaying(false);
            playButton.setText("Play");
          }
        });

    JPanel progressPane = new JPanel(new BorderLayout());
    timeLbl1 = new JLabel("00:00");
    timeLbl2 = new JLabel("00:00");
    progressPane.add(timeLbl1, BorderLayout.WEST);
    progressPane.add(progress, BorderLayout.CENTER);
    progressPane.add(timeLbl2, BorderLayout.EAST);

    mediaPanel.add(mediaPlayerComponent, BorderLayout.CENTER);
    mediaPanel.add(progressPane, BorderLayout.SOUTH);
    mainPanel.add(mediaPanel, BorderLayout.CENTER);
  }
Exemplo n.º 3
0
 public void stop() {
   mediaPlayerComponent.getMediaPlayer().stop();
 }
Exemplo n.º 4
0
 public void play() {
   mediaPlayerComponent.getMediaPlayer().playMedia(mediaMRL);
 }
Exemplo n.º 5
0
 public boolean isPlaying() {
   return mediaPlayerComponent.getMediaPlayer().isPlaying();
 }
Exemplo n.º 6
0
 public void releaseMediaPlayer() {
   mediaPlayerComponent.release();
 }
Exemplo n.º 7
0
 public MediaPlayer getMediaPlayer() {
   return mediaPlayerComponent.getMediaPlayer();
 }
Exemplo n.º 8
0
 private void playButtonActionPerformed(java.awt.event.ActionEvent evt) {
   mediaPlayerComponent.getMediaPlayer().playMedia(mediaMRL);
 }
Exemplo n.º 9
0
 private void pauseButtonActionPerformed(java.awt.event.ActionEvent evt) {
   mediaPlayerComponent.getMediaPlayer().pause();
 }
Exemplo n.º 10
0
 private void stopButtonActionPerformed(java.awt.event.ActionEvent evt) {
   mediaPlayerComponent.getMediaPlayer().stop();
 }
Exemplo n.º 11
0
 private void volumeSliderStateChanged(javax.swing.event.ChangeEvent evt) {
   mediaPlayerComponent.getMediaPlayer().setVolume(volumeSlider.getValue());
 }
Exemplo n.º 12
0
  /** Creates new form VlcPlayer */
  public VlcPlayer() {
    vlcPlayerPanel = this;
    initComponents();
    positionSlider.setValue(0);
    mediaPlayerComponent = new MyEmbeddedMediaPlayerComponent();
    add(mediaPlayerComponent, BorderLayout.CENTER);

    MyMediaPlayerEventAdater mediaPlayerEventAdapter =
        new MyMediaPlayerEventAdater() {

          @Override
          public void finished(MediaPlayer mediaPlayer) {
            super.finished(mediaPlayer);
            stopButton.setEnabled(false);
            playButton.setEnabled(true);
            pauseButton.setEnabled(false);
            skipPreviousButton.setEnabled(false);
            skipNextButton.setEnabled(false);
            fullScreenButton.setEnabled(false);
            pauseButton.setText("暂停");
            pauseButton.setIcon(
                new javax.swing.ImageIcon(
                    getClass()
                        .getResource(
                            "/com/lorent/common/resource/images/media-playback-pause-8.png")));
          }

          @Override
          public void paused(MediaPlayer mediaPlayer) {
            super.paused(mediaPlayer);
            pauseButton.setText("继续");
            pauseButton.setIcon(
                new javax.swing.ImageIcon(
                    getClass()
                        .getResource(
                            "/com/lorent/common/resource/images/media-playback-start-8.png")));
          }

          @Override
          public void playing(MediaPlayer mediaPlayer) {
            super.playing(mediaPlayer);
            playButton.setEnabled(false);
            stopButton.setEnabled(true);
            pauseButton.setEnabled(true);
            skipPreviousButton.setEnabled(true);
            skipNextButton.setEnabled(true);
            fullScreenButton.setEnabled(true);
            pauseButton.setText("暂停");
            pauseButton.setIcon(
                new javax.swing.ImageIcon(
                    getClass()
                        .getResource(
                            "/com/lorent/common/resource/images/media-playback-pause-8.png")));
          }

          @Override
          public void stopped(MediaPlayer mediaPlayer) {
            super.stopped(mediaPlayer);
            stopButton.setEnabled(false);
            playButton.setEnabled(true);
            pauseButton.setEnabled(false);
            skipPreviousButton.setEnabled(false);
            skipNextButton.setEnabled(false);
            fullScreenButton.setEnabled(false);
            pauseButton.setText("暂停");
            pauseButton.setIcon(
                new javax.swing.ImageIcon(
                    getClass()
                        .getResource(
                            "/com/lorent/common/resource/images/media-playback-pause-8.png")));
          }

          @Override
          public void positionChanged(MediaPlayer mediaPlayer, float newPosition) {
            super.positionChanged(mediaPlayer, newPosition);

            final float temp = newPosition;

            SwingUtilities.invokeLater(
                new Runnable() {
                  @Override
                  public void run() {
                    int position = (int) (temp * 1000.0f);
                    //						log.info("positionChanged:  oldposition: "+mediaPlayerComponent
                    //								.getMediaPlayer().getPosition()+" newposition: "+temp);
                    positionSlider.setValue(position);
                    positionProgressBar.setValue(position);
                  }
                });
          }
        };

    mediaPlayerComponent.getMediaPlayer().addMediaPlayerEventListener(mediaPlayerEventAdapter);
    //		executorService.scheduleAtFixedRate(new UpdateRunnable(
    //				mediaPlayerComponent.getMediaPlayer()), 0L, 1L,
    //				TimeUnit.SECONDS);
    //		fullscreenWindow.setExtendedState(state)

    fullscreenWindow.setAlwaysOnTop(true);
    fullscreenWindow.setFocusable(true);
    fullscreenWindow.addMouseListener(
        new MouseAdapter() {

          @Override
          public void mouseClicked(MouseEvent e) {
            log.info("fullscreenframe.mouseClicked");
          }
        });
    fullscreenWindow.addWindowListener(
        new WindowAdapter() {

          @Override
          public void windowClosing(WindowEvent e) {
            mediaPlayerComponent.getMediaPlayer().setFullScreen(false);
          }
        });
    fullscreenWindow.addKeyListener(
        new KeyAdapter() {

          @Override
          public void keyPressed(KeyEvent e) {

            if (e.getID() == KeyEvent.KEY_PRESSED) {
              if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
                if (fullscreenWindow.isVisible()) {
                  mediaPlayerComponent.getMediaPlayer().setFullScreen(false);
                }
              }
            }
          }
        });
    fullscreenWindow.setUndecorated(true);
    //		fullscreenDialog.setResizable(false);
    //
    //	GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(fullscreenframe);
  }
Exemplo n.º 13
0
 private void start(String mrl) {
   mediaPlayerComponent.getMediaPlayer().playMedia(mrl);
 }