chaimPaneth / react-native-jw-media-player

React-Native Android/iOS bridge for JWPlayer SDK (https://www.jwplayer.com/)
MIT License
197 stars 92 forks source link

[Ask] Casting Icon visibility for Android #357

Open fdobre opened 6 months ago

fdobre commented 6 months ago

I would need to hide the casting icon for Android without removing totally the casting dependencies because they are used by another player. Is there any option to do that?

Any response will be greatly appreciated.

Thank you!

fdobre commented 4 months ago

I was able to hide the cast icon and add an error code for Android by adding a patch:

diff --git a/node_modules/react-native-jw-media-player/android/src/main/java/com/appgoalz/rnjwplayer/RNJWPlayerView.java b/node_modules/react-native-jw-media-player/android/src/main/java/com/appgoalz/rnjwplayer/RNJWPlayerView.java
index 45ec30a..3e609f3 100755
--- a/node_modules/react-native-jw-media-player/android/src/main/java/com/appgoalz/rnjwplayer/RNJWPlayerView.java
+++ b/node_modules/react-native-jw-media-player/android/src/main/java/com/appgoalz/rnjwplayer/RNJWPlayerView.java
@@ -747,6 +747,14 @@ public class RNJWPlayerView extends RelativeLayout implements
             }
         }

+        if (prop.hasKey("hideCastIcon")) {
+            boolean hideCastIcon = prop.getBoolean("hideCastIcon");
+            if(hideCastIcon) {
+                View castView = findViewById(R.id.center_cast_img);
+                castView.setLayoutParams(new LayoutParams(0,0));
+            }
+        }
+
         if (mColors != null) {
             if (mColors.hasKey("backgroundColor")) {
                 mPlayerView.setBackgroundColor(Color.parseColor("#" + mColors.getString("backgroundColor")));
@@ -1207,6 +1215,7 @@ public class RNJWPlayerView extends RelativeLayout implements
         if (ex != null) {
             event.putString("error", ex.toString());
             event.putString("description",  errorEvent.getMessage());
+            event.putString("code",  String.valueOf(errorEvent.getErrorCode()));
         }
         getReactContext().getJSModule(RCTEventEmitter.class).receiveEvent(getId(), "topPlayerError", event);