WebChromeClient-全屏视图是黑色的声音

时间:2018-11-23 05:40:36

标签: c# android xamarin

一段时间以来,我一直在尝试解决此问题,但我不知道出了什么问题。

我有一个“ WebView”,如下所示

webView = FindViewById<WebView>(Resource.Id.thebrowserWebViewRss);
LinearLayout MainView = FindViewById<LinearLayout>(Resource.Id.rootviewRFeedbrwoser);
NestedScrollView ContentLayout = FindViewById<NestedScrollView>(Resource.Id.thebrowserScrollerViewRss);
FullScreenClient fullScreenClient = new FullScreenClient(MainView, ContentLayout)
{
 ParentActivity = this
};
webView.SetWebChromeClient(fullScreenClient);    
webView.Settings.JavaScriptEnabled = true;
webView.Settings.LoadWithOverviewMode = true;

以下是我的FullScreenClient

     public class FullScreenClient : WebChromeClient
            {
                readonly FrameLayout.LayoutParams matchParentLayout = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent,
                                                                                                        ViewGroup.LayoutParams.MatchParent);
                readonly ViewGroup content;
                readonly ViewGroup parent;
                View customView;
                int counter = 0;            


                public WebBroswerRSS ParentActivity;

  public FullScreenClient(ViewGroup parentview, ViewGroup contentview)
                {
                    this.parent = parentview;
                    this.content = contentview;               
                }

    public override void OnShowCustomView(View view, ICustomViewCallback callback)
                {
                    customView = view;
                    view.LayoutParameters = matchParentLayout;
                    parent.AddView(view);               
                }

                public override void OnHideCustomView()
                {
                    content.Visibility = ViewStates.Visible;
                    parent.RemoveView(customView);
                    customView = null;
                }

            }

尽管我在任何视频上单击全屏时,它都可以正常运行,但全黑,但全屏。我可以在后台听到视频声音,但看不到视频。

知道我在做什么错吗?

这是我的Web浏览器的XML

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:focusableInTouchMode="true"
    android:id="@+id/rootviewRFeedbrwoser"
              android:background="#ffffff">
  <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="0dp"
        android:orientation="horizontal">
      <LinearLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_weight="1"
          android:orientation="vertical">
<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"    
    android:orientation="horizontal"
    android:weightSum="3">

    <ImageView
        android:id="@+id/closer"
        android:layout_width="30dp"
        android:layout_height="30dp"
        android:layout_alignParentLeft="true"
        android:layout_marginStart="5dp"
        android:layout_marginTop="5dp"
      android:layout_marginLeft="10dp"
    android:padding="5dp"
        android:src="@drawable/ic_left_arrow_black" /> 
  <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentEnd="true">   
    <ImageView
        android:id="@+id/sharingIt"
              android:layout_width="35dp"
     android:layout_height="35dp"
                android:src="@drawable/ic_share"
                android:layout_gravity="right"
                 android:tint="#6E6E6E"
              android:layout_marginRight="10dp"
                android:padding="8dp"
                 />    
    </LinearLayout> 
</RelativeLayout>
<android.support.v4.widget.NestedScrollView
        android:id="@+id/thebrowserScrollerViewRss"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fillViewport="true"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">
        <WebView
            android:id="@+id/thebrowserWebViewRss"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="0dp"
            android:layout_marginRight="0dp" />
    </android.support.v4.widget.NestedScrollView>
      </LinearLayout>
    </LinearLayout>
  </LinearLayout>
</LinearLayout>

0 个答案:

没有答案