private void fullScreenButtonActionPerformed(java.awt.event.ActionEvent evt) { if (mediaPlayerComponent.getMediaPlayer().isFullScreen()) { mediaPlayerComponent.getMediaPlayer().setFullScreen(false); } else { mediaPlayerComponent.getMediaPlayer().setFullScreen(true); } }
// 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); }
public void stop() { mediaPlayerComponent.getMediaPlayer().stop(); }
public void play() { mediaPlayerComponent.getMediaPlayer().playMedia(mediaMRL); }
public boolean isPlaying() { return mediaPlayerComponent.getMediaPlayer().isPlaying(); }
public void releaseMediaPlayer() { mediaPlayerComponent.release(); }
public MediaPlayer getMediaPlayer() { return mediaPlayerComponent.getMediaPlayer(); }
private void playButtonActionPerformed(java.awt.event.ActionEvent evt) { mediaPlayerComponent.getMediaPlayer().playMedia(mediaMRL); }
private void pauseButtonActionPerformed(java.awt.event.ActionEvent evt) { mediaPlayerComponent.getMediaPlayer().pause(); }
private void stopButtonActionPerformed(java.awt.event.ActionEvent evt) { mediaPlayerComponent.getMediaPlayer().stop(); }
private void volumeSliderStateChanged(javax.swing.event.ChangeEvent evt) { mediaPlayerComponent.getMediaPlayer().setVolume(volumeSlider.getValue()); }
/** 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); }
private void start(String mrl) { mediaPlayerComponent.getMediaPlayer().playMedia(mrl); }