summaryrefslogtreecommitdiff
path: root/core/java/android/webkit/HTML5VideoView.java
diff options
context:
space:
mode:
authorTeng-Hui Zhu <ztenghui@google.com>2011-03-21 14:26:14 -0700
committerTeng-Hui Zhu <ztenghui@google.com>2011-03-21 17:38:21 -0700
commitcd445624556d8bd83313fed56388d4e6939ac5e9 (patch)
treeef6159773194fc56340f599ee1b0299de5556770 /core/java/android/webkit/HTML5VideoView.java
parent0b933c02dddbc325498b3b73d8be9167b155801b (diff)
Fix a crash
bug:4139931 Change-Id: Ifc18f964d5aedb268eb0d5fa08db3ffed1de4ff8
Diffstat (limited to 'core/java/android/webkit/HTML5VideoView.java')
-rw-r--r--core/java/android/webkit/HTML5VideoView.java21
1 files changed, 15 insertions, 6 deletions
diff --git a/core/java/android/webkit/HTML5VideoView.java b/core/java/android/webkit/HTML5VideoView.java
index b9d55e07d62b..cd2264c41342 100644
--- a/core/java/android/webkit/HTML5VideoView.java
+++ b/core/java/android/webkit/HTML5VideoView.java
@@ -68,6 +68,14 @@ public class HTML5VideoView implements MediaPlayer.OnPreparedListener{
// common Video control FUNCTIONS:
public void start() {
if (mCurrentState == STATE_PREPARED) {
+ // When replaying the same video, there is no onPrepared call.
+ // Therefore, the timer should be set up here.
+ if (mTimer == null)
+ {
+ mTimer = new Timer();
+ mTimer.schedule(new TimeupdateTask(mProxy), TIMEUPDATE_PERIOD,
+ TIMEUPDATE_PERIOD);
+ }
mPlayer.start();
}
}
@@ -76,8 +84,12 @@ public class HTML5VideoView implements MediaPlayer.OnPreparedListener{
if (mCurrentState == STATE_PREPARED && mPlayer.isPlaying()) {
mPlayer.pause();
}
+
+ // Delete the Timer to stop it since there is no stop call.
if (mTimer != null) {
mTimer.purge();
+ mTimer.cancel();
+ mTimer = null;
}
}
@@ -129,6 +141,7 @@ public class HTML5VideoView implements MediaPlayer.OnPreparedListener{
mVideoLayerId = videoLayerId;
mSaveSeekTime = position;
mAutostart = autoStart;
+ mTimer = null;
}
protected HTML5VideoView() {
@@ -153,8 +166,6 @@ public class HTML5VideoView implements MediaPlayer.OnPreparedListener{
// When switching players, surface texture will be reused.
mUri = uri;
mHeaders = generateHeaders(uri, proxy);
-
- mTimer = new Timer();
}
// Listeners setup FUNCTIONS:
@@ -228,11 +239,9 @@ public class HTML5VideoView implements MediaPlayer.OnPreparedListener{
public void onPrepared(MediaPlayer mp) {
mCurrentState = STATE_PREPARED;
seekTo(mSaveSeekTime);
- if (mProxy != null)
+ if (mProxy != null) {
mProxy.onPrepared(mp);
-
- mTimer.schedule(new TimeupdateTask(mProxy), TIMEUPDATE_PERIOD, TIMEUPDATE_PERIOD);
-
+ }
}
// Pause the play and update the play/pause button