Esempio n. 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);
   }
 }
Esempio n. 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();
      }
    }
  }
Esempio n. 3
0
 @Override
 public synchronized void start() {
   try {
     if (jukeboxEnabled) {
       jukeboxService.start();
     } else {
       mediaPlayer.start();
     }
     setPlayerState(STARTED);
   } catch (Exception x) {
     handleError(x);
   }
 }
Esempio n. 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);
   }
 }
Esempio n. 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;
   }
 }
Esempio n. 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();
       }
     }
   }
 }
Esempio n. 7
0
 @Override
 public void adjustJukeboxVolume(boolean up) {
   jukeboxService.adjustVolume(up);
 }
Esempio n. 8
0
 private void updateJukeboxPlaylist() {
   if (jukeboxEnabled) {
     jukeboxService.updatePlaylist();
   }
 }