chaimPaneth / react-native-jw-media-player

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

Android Chromecast Not working since 0.2.35 #314

Open ppark-jwp opened 11 months ago

ppark-jwp commented 11 months ago

Android app crashes when user connects to a Chromecast device when I upgraded the bride from 0.2.34. Tested all versions after 0.2.35 and they all have the same issue regardless of JWP SDK versions and Exoplayer versions.

The app crashes with the following error :

java.lang.IllegalArgumentException: android.content.pm.PackageManager$NameNotFoundException: ComponentInfo{com.samg.media.EmotionCastleCinema/com.appgoalz.rnjwplayer.RNJWPlayerView} at androidx.core.app.TaskStackBuilder.addParentStack(TaskStackBuilder.java:210) at androidx.core.app.TaskStackBuilder.addNextIntentWithParentStack(TaskStackBuilder.java:144) at com.google.android.gms.cast.framework.media.internal.zzo.zzg(com.google.android.gms:play-services-cast-framework@@21.3.0:16) at com.google.android.gms.cast.framework.media.internal.zzo.zzd(com.google.android.gms:play-services-cast-framework@@21.3.0:14) at com.google.android.gms.cast.framework.media.internal.zzv.zzl(com.google.android.gms:play-services-cast-framework@@21.3.0:12) at com.google.android.gms.cast.framework.media.internal.zzu.onStatusUpdated(com.google.android.gms:play-services-cast-framework@@21.3.0:1) at com.google.android.gms.cast.framework.media.zzbn.zzm(com.google.android.gms:play-services-cast-framework@@21.3.0:6) at com.google.android.gms.cast.internal.zzaq.zzY(com.google.android.gms:play-services-cast@@21.3.0:1) at com.google.android.gms.cast.internal.zzaq.zzO(com.google.android.gms:play-services-cast@@21.3.0:61) at com.google.android.gms.cast.framework.media.RemoteMediaClient.onMessageReceived(com.google.android.gms:play-services-cast-framework@@21.3.0:1) at com.google.android.gms.cast.zzbq.run(com.google.android.gms:play-services-cast@@21.3.0:4) at android.os.Handler.handleCallback(Handler.java:942) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:226) at android.os.Looper.loop(Looper.java:313) at android.app.ActivityThread.main(ActivityThread.java:8757) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067) Caused by: android.content.pm.PackageManager$NameNotFoundException: ComponentInfo{com.samg.media.EmotionCastleCinema/com.appgoalz.rnjwplayer.RNJWPlayerView} at android.app.ApplicationPackageManager.getActivityInfo(ApplicationPackageManager.java:616) at android.app.ApplicationPackageManager.getActivityInfo(ApplicationPackageManager.java:599) at androidx.core.app.NavUtils.getParentActivityName(NavUtils.java:261) at androidx.core.app.NavUtils.getParentActivityIntent(NavUtils.java:195) at androidx.core.app.TaskStackBuilder.addParentStack(TaskStackBuilder.java:203) at androidx.core.app.TaskStackBuilder.addNextIntentWithParentStack(TaskStackBuilder.java:144) at com.google.android.gms.cast.framework.media.internal.zzo.zzg(com.google.android.gms:play-services-cast-framework@@21.3.0:16) at com.google.android.gms.cast.framework.media.internal.zzo.zzd(com.google.android.gms:play-services-cast-framework@@21.3.0:14) at com.google.android.gms.cast.framework.media.internal.zzv.zzl(com.google.android.gms:play-services-cast-framework@@21.3.0:12) at com.google.android.gms.cast.framework.media.internal.zzu.onStatusUpdated(com.google.android.gms:play-services-cast-framework@@21.3.0:1) at com.google.android.gms.cast.framework.media.zzbn.zzm(com.google.android.gms:play-services-cast-framework@@21.3.0:6) at com.google.android.gms.cast.internal.zzaq.zzY(com.google.android.gms:play-services-cast@@21.3.0:1) at com.google.android.gms.cast.internal.zzaq.zzO(com.google.android.gms:play-services-cast@@21.3.0:61) at com.google.android.gms.cast.framework.media.RemoteMediaClient.onMessageReceived(com.google.android.gms:play-services-cast-framework@@21.3.0:1) at com.google.android.gms.cast.zzbq.run(com.google.android.gms:play-services-cast@@21.3.0:4) at android.os.Handler.handleCallback(Handler.java:942) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:226) at android.os.Looper.loop(Looper.java:313) at android.app.ActivityThread.main(ActivityThread.java:8757) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)

