react-native-soundでダッキングしたい(iOS)
オーディオセッションを共有して同時に音を出した状態にするとき、ダッキングと言って片方の音を小さくして片方を目立たせることができる。
iOSネイティブ開発では AVAudioSessionCategoryOptionDuckOthers を指定すればこれが実現できるが、react-native-sound では対応していなかったのでパッチを当てた。
RNSound.m
withOptions:AVAudioSessionCategoryOptionMixWithOthers | AVAudioSessionCategoryOptionAllowBluetooth
ここを
withOptions:AVAudioSessionCategoryOptionMixWithOthers | AVAudioSessionCategoryOptionDuckOthers
こうする。
ちなみに変更前の AVAudioSessionCategoryOptionAllowBluetooth はダッキングしなくても消さないとエラーコード 560557684 の cannotInterruptOthers エラーが出たので消す必要あるかも。