tanguyantoine / react-native-music-control

Display and manage media controls on lock screen and notification center for iOS and Android.
https://www.npmjs.com/package/react-native-music-control
MIT License
697 stars 264 forks source link

Calling Music.stopControl() on Android before setNowPlaying causes null reference crash #380

Closed goleary closed 3 years ago

goleary commented 3 years ago
Attempt to invoke virtual method 'android.app.Notification com.tanguyantoine.react.MusicControlNotification.prepareNotification(androidx.core.app.NotificationCompat$Builder, boolean)' on a null object reference

Description

  1. Sample code (provide repo url or sample code)

Will try to provide a minimal repro later.

  1. Platform ?

    • [ ] iOS
    • [x] Android (api 29)
3. Device - [x] Simulator - [ ] Real device
PupoSDC commented 3 years ago

Is it possible you are calling MusicControl.handleAudioInterruptions(true);? This call only works on ios and causes a crash in android.

goleary commented 3 years ago

We are not using that method, thanks for the tip though!

PupoSDC commented 3 years ago

Maybe you can share your setup?

The README says:

Make sure when you call MusicControl.resetNowPlaying() and MusicControl.stopControl() you must have controls enabled otherwise it will create issues

So doing what you describe in the title isn't exactly recommended. But i personally have not had issues with this so far.

goleary commented 3 years ago

Interesting, I never noticed that. I'm going to go ahead and close this because I don't have time to dig in further at the moment & because this is called out in the readme.