This article describes how to implement the basic features of live-stream shopping.
Refer to the flowcharts for the following functions:
- Joins and leaves the room.
- Co-host across channels.
- Co-host in a channel.
- Manages the product list.
Integrate the SDK
Refer to the following table to integrate the SDKs into your project:
Core API call sequence
The following diagrams show the core APIs that the Agora Live Demo app uses to implement a live-stream shopping scenario. Refer to them to implement the various functions in your project.
- The host joins the room and starts the interactive streaming.
- The host invites an audience member for co-hosting, or an audience member applies for co-hosting.
- The host sends a PK host invitation.
- The audience chat through text messages and switch channels.
Core API reference
- Agora RTM SDK
|createInstance||Creates an RTM Client object.|
|login||Logs into the Agora RTM system.|
|createChannel||Creates an Agora RTM channel.|
|join||Joins the RTM channel.|
|sendMessage||Sends a channel message, which can be received by all users in the channel.|
|sendMessageToPeer||Sends a peer message. The host can use this method to send a co-hosting invitation to an audience member or send a PK host invitation to the host of another channel; an audience member can use this method to send a co-hosting application to the host.|
|leave||Leaves the RTM channel.|
|logout||Logs out of the Agora RTM system.|
- Agora RTC SDK
|create||Creates an RtcEngine object.|
|setChannelProfile||Sets the channel profile. In live-stream shopping, we set the channel profile as
|setClientRole||Sets the user role in live interactive streaming. In live-stream shopping, we set the role of the host as
|setupLocalVideo||Sets the local video view. Call this method on the host's client to configure the view of the host on the local device.|
|joinChannel||Joins the RTC channel.|
|startChannelMediaRelay||Starts relaying media streams across channels. This is the core API for co-hosting across channels.|
|setupRemoteVideo||Sets the remote video view. Once the audience member accepts the co-hosting invitation or the host of the destination channel accepts the PK host invitation, call this method on the original host's client to configure the view of the co-host.|
|stopChannelMediaRelay||Stops relaying media streams across channels.|
|leaveChannel||Leaves the channel.|
The Agora Live Demo app uses a third-party SDK for image enhancement. You can refer to the source code in the faceunity file to implement the function.
Network quality detection
onRtcStats callback to detect and report the network quality in real-time. Triggered once every two seconds during live interactive steaming, this callback reports statistics, including the sending and receiving bitrate and packet loss rate.
enableInEarMonitoring to enable the in-ear monitor function on the host's client.
After joining the channel, call
startAudioMixing on the host's client to play background music.
Open-source sample project
Agora provides an open-source sample project for Live-stream Shopping on GitHub for you to download as a source code reference.