cprcrack / VideoEnabledWebView

Android's WebView and WebChromeClient class extensions that enable fully working HTML5 video support
MIT License
1.05k stars 289 forks source link

blank screen and html video support #33

Open 1reldi opened 6 years ago

1reldi commented 6 years ago

i had a blank screen after i followed the example here . i than noticed that the problem was in "activity_example" where the full screen view was blocking the view , so i added background color transparent so i made this change in "activity_example" : `<RelativeLayout android:id="@+id/videoLayout" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/transparent">

    <!-- View that will be shown while the fullscreen video loads. For example you could include
    a "Loading..." message. However, in this particular example this view is actually defined in
    view_loading_video.xml and inflated programmatically in ExampleActivity.java. The reason for
    this is to keep the main layout (this file) cleaner. -->
    <!-- <View
        android:id="@+id/videoLoading"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:visibility="invisible" /> -->

</RelativeLayout>`

also i had a problem with html5 videos, they couldnt be played ... this happens when video is in a div, so you should add these lines in your "ExampleActivity.java" before you call "webView.loadUrl("m.youtube.com")": webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setMediaPlaybackRequiresUserGesture(false); webView.getSettings().setDomStorageEnabled(true); webView.getSettings().setAppCacheEnabled(true); webView.getSettings().setAppCachePath(getApplicationContext().getFilesDir().getAbsolutePath() + "/cache"); webView.getSettings().setDatabaseEnabled(true); webView.getSettings().setDatabasePath(getApplicationContext().getFilesDir().getAbsolutePath() + "/databases"); webView.loadUrl("m.youtube.com"); i hope this helps anyone with those problems