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
695 stars 265 forks source link

MusicControl.enableControl('pause', true) Don't show pause icon on notification #355

Closed Joshmatjjen closed 4 years ago

Joshmatjjen commented 4 years ago

Description

  1. MusicControl.enableBackgroundMode(true); MusicControl.setNowPlaying({ title: title, artwork: image, // URL or RN's image require() artist: author, album: album, genre: 'Post-disco, Rhythm and Blues, Funk, Dance-pop', duration: state.duration, // (Seconds) description: '', // Android Only color: 0xffffff, // Notification Color - Android Only date: '1983-01-02T00:00:00Z', // Release Date (RFC 3339) - Android Only rating: 84, // Android Only (Boolean or Number depending on the type) notificationIcon: 'src_assets_icon_logo', // Android Only (String), Android Drawable resource name for a custom notification icon }); MusicControl.enableControl('play', true); MusicControl.enableControl('pause', true);
  1. Platform ?

    • [ ] iOS
    • [x ] Android
3. Device - [ ] Simulator - [x ] Real device
Joshmatjjen commented 4 years ago

Fix it with this implementation

MusicControl.on('play', () => {
      setState({ ...state, play: true });
      setTimeout(() => setState((s) => ({ ...s, showControls: false })), 1500);
      MusicControl.updatePlayback({
        state: MusicControl.STATE_PLAYING,
      });
    });

    MusicControl.on('pause', () => {
      setState({ ...state, play: false, showControls: true });
      MusicControl.updatePlayback({
        state: MusicControl.STATE_PAUSED,
      });
    });