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

[Video] More tweaks to AVAudioSession options #4910

Merged
merged 3 commits into from
Aug 9, 2024

Conversation

haileyok
Copy link
Contributor

@haileyok haileyok commented Aug 9, 2024

Why

Upon doing some documentation digging, it looks like we might actually want to be tweaking the category itself from ambient to playback depending on what state we are in.

How

First, it looks like we want to take our app out of the default state, which is soloAmbient. This is described as

Your audio is silenced by screen locking and by the Silent switch (called the Ring/Silent switch on iPhone).

By default, using this category implies that your app’s audio is nonmixable—activating your session will interrupt any other audio sessions which are also nonmixable. To allow mixing, use the ambient category instead.
(https://developer.apple.com/documentation/avfaudio/avaudiosession/category/1616488-soloambient)

And the ambient category is described as

This category is also appropriate for “play-along” apps, such as a virtual piano that a user plays while the Music app is playing. When you use this category, audio from other apps mixes with your audio. Screen locking and the Silent switch (on iPhone, the Ring/Silent switch) silence your audio.
(https://developer.apple.com/documentation/avfaudio/avaudiosession/category/1616560-ambient)

Finally, whenever we want for audio to take over - without background audio - we should switch to playback. We want this because video audio should play whenever the user enables it - regardless of their silent mode.

When using this category, your app audio continues with the Silent switch set to silent or when the screen locks. (The switch is called the Ring/Silent switch on iPhone.) To continue playing audio when your app transitions to the background (for example, when the screen locks), add the audio value to the UIBackgroundModes key in your information property list file.

Note that this might have implications as described here on what happens when the app transitions to the background, however, I believe that AVPlayer should handle those cases. We will need to see what happens on device.

I don't believe that this will account for restarting of background audio whenever the user exits full screen for a video. I'll investigate that with a separate PR.

Test Plan

More changes that are hard to test in simulator here. We should see what happens whenever the TestFlight app updates. I expect we will want to tweak more.

Copy link

render bot commented Aug 9, 2024

Copy link

github-actions bot commented Aug 9, 2024

The Pull Request introduced fingerprint changes against the base commit:

Fingerprint diff
[{"type":"dir","filePath":"modules/expo-bluesky-swiss-army/ios","reasons":["expoAutolinkingIos"],"hash":"dda0fa60c17696961bb5362235688a1b7dc4a167"}]

Generated by PR labeler 🤖

Copy link

github-actions bot commented Aug 9, 2024

Old size New size Diff
7.09 MB 7.09 MB 143 B (0.00%)

@haileyok haileyok merged commit 5bfe5aa into main Aug 9, 2024
6 checks passed
@haileyok haileyok deleted the hailey/more-audio-category branch August 9, 2024 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants