Пример #1
0
  public void playNextSong(MusicItem musicItem) {
    String url = musicItem.audio;
    Logger.debug(TAG, ">>>" + "playNextSong:" + url);
    if (musicPlayBackCallback != null) {
      musicPlayBackCallback.onPreparing(currentItem);
    }
    mState = State.Stopped;

    relaxResource(false);
    try {
      setupMediaPlayerIfNeeded();

      mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
      mediaPlayer.setDataSource(url);
      isStreaming = url.startsWith("http:") || url.startsWith("https:");

      songTitle = url;

      mState = State.Preparing;
      setupAsForeGround(musicItem);

      /** @see onPreparedListener */
      mediaPlayer.prepareAsync();

      if (isStreaming) {
        wifiLock.acquire();
      } else if (wifiLock.isHeld()) {
        wifiLock.release();
      }

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Пример #2
0
 public void processPauseRequest() {
   Logger.debug(TAG, ">>>" + "processPauseRequest");
   if (mState == State.Playing) {
     mState = State.Paused;
     mediaPlayer.pause();
     relaxResource(false);
   }
 }