Read this in other languages: 简体中文
A typical voice chatroom has a host and several audience.
in which:
- The host talks and the audience hear the host.
- The host invites the audience for interaction and the audience switches the user role to be a co-host.
- The host can mute or unmute the co-host, and delete or add a host position.
- Any change to the host state and host position is immediately known to the host, co-host, and audience in the channel.
This use case particularly applies to scenarios such as online KTV and FM radio.
Agora supports real-time voice interaction between a maximum of one host + 16 co-hosts.
Use the Agora SDK to implement the following features in your project:
- Real-time voice interaction: Smooth communication between the host and audience guaranteed by ultra-low latency.
- Co-hosting: The audience becomes a co-host and interact with the host, so that all users in the channel can hear the interaction.
- Host position control: The host has the following control privileges: invite an audience to become a co-host, switch a co-host back to an audience, mute and unmute a co-host, delete and resume a host position. Any change to the host state and host position is immediately known to all users in the channel.
- Real-time messaging: The host, co-host, and audience can send IM messages to each other. The audience can also send gifts to the host/co-host.
- User management: Maintains the user list and nicknames of the users in the channel.
- Audio mixing: The host and co-host can play background music while talking.
- Voice changer: Adds special voice effect for the host or co-host to add more fun to the chatroom.
The sample app shows only the part related to voice chat and is not a complete product. If you want to develop a complete product, you need to implement the rest of the voice chatroom.
-
Create a developer account at agora.io and create a project in Dashboard to get an App ID.
-
Download Voice SDK and Real-time Messaging SDK.
-
Add the AppID and Token in the
Android/app/src/main/res/values/strings_config.xml
file.<string name="app_id" translatable="false"><#Your App Id#></string> <string name="token" translatable="false"><#Temp Access Token#></string> <string name="rtm_token" translatable="false"><#Temp Rtm Access Token#></string>
-
Unpack the SDKs and do the following:
- Copy the
libs
folder to theAndroid/app
folder.
- Copy the
-
Open the project with Android Studio and connect to an Android test device. Compile and run the sample app.
Development environment: - Android Studio 2.0+. - minSdkVersion 16. - Emulators may lack the functionality or performance needed to run the sample app. Agora recommends using physical Android devices.
-
Add the AppID and Token in the
KeyCenter.swift
file.static let AppId: String = <#Your App Id#> static let Token: String? = <#Temp Access Token#> static let RtmToken: String? = <#Temp Rtm Access Token#>
-
Unpack the SDKs and copy the
libs
folder to theiOS/AgoraChatRoom
folder of your project. -
Open the
iOS/AgoraChatRoom.xcodeproj
file with XCode. Connect to an iOS test device and fill in a valid developer signature.Development environment: - XCode 10.0+. - iOS 8.0+.
-
Q: Noise reduction is disabled when there is only one host and
scenario
inaudioProfile
is set to Default, ShowRoom, Education, and GameStreaming. How can I fix that?A: You can enable noise reduction through the private interface:
agoraKit.setParameters("{\"che.audio.enable.ns\":true}")
-
Q: Calling the
disableAudio
orleaveChannel
method stops other apps from using AVAudioSession to play and record. How can I fix that?A: You can keep the audio session active by calling the
agoraKit.setAudioSessionOperationRestriction(.deactivateSession)
method after calling thedisableAudio
orleaveChannel
method.
- API documentation is available at the Document Center.
- For any issue with integration, connect with global developers in the Developer Community.
- For genera technical support, submit a ticket at the Agora Dashboard.
- For any issue with the sample code, submit an issue at GitHub.
The MIT License (MIT).