summaryrefslogtreecommitdiff
path: root/core/java/android/webkit/HTML5VideoView.java
diff options
context:
space:
mode:
authorTeng-Hui Zhu <ztenghui@google.com>2011-06-30 16:15:04 -0700
committerTeng-Hui Zhu <ztenghui@google.com>2011-06-30 16:44:47 -0700
commitb1c2c1e3c7bde3c40d7510fbda4ef8112396dd22 (patch)
tree26bd3b87be4c5ddb95b33eb67d1c8cc63174b39d /core/java/android/webkit/HTML5VideoView.java
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
Diffstat (limited to 'core/java/android/webkit/HTML5VideoView.java')
-rw-r--r--core/java/android/webkit/HTML5VideoView.java16
1 files changed, 12 insertions, 4 deletions
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;