/**
  * Start preparing plauer for play. After call this method player is preparing. If player is
  * prepared then start playing. If player is prepared and method is called again with this same
  * parameter then player starts playing immediately form beginning.
  *
  * @return Flag that indicate the Player need to preparing.
  */
 public boolean play(String path) {
   if (this.sourceUrl.equals(path)) {
     if (mediaPlayer == null) {
       setDataSource(path);
     } else if (isPrepared) {
       if (isPlaying()) {
         mediaPlayer.seekTo(0);
       } else {
         mediaPlayer.start();
       }
       return true;
     } else {
       if (endListener != null) {
         endListener.onCompletion(mediaPlayer);
       }
       setDataSource(path);
     }
   } else {
     if (endListener != null) {
       endListener.onCompletion(mediaPlayer);
     }
     release();
     setDataSource(path);
   }
   return false;
 }
예제 #2
0
 private boolean notifyCompletionListener(MediaPlayer mediaplayer) {
   if (mOnCompletionListener != null) {
     mOnCompletionListener.onCompletion(mediaplayer);
     return true;
   }
   return false;
 }
예제 #3
0
 @Override
 public void run() {
   try {
     mInnerSource.playNative();
   } catch (IOException e) {
     Log.e(TAG, "error playing audio", e);
   }
   MediaPlayer.OnCompletionListener completionListener;
   boolean skipThisCompletionReport;
   synchronized (lock) {
     completionListener = mCompletionListener;
     skipThisCompletionReport = mSkipCompletionReport;
     mPlaybackFinishedLatch.countDown();
   }
   if (!skipThisCompletionReport && completionListener != null) {
     completionListener.onCompletion(null);
   }
 }
 @Override
 public void onCompletion(MediaPlayer mp) {
   mCurrentState = STATE_PLAYBACK_COMPLETED;
   //			mTargetState = STATE_PLAYBACK_COMPLETED;
   if (mOnCompletionListener != null) mOnCompletionListener.onCompletion(mp);
 }
예제 #5
0
 @Override
 public void onCompletion(MediaPlayer mp) {
   Log.d(TAG, "onCompletion()");
   mOnCompletionListener.onCompletion(mp);
 }