Closed PupoSDC closed 2 years ago
I dug quite bit into the code and
RCT_EXPORT_METHOD(resetNowPlaying)
{
MPNowPlayingInfoCenter *center = [MPNowPlayingInfoCenter defaultCenter];
center.nowPlayingInfo = nil;
self.artworkUrl = nil;
}
appears to be working as intended. center.nowPlayingInfo = nil
is set correctly, which according to the docs should be sufficient to make the controls disappear:
https://developer.apple.com/documentation/mediaplayer/mpnowplayinginfocenter/1615903-nowplayinginfo
So in the end the answer was hidden in a somewhat cryptic post from 2018:
https://github.com/tanguyantoine/react-native-music-control/issues/135#issuecomment-396554383
You have to change the state of the controls to STOPPED
before closing the controls, otherwise they will not close!
MusicControl.updatePlayback({
state: MusicControl.STATE_STOPPED,
elapsedTime: 0,
});
MusicControl.stopControl();
So in the end the answer was hidden in a somewhat cryptic post from 2018:
You have to change the state of the controls to
STOPPED
before closing the controls, otherwise they will not close!MusicControl.updatePlayback({ state: MusicControl.STATE_STOPPED, elapsedTime: 0, }); MusicControl.stopControl();
Hmm even when setting it's state (literally copy/paste yours) I can't get it to hide the controls 🤔
@leightonkuchel How did you go with this? Is this an iOS issue? or related to our package here?
So in the end the answer was hidden in a somewhat cryptic post from 2018:
You have to change the state of the controls to
STOPPED
before closing the controls, otherwise they will not close!MusicControl.updatePlayback({ state: MusicControl.STATE_STOPPED, elapsedTime: 0, }); MusicControl.stopControl();
didn't work :(
Description
I'm calling
MusicControl.stopControl()
on the clean up fuction ofuseEffect
:but the player persists after this call.
Before the callback:
after the callback:
Platform ?