I've integrated MPVolumeView
into my view, and it correctly responds to hardware volume changes as expected. However, once I initiate audio streaming using AVAudioEngine
to capture microphone audio and AudioUnit
for decoding, the MPVolumeView
ceases to reflect changes made using the hardware volume buttons. Additionally, even when I adjust the volume using the slider on MPVolumeView,
it doesn't change the system volume. Has anyone else encountered this issue? What might be causing MPVolumeView
to stop responding to hardware volume changes once streaming starts?
For the AVAudioSession.Mode,
I use the default
setting because using .voiceChat
prevents MPVolumeView update from device volume changes permanently.
let session = AVAudioSession.sharedInstance()
do {
try session.setCategory(.playAndRecord, options: [.allowBluetooth])
try session.setActive(true)
} catch {
print(error.localizedDescription)
}