Live Quiz: Client SDK Integration

There is a new release of the Developer Center! If you'd like to check it out, please click  here

Live Quiz: Client SDK Integration

This page describes how to integrate the Agora Live Quiz SDK on an Android client.

Integrating in Basic Live Broadcast Mode

The following figure shows how to integrate the Agora Live Quiz SDK in basic Live Broadcast Mode.

../_images/contest_simple.jpg

Step 1: Join the media channel

See Join a Channel (joinChannel)

public int joinChannel(      String  token,
                         String      channelName,
                         String      optionalInfo,
                         int optionalUid );

Step 2: Join the signaling channel

login

Step 3: View the host

This is implemented using the media callback. See onFirstRemoteVideoFrame_android_en.

public void onFirstRemoteVideoDecoded(int uid,
                                     int width,
                                     int height,
                                     int elapsed )

Step 4: Answer the questions

  1. Check if you are eligible to answer the questions. (To be implemented by Agora’s customers. Refer to Agora’s sample apps to check the eligibility of each user.)
  2. Get the questions sent from the server. This is implemented by using the signaling callback.
onChannelMessageReceived(final String channel, final long msgId, final String msg)
  1. Display the question when receiving the SEI callback from the media SDK. See Callback on the Android device.
onReceiveSEI(final String info)
  1. Upload the answers to the server. (To be implemented by Agora’s customers. You can also refer to Agora’s sample app for uploading the selected answers to the server.)
  2. Get the right answer from the server and display it. This is implemented using the signaling callback:
onChannelMessageReceived(final String channel, final long msgId, final String msg)

Step 5: Text Messaging

  1. Send channel messages using the Signaling API:
sendChannelMessage()
  1. Receive the text messages. This is implemented by the signaling callback:
onChannelMessageReceived(final String channel, final long msgId, final String msg)

Step 6: Leave the channel

See live_android_leaveChannel

public int leaveChannel();

Integrating in Team Mode

The following figure shows how to integrate the Agora HQ SDK in Team Mode.

../_images/contest_group.jpg

See Integrating in Basic Live Broadcast Mode for the steps in the light-blue blocks.

Note

  • In Team Mode, you need to create two Agora media engines; mainEngine for joining the live broadcast channel and subEngine for joining the team channel. Agora recommends only using mainEngine to call voice- and video-specific functions because using two engines may affect the voice and video functionalities of the SDK.
  • The two engines on iOS use the same delegate. If you set both engines as the current controller, you need to specify the engine in the delegate.

Set to Team Mode

To implement Team Mode, use mainEngine to call the following interface before joining the channel.

setParameters("{\"rtc.hq_mode\": {\"hq\": true, \"broadcaster\":false, \"bitrate\":0}}")

Enter Team Mode

Use subEngine to call the following method, and then use Join a Channel (joinChannel) to enter Team Mode.

setParameters("{\"rtc.hq_mode\": {\"hq\": true, \"broadcaster\":true, \"bitrate\":50}}")

Leave Team Mode

Use subEngine to call the following method, and then use Leave a Channel (leaveChannel) to leave Team Mode.

setParameters("{\"rtc.hq_mode\": {\"hq\": true, \"broadcaster\":false, \"bitrate\":0}}")

Leave the Channel

Use mainEngine to call Leave a Channel (leaveChannel).

Set the Volume of the Broadcaster in Team Mode

If your team member is talking and you wish to lower the volume of the broadcaster, use Audio Volume Indication Callback (onAudioVolumeIndication) to get the volume of the host.

public void onAudioVolumeIndication( AudioVolumeInfo[] speakers,
       int totalVolume )

Use this method to lower the volume of the broadcaster.

setParameters("{\"che.audio.playout.uid.volume\":{\"uid\":hostUid,\"volume\":30}}")
Parameter Name
hostUid UID of the host.
volume Volume ranging between 0 and 100.

Note

Currently, Team Mode supports voice functions only.

Integrating in Co-host Mode

Follow the steps shown in the following figure to integrate the Agora HQ SDK in Co-host Mode.

../_images/contest_celebrity.jpg

See Integrating in Basic Live Broadcast Mode and Integrating in Team Mode for the steps in the light-blue and dark-blue blocks respectively.

This part mainly includes methods for Get the invitation, `Start the co-host`_, `Stop the co-host`_, Monitor the first publishing stream of the host and co-host, and Monitor the co-host on the part of the client.

To enable Co-host Mode, the host needs to send the account of the co-host to the server. Then, the server sends an invitation to the invited audience.

Note

If you wish to enable Co-host Mode only, skip the parameter settings step for Team Mode before joining the channel. See Advanced: Hosting In for integrating the SDK.

The Co-host

Get the Invitation

The co-host can accept or decline an invitation by sending an acceptance or rejection message to the server.

onMessageReceivedFrom(final String account, final long msgId, final String msg)

Start the Co-host Mode

After the acceptance message is sent, the co-host needs to use this following method to start the co-host mode.

setParameters("{\"rtc.hq_mode\": {\"hq\": true, \"broadcaster\":true, \"bitrate\":1000}}")

Note

Here the bitrate is set to 1000 just for example, and the actual value must be the same as the one you set when calling the API setVideoProfile.

Stop the Co-host Mode

The co-host can use this method to stop the co-host mode.

rtcEngine.setParameters("{\"rtc.hq_mode\": {\"hq\": true, \"broadcaster\":false, \"bitrate\":0}}")

Note

The current Agora HQ SDK does not have callback functions for starting or stopping the co-host mode. If you want to be informed when a co-host starts and stops the co-host mode, Agora recommends using muteLocalVideoStream(false) when the co-host mode starts and muteLocalVideoStream(true) when the co-host mode stops. Use the didVideoMuted callback function to monitor the co-host modes. You can also synchronize the state with the signaling system.

The Client

Monitor the first publishing stream of the host and co-host

onFirstRemoteVideoDecoded(final int uid, int width, int height, int elapsed)

Note

You can identify who is hosting from the UID of this callback function.

Monitor the Co-host

onUserMuteVideo(final int uid, final boolean muted)

For more information on the Agora HQ API methods, see Agora HQ API.

Is this page helpful?