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

iOS + Expo unexpected results #34

Open
OwenMelbz opened this issue Mar 16, 2024 · 3 comments
Open

iOS + Expo unexpected results #34

OwenMelbz opened this issue Mar 16, 2024 · 3 comments

Comments

@OwenMelbz
Copy link

Hi, Sorry this is not a bug as such.

We're using Expo and want:

  • Audio from other apps to continue, e.g. spotify, twitch, youtube, etc.
  • Audio to play from our app even when in silent mode
  • To detect when silent mode is turned off/on

We used expo originally and had it working fine with:

import { Audio } from 'expo-av'

await Audio.setAudioModeAsync({
    allowsRecordingIOS: false,
    staysActiveInBackground: true,
    playsInSilentModeIOS: true,
    shouldDuckAndroid: true,
    interruptionModeIOS: InterruptionModeIOS.DuckOthers,
    interruptionModeAndroid: InterruptionModeAndroid.DuckOthers,
})

We then added the following after the above ^^

await VolumeManager.enable(true, false)
await VolumeManager.enableInSilenceMode(true)

VolumeManager.addSilentListener(({ isMuted }) => {
    setState(isMuted)
})

However this seems to pause all audio from other apps when our app boots.

What would be the correct usage to enable what's mentioned above?

Thanks

@hirbod
Copy link
Owner

hirbod commented Mar 16, 2024

Unfortunately, VolumeManager and expo-av are not compatible without patching expo-av. We had to do the same in our app before we ultimately switched to Amazon IVS Player for React Native.

Expo-av (and some other components like react-native-video) hijack the audio session and forcefully reset it upon foregrounding/backgrounding. When I used expo-av, I had to remove the audio session management by Expo and use my own library to have more granular control over when I set the audio mode and when I clear the listeners.

@OwenMelbz
Copy link
Author

We're not locked into using expo-av, if we were to drop it, how would we replicate the above expo-av settings using this package?

Thanks

@hirbod
Copy link
Owner

hirbod commented Mar 16, 2024

    allowsRecordingIOS: false, // Not implemented in this package
    staysActiveInBackground: true, // This works out-of-the-box if the background music entitlement is active
    playsInSilentModeIOS: true, // There is a method for this in the package
    shouldDuckAndroid: true, // Not implemented in this package
    interruptionModeIOS: InterruptionModeIOS.DuckOthers, // Implemented, check setMode/setCategory
    interruptionModeAndroid: InterruptionModeAndroid.DuckOthers, // Not implemented in this package

Android hasn't been the primary focus in this package yet. I'll try to address the missing features for Android, but my free time is very limited currently. I can't give any ETA, but contributions via pull requests would be greatly appreciated.

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

No branches or pull requests

2 participants