Skip to content
This repository was archived by the owner on Oct 6, 2022. It is now read-only.

ios controls persist after calling MusicControl.stopControl #376

Closed
2 of 4 tasks
PupoSDC opened this issue Mar 2, 2021 · 5 comments
Closed
2 of 4 tasks

ios controls persist after calling MusicControl.stopControl #376

PupoSDC opened this issue Mar 2, 2021 · 5 comments

Comments

@PupoSDC
Copy link

PupoSDC commented Mar 2, 2021

Description

I'm calling MusicControl.stopControl() on the clean up fuction of useEffect:

 useEffect(() => () => {
   MusicControl.stopControl();
 });

but the player persists after this call.

Before the callback:

image

after the callback:

image

  1. Platform ?

    • iOS
    • Android
  1. Device
  • Simulator
  • Real device
@PupoSDC
Copy link
Author

PupoSDC commented Mar 8, 2021

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

@PupoSDC
Copy link
Author

PupoSDC commented Mar 8, 2021

So in the end the answer was hidden in a somewhat cryptic post from 2018:

#135 (comment)

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();

@leightonkuchel
Copy link

So in the end the answer was hidden in a somewhat cryptic post from 2018:

#135 (comment)

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 🤔

@bradfloodx
Copy link
Collaborator

@leightonkuchel How did you go with this? Is this an iOS issue? or related to our package here?

@AliHaidar110
Copy link

So in the end the answer was hidden in a somewhat cryptic post from 2018:

#135 (comment)

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 :(

@PupoSDC PupoSDC closed this as completed Mar 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants