コード例 #1
0
 @Override
 public void play() {
   if (player != null) {
     if (isPlaying) {
       player.pause();
       isPlaying = false;
       log.log(LogType.PLAYER, "Pause");
     } else {
       player.play();
       isPlaying = true;
       log.log(LogType.PLAYER, "Play");
     }
     UIManager.setPlayPauseIcon(isPlaying);
   }
 }
コード例 #2
0
  public void open(PagedListEntry entry) {
    try {
      if (MediaManager.canPlayProtocol("https"))
        BackgroundLoader.addTaskWithTimeout(
            () -> {
              if (entry instanceof PlayList) {
                // expand inner playlists
                currentPlaylist.remove(entry);
                PagedList<PagedListEntry> innerPlaylist = ((PlayList) entry).getTrackList();
                currentPlaylist.addAll(playlistPosition, innerPlaylist);
                currentTrack = (Track) currentPlaylist.get(++playlistPosition);
              } else {
                currentTrack = (Track) entry;
              }
              String url = currentTrack.getStreamURL();

              currentMedia = new Media(url);
              stop();

              currentTrack.getWaveform().resetProgress();
              player = new MediaPlayer(currentMedia);

              player.volumeProperty().bindBidirectional(volumeSliderProb);
              player.setOnEndOfMedia(this::next);
              // TODO: append listener to new player
              player.setAudioSpectrumListener(audioSpectrumListener);

              player.play();
              isPlaying = true;

              UIManager.setTrackForPlayerUI(currentTrack, currentPlaylist);
              UIManager.setPlayPauseIcon(isPlaying);
            },
            3 * 1000);
    } catch (NoSuchMethodError error) {
      // the support came together with that method
      String version = com.sun.javafx.runtime.VersionInfo.getRuntimeVersion();
      log.log(LogType.PLAYER, "JavaFx version does not support https protocol");
      log.log(LogType.PLAYER, "Min version = 8.0.72. Current version " + version);
    }
  }