一、显示通话中页面
通话建立后,展示通话中的页面
// 监听当前的通话
CallsViewModel.shared.currentCallData.readCurrentAndObserve { [weak self] (currentCallData) in
self?.updateNavigation()
if (currentCallData == nil) {
// self.callPausedByRemoteView?.isHidden = true
// self.callPausedByLocalView?.isHidden = true
} else {
currentCallData??.isIncoming.readCurrentAndObserve { _ in self?.updateNavigation() }
currentCallData??.isOutgoing.readCurrentAndObserve { _ in self?.updateNavigation() }
}
// 通话对象
self?.callData = currentCallData != nil ? currentCallData! : nil
}
...
func updateNavigation() {
if (Core.get().callsNb == 0) {
// 通话挂断,移除页面
JWCallViewManager.shared().removeCallingVC()
} else {
if let data = CallsViewModel.shared.currentCallData.value {
if (data?.isOutgoing.value == true || data?.isIncoming.value == true) {
// 通话挂断,移除页面
JWCallViewManager.shared().removeCallingVC()
} else {
if (data!.isInRemoteConference.value == true) {
// 通话挂断,移除页面
JWCallViewManager.shared().removeCallingVC()
} else {
// 通话建立,显示页面
JWCallViewManager.shared().showCallingVC()
}
}
} else {
// 通话建立,显示页面
JWCallViewManager.shared().showCallingVC()
}
}
}
二、通话保持与接回
- 切换保持与接回状态
self.callData?.togglePause()
- 监听通话保持与接回状态
self.callData?.isPaused.readCurrentAndObserve { [weak self] locallyPaused in
self?.callDataIsPausedChanage(locallyPaused ?? false)
}
三、切换扬声器
- 切换扬声器
ControlsViewModel.shared.toggleSpeaker()
- 监听扬声器的切换
ControlsViewModel.shared.isSpeakerSelected.readCurrentAndObserve { [weak self] (selected) in
self?.selectorToSpeakerSelect(select: selected ?? false)
}
四、切换麦克风
- 切换麦克风
ControlsViewModel.shared.toggleMuteMicrophone()
- 监听麦克风的切换
ControlsViewModel.shared.isMicrophoneMuted.readCurrentAndObserve { [weak self] (muted) in
self?.selectorToMicrophoneSelect(select: muted ?? false)
}
网友评论