summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Teng-Hui Zhu <ztenghui@google.com> 2011-06-30 16:15:04 -0700
committer Teng-Hui Zhu <ztenghui@google.com> 2011-06-30 16:44:47 -0700
commitb1c2c1e3c7bde3c40d7510fbda4ef8112396dd22 (patch)
tree26bd3b87be4c5ddb95b33eb67d1c8cc63174b39d
parent9c902c1aa3ecaa7e601aae81ca812743eb6488f3 (diff)
Release the media player when exiting the full screen
Once we switch out from full screen mode, the player will be re-created for the next video, we should release the sources as early as possible. bug:4332676 Change-Id: I4c26523b3600d3100f81e422979236fca57beb7c
-rw-r--r--core/java/android/webkit/HTML5VideoFullScreen.java5
-rw-r--r--core/java/android/webkit/HTML5VideoView.java16
2 files changed, 17 insertions, 4 deletions
diff --git a/core/java/android/webkit/HTML5VideoFullScreen.java b/core/java/android/webkit/HTML5VideoFullScreen.java
index 11ab0d778043..0ea27a0b9f5e 100644
--- a/core/java/android/webkit/HTML5VideoFullScreen.java
+++ b/core/java/android/webkit/HTML5VideoFullScreen.java
@@ -107,6 +107,7 @@ public class HTML5VideoFullScreen extends HTML5VideoView
// After we return from this we can't use the surface any more.
// The current Video View will be destroy when we play a new video.
pauseAndDispatch(mProxy);
+ mPlayer.release();
mSurfaceHolder = null;
if (mMediaController != null) {
mMediaController.hide();
@@ -226,6 +227,10 @@ public class HTML5VideoFullScreen extends HTML5VideoView
mProxy.getWebView().getViewManager().showAll();
mProxy = null;
+
+ // Don't show the controller after exiting the full screen.
+ mMediaController = null;
+ mCurrentState = STATE_RELEASED;
}
};
diff --git a/core/java/android/webkit/HTML5VideoView.java b/core/java/android/webkit/HTML5VideoView.java
index 5983a4444e96..67660b86af02 100644
--- a/core/java/android/webkit/HTML5VideoView.java
+++ b/core/java/android/webkit/HTML5VideoView.java
@@ -34,6 +34,7 @@ public class HTML5VideoView implements MediaPlayer.OnPreparedListener {
static final int STATE_NOTPREPARED = 1;
static final int STATE_PREPARED = 2;
static final int STATE_PLAYING = 3;
+ static final int STATE_RELEASED = 4;
protected int mCurrentState;
protected HTML5VideoViewProxy mProxy;
@@ -84,7 +85,7 @@ public class HTML5VideoView implements MediaPlayer.OnPreparedListener {
}
public void pause() {
- if (mCurrentState == STATE_PREPARED && mPlayer.isPlaying()) {
+ if (isPlaying()) {
mPlayer.pause();
} else if (mCurrentState == STATE_NOTPREPARED) {
mPauseDuringPreparing = true;
@@ -120,11 +121,18 @@ public class HTML5VideoView implements MediaPlayer.OnPreparedListener {
}
public boolean isPlaying() {
- return mPlayer.isPlaying();
+ if (mCurrentState == STATE_PREPARED) {
+ return mPlayer.isPlaying();
+ } else {
+ return false;
+ }
}
public void release() {
- mPlayer.release();
+ if (mCurrentState != STATE_RELEASED) {
+ mPlayer.release();
+ }
+ mCurrentState = STATE_RELEASED;
}
public void stopPlayback() {
@@ -228,7 +236,7 @@ public class HTML5VideoView implements MediaPlayer.OnPreparedListener {
public int getCurrentState() {
- if (mPlayer.isPlaying()) {
+ if (isPlaying()) {
return STATE_PLAYING;
} else {
return mCurrentState;