フルスクリーン ビデオと WebView を表示する 1 つの FrameLayout を持つ単純なレイアウトがあります。
<?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 は、ビデオが定義された単純な html5 ページを表示します。
onShowCustomView の本体は次のとおりです。
@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);
}
onShowCustomView からビデオ オブジェクトにアクセスするにはどうすればよいですか? framelayout のフォーカスされた子を取得して VideoView にキャストしようとすると、ClassCastException が発生します (そこに HTML5VideoFullScreen オブジェクトがあります)。
助けてください。