Ejemplo n.º 1
0
  protected void initialize() {

    this.playIcon =
        new ImageIcon(getClass().getResource("/net/firefly/client/resources/images/play.png"));
    this.pressedPlayIcon =
        new ImageIcon(getClass().getResource("/net/firefly/client/resources/images/play-on.png"));
    this.pauseIcon =
        new ImageIcon(getClass().getResource("/net/firefly/client/resources/images/pause.png"));
    this.pressedPauseIcon =
        new ImageIcon(getClass().getResource("/net/firefly/client/resources/images/pause-on.png"));
    this.stopIcon =
        new ImageIcon(getClass().getResource("/net/firefly/client/resources/images/stop.png"));
    this.pressedStopIcon =
        new ImageIcon(getClass().getResource("/net/firefly/client/resources/images/stop-on.png"));

    setToolTipText(
        ResourceManager.getLabel("player.control.play.pause", context.getConfig().getLocale()));

    setOpaque(false);
    setVerticalAlignment(SwingConstants.CENTER);
    setIcon(this.playIcon);

    setBackground(null);
    setIconTextGap(0);
    setBorder(new EmptyBorder(0, 0, 0, 0));

    addMouseListener(
        new java.awt.event.MouseAdapter() {
          public void mouseClicked(java.awt.event.MouseEvent e) {
            PlayerStatus playerStatus = context.getPlayer().getPlayerStatus();
            if (playerStatus.equals(PlayerStatus.STATUS_STOPPED)) {
              context.getPlayer().resume();
            } else {
              context.getPlayer().pause();
            }
          }

          public void mousePressed(java.awt.event.MouseEvent e) {
            if (getIcon().toString().equals(playIcon.toString())) {
              setIcon(pressedPlayIcon);
            } else if (getIcon().toString().equals(pauseIcon.toString())) {
              setIcon(pressedPauseIcon);
            } else {
              setIcon(pressedStopIcon);
            }
          }

          public void mouseReleased(MouseEvent arg0) {
            if (getIcon().toString().equals(pressedPlayIcon.toString())) {
              setIcon(playIcon);
            } else if (getIcon().toString().equals(pressedPauseIcon.toString())) {
              setIcon(pauseIcon);
            } else {
              setIcon(stopIcon);
            }
          }
        });

    this.context.getPlayer().addPlayerStatusChangedEventListener(this);
  }
Ejemplo n.º 2
0
 public void onPlayerStatusChange(PlayerStatusChangedEvent evt) {
   PlayerStatus newPlayerStatus = evt.getNewStatus();
   if (newPlayerStatus.equals(PlayerStatus.STATUS_STOPPED)) {
     setIcon(this.playIcon);
   } else if (context.getPlayer().isSupportSeeking()) {
     setIcon(this.pauseIcon);
   } else {
     setIcon(this.stopIcon);
   }
 }