clean up the mediaplayer at surface destroy, so its recreated
This commit is contained in:
parent
b1fcd36a0b
commit
301f14acdb
1 changed files with 9 additions and 6 deletions
|
@ -218,11 +218,6 @@ public class VideoFragment extends ViewPagerFragment
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void surfaceCreated(SurfaceHolder holder) {
|
|
||||||
initMediaPlayer();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initMediaPlayer() {
|
private void initMediaPlayer() {
|
||||||
if (mMediaPlayer != null)
|
if (mMediaPlayer != null)
|
||||||
return;
|
return;
|
||||||
|
@ -284,6 +279,11 @@ public class VideoFragment extends ViewPagerFragment
|
||||||
mTimerHandler.removeCallbacksAndMessages(null);
|
mTimerHandler.removeCallbacksAndMessages(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void surfaceCreated(SurfaceHolder holder) {
|
||||||
|
initMediaPlayer();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
|
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
|
||||||
|
|
||||||
|
@ -291,7 +291,10 @@ public class VideoFragment extends ViewPagerFragment
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void surfaceDestroyed(SurfaceHolder holder) {
|
public void surfaceDestroyed(SurfaceHolder holder) {
|
||||||
|
if (mMediaPlayer != null) {
|
||||||
|
mMediaPlayer.release();
|
||||||
|
mMediaPlayer = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue