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); } }
private void release(boolean cleartargetstate) { if (mMediaPlayer != null) { mMediaPlayer.reset(); mMediaPlayer.release(); mMediaPlayer = null; mCurrentState = STATE_IDLE; if (cleartargetstate) mTargetState = STATE_IDLE; } }
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; } }
public boolean onError(MediaPlayer mp, int what, int extra) { mediaController.showError(0); mp.reset(); return false; }