简体   繁体   中英

How to programmatically change the volume on call using the Sinch SDK?

At the moment, when I call and try to change the volume with UI elements, I only see the UI change, the volume slider change, but not the device volume. The volume is static. For volume changing I'm using MPVolumeView

static func adjustCurrentVolume(_ volume: Float) {
        let volumeView = MPVolumeView()
        
        guard let slider = volumeView.subviews.first(where: { $0 is UISlider }) as? UISlider else { return }
        
        if volume > maximumVolume {
            currentVolume = maximumVolume
        } else if volume < minimumVolume {
            currentVolume = minimumVolume
        } else {
            currentVolume = volume
        }
        
        DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
            slider.value = currentVolume
        }
    }

For Call: SinchRTC and CallKit. The AudioSession during a call is in the PlayAndRecord category and VoiceChat mode.

Looking at the developer reference for MPVolumeview, have you tried it with the button to set the audio output path. If you add the button are you able to set an audio output route and control the volume as expected?

https://developer.apple.com/documentation/mediaplayer/mpvolumeview

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM