am 6083f5eb: am 01e3feaf: Merge "Make sure the onended event is dispatched even when the user dismisses the video before it plays to completion." into froyo

Merge commit '6083f5eb1b1ee5bb026c99cb5018f0d3cc5f5ff3' into kraken

* commit '6083f5eb1b1ee5bb026c99cb5018f0d3cc5f5ff3':
  Make sure the onended event is dispatched even when
This commit is contained in:
Andrei Popescu
2010-04-14 12:11:21 -07:00
committed by Android Git Automerger

View File

@@ -132,6 +132,7 @@ class HTML5VideoViewProxy extends Handler
if (mVideoView.isPlaying()) { if (mVideoView.isPlaying()) {
mVideoView.stopPlayback(); mVideoView.stopPlayback();
} }
mCurrentProxy.dispatchOnEnded();
mCurrentProxy = null; mCurrentProxy = null;
mLayout.removeView(mVideoView); mLayout.removeView(mVideoView);
mVideoView = null; mVideoView = null;
@@ -154,7 +155,7 @@ class HTML5VideoViewProxy extends Handler
if (mCurrentProxy != null) { if (mCurrentProxy != null) {
// Some other video is already playing. Notify the caller that its playback ended. // Some other video is already playing. Notify the caller that its playback ended.
proxy.playbackEnded(); proxy.dispatchOnEnded();
return; return;
} }
@@ -245,7 +246,10 @@ class HTML5VideoViewProxy extends Handler
// MediaPlayer.OnCompletionListener; // MediaPlayer.OnCompletionListener;
public void onCompletion(MediaPlayer mp) { public void onCompletion(MediaPlayer mp) {
playbackEnded(); // The video ended by itself, so we need to
// send a message to the UI thread to dismiss
// the video view and to return to the WebView.
sendMessage(obtainMessage(ENDED));
} }
// MediaPlayer.OnErrorListener // MediaPlayer.OnErrorListener
@@ -254,11 +258,9 @@ class HTML5VideoViewProxy extends Handler
return false; return false;
} }
public void playbackEnded() { public void dispatchOnEnded() {
Message msg = Message.obtain(mWebCoreHandler, ENDED); Message msg = Message.obtain(mWebCoreHandler, ENDED);
mWebCoreHandler.sendMessage(msg); mWebCoreHandler.sendMessage(msg);
// also send a message to ourselves to return to the WebView
sendMessage(obtainMessage(ENDED));
} }
public void onTimeupdate() { public void onTimeupdate() {