I have a simple layout with one FrameLayout to display fullscreen video and a WebView:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<FrameLayout
android:id="@+id/frameLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal" >
</FrameLayout>
<WebView
android:id="@+id/webView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true" />
WebView displays simple html5 page with video defined.
Body of onShowCustomView is:
@Override
public void onShowCustomView(View view, CustomViewCallback callback) {
super.onShowCustomView(view, callback);
FrameLayout frameLayout = (FrameLayout) findViewById(R.id.frameLayout);
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.FILL_PARENT, Gravity.CENTER);
frameLayout.removeAllViews();
frameLayout.addView(view, layoutParams);
frameLayout.setVisibility(View.VISIBLE);
}
How can I get access to video object from onShowCustomView? When I try to get focused child of framelayout and cast it to a VideoView I get an ClassCastException (I have a HTML5VideoFullScreen object there).
Please help.
I've been noticing that starting with Ice Cream Sandwich (Android 4.0), a VideoView isn't used for video playback. There's new objects like the HTML5VideoFullScreen you mentioned, which have their own MediaPlayers instead of using the default VideoView.
Why do you need the VideoView?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With