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

MusicControl.updatePlayback({ state: _}) Does Not Work. Playback State Doesn't Change. #395

Open franekantoni opened 2 years ago

franekantoni commented 2 years ago

Description

I am using react-native-music-control to pause/play react-native-video player when app is in the background. Controls work fine when app is in the background (the 'pause', 'play' events get handled), but I am unable to change the MusicControl state with tha updatePlayback method-> the icon of music control does not change when MusicControl.updatePlayback gets called. All parts of pausePodcast, playPodcast functions shown below work properly, elapsedTime gets updated, but the MusicControl state does not change. I am running my app on iphone xs ios 14.2

  1. Sample code (provide repo url or sample code)
pausePodcast = () => {
        ReactNativeHapticFeedback.trigger("impactLight", {enableVibrateFallback: true, ignoreAndroidSystemSettings: false})
        this.setState({
            paused: true
        })
        MusicControl.updatePlayback({
          state: MusicControl.STATE_PAUSED,
          elapsedTime: this.state.currentTime,
        })
    }

playPodcast = () => {
        ReactNativeHapticFeedback.trigger("impactLight", {enableVibrateFallback: true, ignoreAndroidSystemSettings: false})
        this.setState({
            paused: false
        })
        MusicControl.updatePlayback({
          state: MusicControl.STATE_PLAYING,
          elapsedTime: this.state.currentTime,
        })
    }
  1. Platform ?

    • [x] iOS
    • [ ] Android
  2. Device

    • [ ] Simulator
    • [x] Real device