react-native-sound icon indicating copy to clipboard operation
react-native-sound copied to clipboard

Sounds playing when iPhone is in silent mode and setCategory('Ambient')

Open DanStevensonDev opened this issue 3 years ago • 3 comments

:beetle: Description

I am trying to play ambient sounds, where they should be muted if the device is in silent mode.

:beetle: What have you tried?

react-native-sounds config is set to below code

:beetle: Please post your code:

import Sound from 'react-native-sound'

const start_final = new Sound('start_final.mp3', Sound.MAIN_BUNDLE)

Sound.setActive(true)
Sound.setCategory('Ambient')
Sound.setMode("Default")

const playStart = () => {
  start_final.play()
}

:bulb: Possible solution

Unknown

Is your issue with...

  • [x] iOS
  • [ ] Android
  • [ ] Windows

Are you using...

  • [x] React Native CLI (e.g. react-native run-android)
  • [ ] Expo
  • [ ] Other: (please specify)

Which versions are you using?

  • React Native Sound: ^0.11.2
  • React Native: 0.64.3
  • iOS: 15.6.1
  • Android: N/A
  • Windows: N/A

Does the problem occur on...

  • [x] Simulator
  • [x] Device

If your problem is happening on a device, which device?

  • Device: iPhone 12

DanStevensonDev avatar Dec 14 '22 12:12 DanStevensonDev

You can handle this by lowering volume :

start_final.setVolume(0)

like above statement rest thing u can handle by fetching details of device if its mute or not handle this accordingly....

shubhammalvedev avatar Dec 16 '22 13:12 shubhammalvedev

I'm wondering if it is still possible to play sounds when you are on silent mode on iOS? Seems like some features have been deprecated? 🤔

The signature '(value: AVAudioSessionCategory): void' of 'MySound.setCategory' is deprecated.

danbjork avatar Jan 19 '23 16:01 danbjork

This will help https://www.youtube.com/watch?v=vVI7ZAZq5e0

BraveEvidence avatar Mar 09 '23 14:03 BraveEvidence