DishOtt commented 11 months ago

same issue, any one version that work properly ?

jmurth1234 commented 10 months ago

I'm also getting this -- seems to be related to upgrading the chromecast library but unsure how to resolve

grigdodon commented 8 months ago

anyone managed to find a solution? maybe created a patch to remove JWPlayer's chromecasting so google cast can be implemented?

BadassBeth commented 7 months ago

I've recently being getting this same issue :( has anyone been able to resolve yet?

SufianBabri commented 6 months ago

I am using react-native-google-cast for the chromecast functionality in the app I'm currently working on.

To disable the Chromecasting functionality of this library, I use one of the patches (I'm the author of these patches). Please pick the one that uses the same version you've installed.

I encountered this issue with Chromecast for which I had to move to the google-cast library. Nonetheless, the developer of this JW Player library has been a great help to the community, always working to resolve bugs and keeping the library up to date.

Jmilham21 commented 5 months ago

This issue is related to how the module is wrapped inside the application. This is causing bad package signatures to be registered with the casting framework, as seen from the top of the provided stack trace ComponentInfo{com.samg.media.EmotionCastleCinema/com.appgoalz.rnjwplayer.RNJWPlayerView}

Notice the component is referencing your application/the module's signature. This is no longer valid in the casting framework and newer versions of Android. I can't determine which version, but the current version of this wrapper works on Android 7, but does not work on Android 11+.

My proposed solution is seen in this branch. The approach is to move the casting framework registration to your application, and don't have the module do it for you any longer. This will also give you a more hands-on approach to controlling the CastOptionsProvider class, which determines the receiver ID, notification styling, and many more options. This is more in line with how the JW Android SDK works.

It is an option to eject the JW cast module and use the react-native-google-cast as described by @SufianBabri. It will come down to what works best for you.

For note, I am a JW Android SDK engineer, but I am not a master of React Native. Please take my suggestion with salt.

Jmilham21 commented 5 months ago

Updated the above PR to resolve a session ID issue between the sender and receiver.

tara-singh-danu commented 5 months ago

Facing the same issue on 0.2.39 as well as on the latest 0.2.44 @chaimPaneth

tara-singh-danu commented 5 months ago

Any update? @chaimPaneth

tara-singh-danu commented 5 months ago

The app is not crashing but Chromecast is not casting video in version 0.2.35 also. @chaimPaneth

SufianBabri commented 4 months ago

@tara-singh-danu in case of Android, please make sure you've made these changes:

  1. removed this from android/build.gradle: implementation 'com.google.android.gms:play-services-cast-framework:21.0.1'
  2. removed the following from android/src/main/AndroidManifest.xml
  3. removed the file CastOptionsProvider.java
tara-singh-danu commented 4 months ago

@SufianBabri I passed hideUIGroups: ['casting_menu'] in the jwplayer config and the chromecast icon got removed. But the chromecast is not working smoothly on android, sometimes it hangs the phone.

SufianBabri commented 4 months ago

@tara-singh-danu to disable chromecast on Android, you need to apply relevant patch of the library (it will remove chromecast dependencies and disable it for Android). For iOS it has an additional step which it appears you've already followed.

These are hopefully all the steps you need to take:

  1. Add these lines to the "scripts" of your package.json (you may need to slightly modify if not using yarn):
    "create-patch": "npx --yes patch-package --exclude 'build/|xcodeproj'",
    "postinstall": "npx --yes patch-package"
  2. Download and place the patch file (pick the patch that is for the library version you've installed)
  3. For iOS, jwPlayer.current?.setVisibility(false, ['chromecast']); has to be added which you say you've already done
  4. Run npm install or yarn install
  5. Install the app again (you may need to kill Metro if the app isn't working as expected).
tara-singh-danu commented 4 months ago

The solution is not working properly, it hangs the device