ソースを参照

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

Vladimir 4 年 前
コミット
d8acd9086c
共有1 個のファイルを変更した11 個の追加1 個の削除を含む
  1. 11
    1
      android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java

+ 11
- 1
android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java ファイルの表示

642
     if (mAllowsFullscreenVideo) {
642
     if (mAllowsFullscreenVideo) {
643
       int initialRequestedOrientation = reactContext.getCurrentActivity().getRequestedOrientation();
643
       int initialRequestedOrientation = reactContext.getCurrentActivity().getRequestedOrientation();
644
       mWebChromeClient = new RNCWebChromeClient(reactContext, webView) {
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
         @Override
650
         @Override
646
         public void onShowCustomView(View view, CustomViewCallback callback) {
651
         public void onShowCustomView(View view, CustomViewCallback callback) {
647
           if (mVideoView != null) {
652
           if (mVideoView != null) {
694
       if (mWebChromeClient != null) {
699
       if (mWebChromeClient != null) {
695
         mWebChromeClient.onHideCustomView();
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
       webView.setWebChromeClient(mWebChromeClient);
708
       webView.setWebChromeClient(mWebChromeClient);
699
     }
709
     }
700
   }
710
   }