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

Problems with updatePlayback #412

Open antonkoetzler opened 1 year ago

antonkoetzler commented 1 year ago
  1. Sample code (provide repo url or sample code)

    // Code used to init MusicControl
    export async function initNotification(path) {
    MusicControl.stopControl();
    
    MusicControl.enableBackgroundMode(true);
    MusicControl.enableControl("play", true);
    MusicControl.enableControl("pause", true);
    MusicControl.enableControl("stop", true);
    MusicControl.enableControl("nextTrack", true);
    MusicControl.enableControl("previousTrack", true);
    MusicControl.enableControl("changePlaybackPosition", false);
    MusicControl.enableControl("seekForward", false);
    MusicControl.enableControl("seekBackward", false);
    MusicControl.enableControl("seek", false);
    MusicControl.enableControl("skipForward", false);
    MusicControl.enableControl("skipBackward", false);
    MusicControl.enableControl("setRating", false);
    MusicControl.enableControl("volume", false);
    MusicControl.enableControl("remoteVolume", false);
    MusicControl.enableControl("enableLanguageOption", false);
    MusicControl.enableControl("disableLanguageOption", false);
    
    let name = null;
    for (var i = (path.length - 1); i >= 0; i--) {
    if (path[i] == '/') {
      name = path.substr(i + 1);
      name = name.substr(0, name.length - 4);
    }
    }
    
    MusicControl.setNowPlaying({
    title: name,
    artwork: require("./DefaultAlbumCover.png"),
    artist: "",
    album: "",
    genre: "",
    description: "",
    color: 0x7393b3,
    colorized: true,
    date: "",
    isLiveStream: false
    });
    
    MusicControl.on(Command.previousTrack, previousSong);
    MusicControl.on(Command.play, () => { toggleNotificationPlay(); });
    MusicControl.on(Command.pause, () => { toggleNotificationPlay(); });
    MusicControl.on(Command.nextTrack, nextSong);
    }

Whenever I call MusicControl.updatePlayback, it never actually changes anything in the notification. As well, using the notification buttons when the app is in the background never changes the text of the notification.

  1. Platform ? ~ Android
4. Device ~ Simulator