When the user uses the dynamic PPT of the RTC and the whiteboard at the same time, the following problems may be encountered:
In order to solve these problems, the 2.9.15 whiteboard has a built-in RTC interface for mixing. Users can avoid these problems after implementing them according to the content of this chapter.
If the user's RTC provider does not support mixing, the content of this chapter will be invalid
For sample code, please refer to Whiteboard-iOS rtc branch, RTC folder content
In this article, RTC uses Agora SDK as an example, please configure AppId in
AppID.swift
before running the demo
WhiteAudioMixerBridgeDelegate
protocol.WhiteSDK
, pass in an object that implements the audioMixerBridgeDelegate
protocol.rtcEngine:localAudioMixingStateDidChanged:errorCode:
callback, actively call the setMediaState:errorCode:
method in the audioMixer
property of WhiteSDK
to inform the completion of the audio and video status update.When the dynamic ppt of the whiteboard is playing, it will actively call the startAudioMixing:filePath:loopback:replace:cycle
API when it is ready to play, and the developer needs to actively call the audio mixing interface of the RTC sdk here.
There is a situation in the iOS SDK: when this method fails, the rtc SDK will not actively call
rtcEngine:localAudioMixingStateDidChanged:errorCode:
Therefore, when the value is not 0, the developer needs to code directly here Call thesetMediaState:errorCode:
method ofaudioMixer
directly to pass it, and pass the non-zero return value to the errorCode, and fill in the stateCode at will.
extension VideoChatViewController: WhiteAudioMixerBridgeDelegate {
func startAudioMixing(_ filePath: String, loopback: Bool, replace: Bool, cycle: Int) {
// At this stage, the rtc on iOS does not support mixing online mp4 files. When mixing this kind of files, there will be a problem that the jump fails and the mixing effect disappears.
// If it is an online mp4 address, please use the dynamic ppt resource package to download in advance, or change the mp4 suffix to m4a for playback.
// The filePath path will be affected by the scheme parameter in pptParams when the SDK is initialized. Please recover by yourself.
let result:Int32 = agoraKit.startAudioMixing(filePath, loopback: true, replace: false, cycle: 1)
print("\(#function) \(filePath) \(loopback) \(replace) \(cycle) result:\(result)")
if result != 0 {
self.whiteSdk!.audioMixer?.setMediaState(714, errorCode: Int(result))
}
}
func stopAudioMixing() {
let result:Int32 = agoraKit.stopAudioMixing()
print("\(#function) result:\(result)")
if result != 0 {
self.whiteSdk!.audioMixer?.setMediaState(0, errorCode: Int(result))
}
}
func setAudioMixingPosition(_ position: Int) {
print("position: \(position)")
let result: Int32 = agoraKit.setAudioMixingPosition(position)
print("\(#function) result:\(result) position: \(position)")
if result != 0 {
self.whiteSdk!.audioMixer?.setMediaState(0, errorCode: Int(result))
}
}
}
extension VideoChatViewController: AgoraRtcEngineDelegate {
...
func rtcEngine(_ engine: AgoraRtcEngineKit, localAudioMixingStateDidChanged state: AgoraAudioMixingStateCode, errorCode: AgoraAudioMixingErrorCode) {
print("localAudioMixingStateDidChanged: \(state.rawValue) errorCode: \(errorCode.rawValue)")
if let sdk = self.whiteSdk {
sdk.audioMixer?.setMediaState(state.rawValue, errorCode: errorCode.rawValue)
} else {
print("sdk not init !")
}
}
...
}
The above content can be viewed in the VideoChatViewController.swift
project.