Esempio n. 1
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);
    }
  }
Esempio n. 2
0
 public void bindVolume(Property<Number> volumeProb) {
   if (player != null) {
     player.volumeProperty().bindBidirectional(volumeProb);
   }
   volumeSliderProb = volumeProb;
 }