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

Music controls not shown in background on iOS #338

Closed
2 of 4 tasks
pascaljung opened this issue Jul 21, 2020 · 3 comments
Closed
2 of 4 tasks

Music controls not shown in background on iOS #338

pascaljung opened this issue Jul 21, 2020 · 3 comments

Comments

@pascaljung
Copy link

Description

The music controls are not displayed properly when the app is in the background (app not active or screen locked). As long as the app is active, the title and buttons seem to be placed correctly in the notification area. We did our PoC on iOS, so no clue yet if the issue affects Android as well.

  1. Sample code (provide repo url or sample code)

We installed the MusicControl with yarn. Then pod install in the ios folder.

We use react-native-video for playback. In the player component we do the following

useEffect(() => {
  MusicControl.enableBackgroundMode(true);
  MusicControl.on('play', () => {
  });
  MusicControl.on('pause', () => {
  });
  MusicControl.on('skipBackward', () => {
  });
  MusicControl.on('skipForward', () => {
  });

  MusicControl.enableControl('play', true);
  MusicControl.enableControl('pause', false);
  MusicControl.enableControl('stop', false);
  MusicControl.enableControl('skipBackward', true, { interval: 15 });
  MusicControl.enableControl('skipForward', true, { interval: 15 });
}, []);

Then once we are playing something, we additionally call

MusicControl.setNowPlaying({
  title: state.song.name,
  artwork: state.song.image, // url
  artist: state.song.artist,
  album: state.song.album,
  duration: duration, // (Seconds)
  date: state.song.publishDate, // Release Date (RFC 3339) - Android Only
});

Any idea what we are doing wrong?

  1. Platform ?

    • iOS
    • Android
  2. Device

    • Simulator
    • Real device
@bradfloodx
Copy link
Collaborator

Hmm I know I don't have this problem with my app.
We need to finish the sample app so you have something to compare against.
I'll have a look into it and get back to you. Thanks :)

@pascaljung
Copy link
Author

For some strange reason it works now. I have no clue what changed - maybe my phone just needed a restart. I can't even reproduce the issue... So I'm good with closing it. Thanks anyways :)

@bradfloodx
Copy link
Collaborator

👍

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

2 participants