question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[expo-av][iOS] Lock screen controls not working

See original GitHub issue

🐛 Bug Report

I am using react-native-music-control for lock screen controls when playing audio in background mode. The pause button on the lock screen works, but when play is pressed again, it does not resume playing. When the function that listens to the lock screen play button press runs, it says that there is no active sound session.

A a workaround, having this function: https://github.com/expo/expo/blob/491dde5dedca1a95efa40026aa119a0b0ec2b4e5/packages/expo-av/ios/EXAV/EXAVPlayerData.m#L359 always return true results in the lock screen controls working.

The app I am working on is already in production. Is it safe to use this workaround as a temporary fix to get lock screen controls working?

Environment

Expo CLI 2.17.1 environment info: System: OS: macOS 10.14.4 Shell: 5.3 - /bin/zsh Binaries: Node: 11.10.1 - ~/.nvm/versions/node/v11.10.1/bin/node Yarn: 1.15.2 - /usr/local/bin/yarn npm: 6.7.0 - ~/.nvm/versions/node/v11.10.1/bin/npm Watchman: 4.9.4 - /usr/local/bin/watchman IDEs: Android Studio: 3.4 AI-183.5429.30.34.5452501 Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild npmPackages: react: 16.8.3 => 16.8.3 react-native: 0.59.5 => 0.59.5 react-navigation: 3.9.1 => 3.9.1 npmGlobalPackages: expo-cli: 2.17.1

iOS

Steps to Reproduce

Create new app with bare template -> add react-native-music-control as dependency -> configure MusicControl.on('play', ...) and MusicControl.on('pause', ...) and other required configurations -> play a sound -> whilst sound is playing lock the device -> on the lock screen press pause -> on the lock screen press play, this should print no active sound session… to error log

Expected Behavior

In the section above, the last step should resume the paused sound, rather than printing an error to the log

Actual Behavior

The last step two section above, i.e. printing to the error log that there is no active av session

Reproducible Demo

https://github.com/redpandatronicsuk/expoavtest

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:22 (16 by maintainers)

github_iconTop GitHub Comments

2reactions
brettdhcommented, Jun 20, 2019

Perfect, thank you! I found the wonderful patch-package tool and saved your second patch for now. ✨

0reactions
IjzerenHeincommented, Jul 22, 2020

I’ve been debugging this to see whether we can get this fixed. What I’ve found so far is that with the latest expo-av it doesn’t work because of this check in promoteAudioSessionIfNecessary in EXAM.m:

if (_isBackgrounded && ![_kernelAudioSessionManagerDelegate isActiveForModule:self]) {
  return UMErrorWithMessage(@"This experience is currently in the background, so the audio session could not be activated.");
}

This check does not allow audio to be played when the app is in the background. When disabling this check it starts working though. Nevertheless this check serves a purpose and we cannot just disable it. More research and a solid approach for triggering audio in the background is needed. To be continued…

Read more comments on GitHub >

github_iconTop Results From Across the Web

EXPO-AV - player controlls in lockscreen - #2 by adamjnav
Start using react-native-music-control in your project by running `npm i react-native-music-control`. There are 5 other projects in the npm...
Read more >
[expo-av][iOS] Lock screen controls not working - Bountysource
I am using react-native-music-control for lock screen controls when playing audio in background mode. The pause button on the lock screen ...
Read more >
ios - React-Native: expo-screen-orientation lockAsync() not ...
I just started a new React-Native project using Expo. I'm trying to lock the screen orientation to portrait on any device.
Read more >
react-native-music-control | Voters - Expo - Canny
This will allow expo app to display Now playing Info on lockscreen / control center widget and handle control events. This will extend...
Read more >
iOS 16 Live Activities Lock Screen… | Apple Developer Forums
Replies · votes 5. try this: Open your app's Info.plist file and add an entry with the key NSSupportsLiveActivities of type Boolean with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found