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

[iOS Device] Music controls disabled if video is played in full screen using native iOS controls #372

Open gkuettel opened 3 years ago

gkuettel commented 3 years ago

We're using react-native-video in conjunction with this library to show lock screen controls for videos. Everything works as expected, but we're running into a problem when locking the phone after the video is in full screen mode, and the native iOS controls take over.

Steps to reproduce:

We've tried to call setNowPlaying when full screen is enabled, but that did not resolve the issue.

Screenshot: Lock screen controls working as expected

File (2)

Screenshot: Lock screen controls are greyed out when locking the phone from full screen (native iOS controls)

File (3)


Here's the code that we call when the component mounts:

useEffect(() => {
     Controls.handleAudioInterruptions(true);
    Controls.enableControl("closeNotification", true, { when: "always" });
    Controls.enableBackgroundMode(true);
    Controls.enableControl("play", true);
    Controls.enableControl("pause", true);
    Controls.enableControl("nextTrack", true);
    Controls.enableControl("previousTrack", true);
  }, []);

Here's the code we call when the video instance loads

useEffect(() => {
    Controls.setNowPlaying({
      title,
    });
    Controls.on(Command.play, () => {
      onPressPlay();
    });
    Controls.on(Command.pause, () => {
      onPressPause();
    });
    Controls.on(Command.nextTrack, () => {
      onAdvanceSlide(true);
    });
    Controls.on(Command.previousTrack, () => {
      onAdvanceSlide(false);
    });
  }, [title]);

Platform

Device