tanguyantoine/react-native-music-control

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

Closed this issue · 1 comments

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
  1. Device
  • Simulator
  • [x ] Real device

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,
      });
    });