Skip to content

Commit

Permalink
Clean ijk code
Browse files Browse the repository at this point in the history
  • Loading branch information
FongMi committed May 9, 2023
1 parent 7b84f16 commit dce87a9
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ public void addListener(IMediaPlayer.Listener listener) {

public void setRender(int render) {
mCurrentRender = render;
if (mPlayer == null) return;
switch (render) {
case RENDER_TEXTURE_VIEW:
setRenderView(new TextureRenderView(getContext()));
Expand Down Expand Up @@ -146,8 +145,6 @@ private void openVideo(Uri uri, Map<String, String> headers) {
fixUserAgent(headers);
setSpeed(mCurrentSpeed);
setRender(mCurrentRender);
mCurrentBufferPosition = 0;
mCurrentBufferPercentage = 0;
mAudioManager.requestAudioFocus(null, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN);
mPlayer.setDataSource(getContext(), uri, headers);
mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
Expand Down Expand Up @@ -198,20 +195,23 @@ public void stop() {
if (mPlayer == null) return;
mPlayer.stop();
mPlayer.reset();
mTargetState = STATE_IDLE;
mCurrentState = STATE_IDLE;
mAudioManager.abandonAudioFocus(null);
reset();
}

public void release() {
if (mPlayer == null) return;
mSubtitleView.setText("");
removeRenderView();
mPlayer.reset();
mPlayer.release();
mPlayer = null;
reset();
}

private void reset() {
mSubtitleView.setText("");
mTargetState = STATE_IDLE;
mCurrentState = STATE_IDLE;
mCurrentBufferPosition = 0;
mCurrentBufferPercentage = 0;
mAudioManager.abandonAudioFocus(null);
}

Expand Down

0 comments on commit dce87a9

Please sign in to comment.