Kaynağa Gözat

fix(android): Added fallback poster image to prevent crashes (#1036)

Vladimir 5 yıl önce
ebeveyn
işleme
d8acd9086c

+ 11
- 1
android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java Dosyayı Görüntüle

@@ -642,6 +642,11 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
642 642
     if (mAllowsFullscreenVideo) {
643 643
       int initialRequestedOrientation = reactContext.getCurrentActivity().getRequestedOrientation();
644 644
       mWebChromeClient = new RNCWebChromeClient(reactContext, webView) {
645
+        @Override
646
+        public Bitmap getDefaultVideoPoster() {
647
+          return Bitmap.createBitmap(50, 50, Bitmap.Config.ARGB_8888);
648
+        }
649
+        
645 650
         @Override
646 651
         public void onShowCustomView(View view, CustomViewCallback callback) {
647 652
           if (mVideoView != null) {
@@ -694,7 +699,12 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
694 699
       if (mWebChromeClient != null) {
695 700
         mWebChromeClient.onHideCustomView();
696 701
       }
697
-      mWebChromeClient = new RNCWebChromeClient(reactContext, webView);
702
+      mWebChromeClient = new RNCWebChromeClient(reactContext, webView) {
703
+        @Override
704
+        public Bitmap getDefaultVideoPoster() {
705
+          return Bitmap.createBitmap(50, 50, Bitmap.Config.ARGB_8888);
706
+        }
707
+      };
698 708
       webView.setWebChromeClient(mWebChromeClient);
699 709
     }
700 710
   }