예제 #1
0
  private void openVideo() {
    if (mUri == null || mPlayer == null) return;

    mPlayer.reset();
    mInitialized = false;
    mPrepared = false;
    mVideoSizeKnown = false;

    try {
      mPlayer.setScreenOnWhilePlaying(true);
      mPlayer.setDataSource(PlayerService.this, mUri);
      // if (mLastAudioTrack != -1)
      // mPlayer.setInitialAudioTrack(mLastAudioTrack);
      // if (mLastSubTrackId != -1)
      // mPlayer.setInitialSubTrack(mLastSubTrackId);
      if (mSurfaceHolder != null
          && mSurfaceHolder.getSurface() != null
          && mSurfaceHolder.getSurface().isValid()) mPlayer.setDisplay(mSurfaceHolder);
      mPlayer.prepareAsync();
    } catch (IllegalArgumentException e) {
      Logger.e("openVideo", e);
    } catch (IllegalStateException e) {
      Logger.e("openVideo", e);
    } catch (IOException e) {
      Logger.e("openVideo", e);
    }
  }
예제 #2
0
 private void release(boolean cleartargetstate) {
   if (mMediaPlayer != null) {
     mMediaPlayer.reset();
     mMediaPlayer.release();
     mMediaPlayer = null;
     mCurrentState = STATE_IDLE;
     if (cleartargetstate) mTargetState = STATE_IDLE;
   }
 }
예제 #3
0
 private void release(boolean all) {
   if (mPlayer != null) {
     if (mListener != null) mListener.onCloseStart();
     mPlayer.reset();
     mInitialized = false;
     mPrepared = false;
     mVideoSizeKnown = false;
     if (mListener != null) mListener.onCloseComplete();
   }
   if (all) {
     mListener = null;
     mUri = null;
   }
 }
예제 #4
0
 public boolean onError(MediaPlayer mp, int what, int extra) {
   mediaController.showError(0);
   mp.reset();
   return false;
 }