Пример #1
0
 @Override
 public synchronized void seekTo(int position) {
   try {
     if (jukeboxEnabled) {
       jukeboxService.skip(getCurrentPlayingIndex(), position / 1000);
     } else {
       mediaPlayer.seekTo(position);
     }
   } catch (Exception x) {
     handleError(x);
   }
 }
Пример #2
0
  @Override
  public void setJukeboxEnabled(boolean jukeboxEnabled) {
    this.jukeboxEnabled = jukeboxEnabled;
    jukeboxService.setEnabled(jukeboxEnabled);
    if (jukeboxEnabled) {
      reset();

      // Cancel current download, if necessary.
      if (currentDownloading != null) {
        currentDownloading.cancelDownload();
      }
    }
  }
Пример #3
0
 @Override
 public synchronized void start() {
   try {
     if (jukeboxEnabled) {
       jukeboxService.start();
     } else {
       mediaPlayer.start();
     }
     setPlayerState(STARTED);
   } catch (Exception x) {
     handleError(x);
   }
 }
Пример #4
0
 @Override
 public synchronized void pause() {
   try {
     if (playerState == STARTED) {
       if (jukeboxEnabled) {
         jukeboxService.stop();
       } else {
         mediaPlayer.pause();
       }
       setPlayerState(PAUSED);
     }
   } catch (Exception x) {
     handleError(x);
   }
 }
Пример #5
0
 @Override
 public synchronized int getPlayerPosition() {
   try {
     if (playerState == IDLE || playerState == DOWNLOADING || playerState == PREPARING) {
       return 0;
     }
     if (jukeboxEnabled) {
       return jukeboxService.getPositionSeconds() * 1000;
     } else {
       return mediaPlayer.getCurrentPosition();
     }
   } catch (Exception x) {
     handleError(x);
     return 0;
   }
 }
Пример #6
0
 private synchronized void play(int index, boolean start) {
   if (index < 0 || index >= size()) {
     reset();
     setCurrentPlaying(null);
   } else {
     setCurrentPlaying(index);
     checkDownloads();
     if (start) {
       if (jukeboxEnabled) {
         jukeboxService.skip(getCurrentPlayingIndex(), 0);
         setPlayerState(STARTED);
       } else {
         bufferAndPlay();
       }
     }
   }
 }
Пример #7
0
 @Override
 public void adjustJukeboxVolume(boolean up) {
   jukeboxService.adjustVolume(up);
 }
Пример #8
0
 private void updateJukeboxPlaylist() {
   if (jukeboxEnabled) {
     jukeboxService.updatePlaylist();
   }
 }