Exemplo n.º 1
0
  /** Prepare the window that shall show the openGL content. */
  private void initWindow() {
    IllarionLookAndFeel.setupLookAndFeel();
    // create canvas that shall show the openGL content
    display = Graphics.getInstance().getRenderDisplay();
    display.getRenderArea().setBackground(Color.red);

    configChanged(IllaClient.getCfg(), CFG_RESOLUTION);

    final Component displayParent = display.getRenderArea();
    displayParent.setBackground(Color.green);
    displayParent.setVisible(true);

    // set up the window settings
    displayFrame = new Frame();
    displayFrame.setLayout(new BorderLayout(0, 0));
    displayFrame.setTitle(IllaClient.getVersionText());
    displayFrame.setBackground(Color.black);

    setIcon(displayFrame);

    displayFrame.addWindowListener(new ClientWindowListener());
    displayFrame.setResizable(false);
    displayFrame.setFocusable(false);
    displayFrame.setFocusableWindowState(true);
    displayFrame.setFocusTraversalKeysEnabled(false);
    displayParent.setFocusable(true);
    displayParent.setFocusTraversalKeysEnabled(false);

    // add the canvas to the window and make the canvas the openGL render
    // target.
    displayFrame.add(displayParent, BorderLayout.CENTER);
    displayFrame.pack();

    displayFrame.setLocationRelativeTo(null);
    displayFrame.setVisible(true);

    displayParent.requestFocusInWindow();

    final RenderDisplay usedDisplay = display;
    Graphics.getInstance()
        .getRenderManager()
        .addTask(
            new RenderTask() {
              @Override
              public boolean render(final int delta) {
                usedDisplay.startRendering();
                return false;
              }
            });
  }
Exemplo n.º 2
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);
  }