I have implemented Agora Web SDK for calling and its working great in Laravel and Vue.js.
I want to know if there is any way to switch from audio to video call while having audio call.
If I createStream with video = false then it is only audio call but I cannot change it to switch to video call using rtc.localStream.unmuteVideo()
because it requires video = true to make it work
If I createStream with video = true then I turn of the camera using rtc.localStream.muteVideo()
. So it turns off the camera and user can turn it on when required. But camera light is still on.
// create local stream
this.rtc.localStream = AgoraRTC.createStream({
streamID: this.rtc.params.uid,
audio: true,
video: true,
screen: false,
microphoneId: this.option.microphoneId,
cameraId: this.option.cameraId
});
Which means it is still a video call but video track is just a blank screen.
I am looking for a way where I can remove the only audio call stream and add audio-video call stream without interruption.
I have looked into Agora docs but I couldnt find anything about it.
I think once a stream is created then cannot change video to true or false.
UPDATE:
After reading Hermes' answer. I did some RnD and found some useful events.
Trick is same as mentioned in answer.
To change call from screen <=> audio <=> video <=> screen.
- Unpublish the local stream using
- Create new stream to add/remove video or screen sharing
- wait for old local stream to be unpublished and init the new stream and publish it.
Above 3 steps will trigger AGORA events
- client.unpublish triggers stream-removed event
- publish triggers stream-added event . In this event listener, subscribe to new stream. When you subscribe to new stream then stream-subscribed event is triggered.
On the basis of these events, you can update the ui and (local, remote) streams as well.
The best way to handle this is to use two Agora
stream
objects.First create the audio only
stream
, and publish it usingclient.publish
. Then when you want to change to a video call, \ then callclient.unpublish
on the the audiostream
and create a secondstream
with video option enabled and callclient.publish
with the videostream
.There will be only a momentary interruption as the one stream is unpublished and then new one is published to the channel.