If the audience of interactive live video streaming wants to leave for another channel, usually you need to call the following methods:
leaveChannelmethod to leave the current channel.
joinChannelmethod to join the new channel.
Starting with v2.9.0, the Agora Native SDK provides the
switchChannel method for the audience to quickly switch between interactive live video streaming channels while staying connected to Agora. With this method, you can achieve a much faster channel switch than with the
Before implementing the quick switch function in your project, ensure that you have implemented the basic interactive live video streaming in your project. For details, see Start Live Interactive Video Streaming.
After the audience joins an interactive live video streaming channel, call the
switchChannel method to enable the audience to switch to another interactive live video streaming channel. Pass in the token and channel name of the new channel in this method.
A successful channel switch with this method triggers the
The following diagram shows the API call sequence for channel switching:
You can refer to the following code snippets and implement quick switching in your project:
We also provide an open-source demo project that implements Quick-Switch-Android on GitHub. You can try the demo and view the source code.
switchChannel method takes effect only when the client role is AUDIENCE.