Hope this comes useful for Future readers.
You really can't switch between callUserVideo
and callUser
while on an ongoing call.
But there is an alternate way to achieve the functionality. This is what Sinch Support team says,
you can pause video and do voice only, so all calls are video and you can pause / resume the video track
So what this means is, you have to start the call always with callUserVideo
, in case you want to toggle between audio and video.
So for toggling between Audio and Video, you need to do some thing like this. In the page where you are handling the incoming call client.
// function to be called when you want to toggle to video call
private void resumeVideo() {
if (mVideoCall != null) {
mVideoCall.resumeVideo();
}
}
// enable speaker
// add remote and local video views
private void resumeVideoCallback() {
mAudioCallToggle.setText("Switch to AudioCall");
if (getSinchServiceInterface() != null && getSinchServiceInterface().getAudioController() != null) {
getSinchServiceInterface().getAudioController().enableSpeaker();
}
addLocalView();
addRemoteView();
}
// function to be called when you want to toggle to audio call
private void pauseVideo() {
if (mVideoCall != null) {
mVideoCall.pauseVideo();
}
}
// disable speaker
// remove remote and local video views
private void pauseVideoCallback() {
mAudioCallToggle.setText("Switch to VideoCall");
if (getSinchServiceInterface() != null && getSinchServiceInterface().getAudioController() != null) {
getSinchServiceInterface().getAudioController().disableSpeaker();
}
removeVideoViews();
}
And on your video call listener, implement like this
.............
.............
other implementations
.............
.............
@Override
public void onVideoTrackAdded(Call call) {
Log.d(TAG, "Video track added");
addRemoteView();
}
@Override
public void onVideoTrackPaused(Call call) {
pauseVideoCallback();
}
@Override
public void onVideoTrackResumed(Call call) {
resumeVideoCallback();
}
And finally to toggle between Audio/Video, do something like this
new OnClickListener() {
@Override
public void onClick(View v) {
if (mAudioCallToggle.getTag().equals("Audio")) {
mAudioCallToggle.setTag("Video");
pauseVideo();
} else {
mAudioCallToggle.setTag("Audio");
resumeVideo();
}
}
}