Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[expo-av] Allow audio playback/recording when the app is in background #3498

Merged
merged 10 commits into from Mar 22, 2019

Conversation

Projects
None yet
@sjchmiela
Copy link
Contributor

commented Feb 12, 2019

Why

Closes #3304. Also, somehow moves https://expo.canny.io/feature-requests/p/audio-playback-in-background forward (however, I would consider this canny request a bit broader than just allowing this functionality).

How

Following suggestion found in #3304 by @redpandatronicsuk I implemented a way to disable pausing of all AV objects when the app goes into background.

Test Plan

Tested on NCL. With audio background mode enabled and setAudioMode called with staysActiveInBackgroundIOS playback and recordings continue in background.

@sjchmiela sjchmiela requested review from ide and tsapeta Feb 12, 2019

@brettdh

This comment has been minimized.

Copy link

commented Feb 20, 2019

This is real exciting to see. Do I understand correctly that the reason that this is iOS-specific is that there's nothing special required on Android to get bg audio working (besides perhaps general backgrounding configuration as released in SDK 32)? Or is there further implementation required to make this work on Android?

It would be great to see a minimal example that works on iOS and Android

Thanks! Looking forward to using this.

@RapsIn4

This comment has been minimized.

Copy link

commented Feb 21, 2019

Excited to see progress on this! Would be great to see both iOS and Android support!

@redpandatronicsuk

This comment has been minimized.

Copy link
Contributor

commented Feb 26, 2019

I think for Android a similar approach can be used. Not sure, but I think the code we want to prevent from being executed when we want to keep audio running when going to background mode is around here:

@sjchmiela

This comment has been minimized.

Copy link
Contributor Author

commented Feb 26, 2019

Thanks, will see!

@sjchmiela sjchmiela force-pushed the @sjchmiela/bg_audio branch from cab6bc0 to a3b64c9 Feb 26, 2019

@tsapeta

tsapeta approved these changes Mar 3, 2019

Copy link
Member

left a comment

👌

@samkuhn

This comment has been minimized.

Copy link

commented Mar 7, 2019

This is great thanks guys. We've been waiting to launch our app but have been unable due to a firm requirement of background audio and have been reluctant to detach from Expo. Hoping there's an easy android patch as well 🤞

@ladigitale

This comment has been minimized.

Copy link

commented Mar 8, 2019

We are 🤞 for Android support.

@yutin1987

This comment has been minimized.

Copy link

commented Mar 17, 2019

if (_isBackgrounded) {
return UMErrorWithMessage(@"This experience is currently in the background, so the audio session could not be activated.");
}

if (_isBackgrounded) { 
   return UMErrorWithMessage(@"This experience is currently in the background, so the audio session could not be activated."); 
 } 

Need to delete it, because new Audio.Sound() and play in background will show error [Error: Play encountered an error: audio session not activated.]

@turbozv

This comment has been minimized.

Copy link

commented Mar 19, 2019

Any update on this PR?

@sjchmiela sjchmiela force-pushed the @sjchmiela/bg_audio branch from a3b64c9 to 10763cb Mar 22, 2019

@sjchmiela sjchmiela force-pushed the @sjchmiela/bg_audio branch from 10763cb to 31e0c5b Mar 22, 2019

@tsapeta tsapeta merged commit 6fcfe9f into master Mar 22, 2019

3 of 4 checks passed

client_shell_app Workflow: client_shell_app
Details
client Workflow: client
Details
docs Workflow: docs
Details
sdk Workflow: sdk
Details

@tsapeta tsapeta deleted the @sjchmiela/bg_audio branch Mar 22, 2019

@tsapeta tsapeta removed the in progress label Mar 22, 2019

@turbozv

This comment has been minimized.

Copy link

commented Mar 22, 2019

Nice! It's merged, thanks guys!

@wilbyang

This comment has been minimized.

Copy link

commented Mar 23, 2019

It's awesome work! How could we use this feature.

@aviggiano

This comment has been minimized.

Copy link

commented Mar 23, 2019

Looking forward to it! Is there a way to use this while still in beta, or not publicly released?

@sjchmiela

This comment has been minimized.

Copy link
Contributor Author

commented Mar 25, 2019

There's no easy way right now, we would have to publish an update to expo-av package and you would have to be either ejected or on bare project to be able to pull the changes.

@jennya

This comment has been minimized.

Copy link

commented Mar 25, 2019

Would love to see an updated expo-av package!

@sjchmiela

This comment has been minimized.

Copy link
Contributor Author

commented Mar 27, 2019

Published expo-av@4.1.0 with this PR included. If trying it out, don't forget to also add proper UIBackgroudMode to the application configuration! 🙂

@eltoob

This comment has been minimized.

Copy link

commented Mar 31, 2019

@sjchmiela do you know if that will make the speech api work in the background?
Also what's the best way to get it to work in my detached expo app?

@sjchmiela sjchmiela referenced this pull request Apr 11, 2019

Closed

fix unused parameter #3939

@james-berry

This comment has been minimized.

Copy link

commented May 9, 2019

any updates on when this gets released? or how to use it?

@ide

This comment has been minimized.

Copy link
Member

commented May 9, 2019

There are two main ways to use the code in this repo:

  • Managed workflow: Wait for the next SDK release. For updates on the SDK releases, follow https://blog.expo.io.
  • Bare workflow: When a unimodule is published on npm, you can try installing it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.