am fd49faae: Merge change 25772 into eclair
Merge commit 'fd49faae33dc813c93347d1bcc8fa7c4fa0ae55d' into eclair-plus-aosp * commit 'fd49faae33dc813c93347d1bcc8fa7c4fa0ae55d': Add progress view and default poster for the <video> implementation
This commit is contained in:
@@ -36,10 +36,12 @@ import android.os.Looper;
|
|||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
|
import android.view.Gravity;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.webkit.ViewManager.ChildView;
|
import android.webkit.ViewManager.ChildView;
|
||||||
import android.widget.AbsoluteLayout;
|
import android.widget.AbsoluteLayout;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.MediaController;
|
import android.widget.MediaController;
|
||||||
import android.widget.VideoView;
|
import android.widget.VideoView;
|
||||||
@@ -90,6 +92,10 @@ class HTML5VideoViewProxy extends Handler
|
|||||||
// The VideoView instance. This is a singleton for now, at least until
|
// The VideoView instance. This is a singleton for now, at least until
|
||||||
// http://b/issue?id=1973663 is fixed.
|
// http://b/issue?id=1973663 is fixed.
|
||||||
private static VideoView mVideoView;
|
private static VideoView mVideoView;
|
||||||
|
// The progress view.
|
||||||
|
private static View mProgressView;
|
||||||
|
// The container for the progress view and video view
|
||||||
|
private static FrameLayout mLayout;
|
||||||
|
|
||||||
private static final WebChromeClient.CustomViewCallback mCallback =
|
private static final WebChromeClient.CustomViewCallback mCallback =
|
||||||
new WebChromeClient.CustomViewCallback() {
|
new WebChromeClient.CustomViewCallback() {
|
||||||
@@ -101,7 +107,13 @@ class HTML5VideoViewProxy extends Handler
|
|||||||
// is invoked.
|
// is invoked.
|
||||||
mCurrentProxy.playbackEnded();
|
mCurrentProxy.playbackEnded();
|
||||||
mCurrentProxy = null;
|
mCurrentProxy = null;
|
||||||
|
mLayout.removeView(mVideoView);
|
||||||
mVideoView = null;
|
mVideoView = null;
|
||||||
|
if (mProgressView != null) {
|
||||||
|
mLayout.removeView(mProgressView);
|
||||||
|
mProgressView = null;
|
||||||
|
}
|
||||||
|
mLayout = null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -113,6 +125,13 @@ class HTML5VideoViewProxy extends Handler
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mCurrentProxy = proxy;
|
mCurrentProxy = proxy;
|
||||||
|
// Create a FrameLayout that will contain the VideoView and the
|
||||||
|
// progress view (if any).
|
||||||
|
mLayout = new FrameLayout(proxy.getContext());
|
||||||
|
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
|
||||||
|
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||||
|
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||||
|
Gravity.CENTER);
|
||||||
mVideoView = new VideoView(proxy.getContext());
|
mVideoView = new VideoView(proxy.getContext());
|
||||||
mVideoView.setWillNotDraw(false);
|
mVideoView.setWillNotDraw(false);
|
||||||
mVideoView.setMediaController(new MediaController(proxy.getContext()));
|
mVideoView.setMediaController(new MediaController(proxy.getContext()));
|
||||||
@@ -120,8 +139,15 @@ class HTML5VideoViewProxy extends Handler
|
|||||||
mVideoView.setOnCompletionListener(proxy);
|
mVideoView.setOnCompletionListener(proxy);
|
||||||
mVideoView.setOnPreparedListener(proxy);
|
mVideoView.setOnPreparedListener(proxy);
|
||||||
mVideoView.seekTo(time);
|
mVideoView.seekTo(time);
|
||||||
|
mLayout.addView(mVideoView, layoutParams);
|
||||||
|
mProgressView = client.getVideoLoadingProgressView();
|
||||||
|
if (mProgressView != null) {
|
||||||
|
mLayout.addView(mProgressView, layoutParams);
|
||||||
|
mProgressView.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
mLayout.setVisibility(View.VISIBLE);
|
||||||
mVideoView.start();
|
mVideoView.start();
|
||||||
client.onShowCustomView(mVideoView, mCallback);
|
client.onShowCustomView(mLayout, mCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void seek(int time, HTML5VideoViewProxy proxy) {
|
public static void seek(int time, HTML5VideoViewProxy proxy) {
|
||||||
@@ -135,11 +161,20 @@ class HTML5VideoViewProxy extends Handler
|
|||||||
mVideoView.pause();
|
mVideoView.pause();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void onPrepared() {
|
||||||
|
if (mProgressView != null) {
|
||||||
|
mProgressView.setVisibility(View.GONE);
|
||||||
|
mLayout.removeView(mProgressView);
|
||||||
|
mProgressView = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// A bunch event listeners for our VideoView
|
// A bunch event listeners for our VideoView
|
||||||
// MediaPlayer.OnPreparedListener
|
// MediaPlayer.OnPreparedListener
|
||||||
public void onPrepared(MediaPlayer mp) {
|
public void onPrepared(MediaPlayer mp) {
|
||||||
|
VideoPlayer.onPrepared();
|
||||||
Message msg = Message.obtain(mWebCoreHandler, PREPARED);
|
Message msg = Message.obtain(mWebCoreHandler, PREPARED);
|
||||||
Map<String, Object> map = new HashMap<String, Object>();
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
map.put("dur", new Integer(mp.getDuration()));
|
map.put("dur", new Integer(mp.getDuration()));
|
||||||
@@ -166,6 +201,13 @@ class HTML5VideoViewProxy extends Handler
|
|||||||
switch (msg.what) {
|
switch (msg.what) {
|
||||||
case INIT: {
|
case INIT: {
|
||||||
mPosterView = new ImageView(mWebView.getContext());
|
mPosterView = new ImageView(mWebView.getContext());
|
||||||
|
WebChromeClient client = mWebView.getWebChromeClient();
|
||||||
|
if (client != null) {
|
||||||
|
Bitmap poster = client.getDefaultVideoPoster();
|
||||||
|
if (poster != null) {
|
||||||
|
mPosterView.setImageBitmap(poster);
|
||||||
|
}
|
||||||
|
}
|
||||||
mChildView.mView = mPosterView;
|
mChildView.mView = mPosterView;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -273,4 +273,26 @@ public class WebChromeClient {
|
|||||||
* @hide pending API council.
|
* @hide pending API council.
|
||||||
*/
|
*/
|
||||||
public void addMessageToConsole(String message, int lineNumber, String sourceID) {}
|
public void addMessageToConsole(String message, int lineNumber, String sourceID) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ask the host application for an icon to represent a <video> element.
|
||||||
|
* This icon will be used if the Web page did not specify a poster attribute.
|
||||||
|
*
|
||||||
|
* @return Bitmap The icon or null if no such icon is available.
|
||||||
|
* @hide pending API Council approval
|
||||||
|
*/
|
||||||
|
public Bitmap getDefaultVideoPoster() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ask the host application for a custom progress view to show while
|
||||||
|
* a <video> is loading.
|
||||||
|
*
|
||||||
|
* @return View The progress view.
|
||||||
|
* @hide pending API Council approval
|
||||||
|
*/
|
||||||
|
public View getVideoLoadingProgressView() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user