• 製品
  • 価格
  • リソース
  • サポート
このページは現在英語版のみで提供されており、日本語版も近日中に提供される予定です。ご利用いただきありがとうございます。

Overview

Feature Preview

Full feature integration for live streaming rooms supports the following features.
Host Preparation Page
Host Live Stream Page
Waterfall Layout
Audience Viewing Page






Environment Preparation

Android 5.0 (SDK API Level 21) and above versions.
Gradle 7.0 and above versions.
Android 5.0 and above mobile devices.

Steps

Step 1: Enabling the Service

Before using the audio and video service provided by Tencent Cloud, you need to go to the console to activate the audio and video service for your application. For specific steps, see Activate Service (TUILiveKit).

Step 2: Download the TUILiveKit Component

Clone/download the code in GitHub, then copy the tuilivekit subdirectory under the Android directory to the same-level directory as your current project's app, as shown in the figure below:




Step 3: Project Configuration

1. Add the jitpack repository address in the settings.gradle.kts (or settings.gradle) file in the project root directory: Add the jitpack repository dependency (to download the third-party library SVGAPlayer for playing gift svg animations):
settings.gradle.kts
settings.gradle
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()

// Add jitpack repository url
maven { url = uri("https://jitpack.io") }
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()

// Add jitpack repository url
maven { url 'https://jitpack.io' }
}
}
2. Add the following code in the settings.gradle.kts (or settings.gradle) file in the project root directory. It enables importing the tuilivekit component downloaded in step two into your current project:
settings.gradle.kts
settings.gradle
include(":tuilivekit")
include ':tuilivekit'
3. Locate the build.gradle.kts (or build.gradle) file under the app directory and add the following code in it. It declares the current app's dependency on the newly joined tuilivekit component:
build.gradle.kts
build.gradle
api(project(":tuilivekit"))
api project(':tuilivekit')
Note:
Note: TUILiveKit project internally depends on TRTC SDK, Chat SDK, tuiroomengine as well as public library tuicore. No need for developers to configure separately. If needed, just modify tuilivekit/build.gradle file to upgrade.
4. Since we use Java reflection features internally in the SDK, you need to add the following code to the proguard-rules.pro file to include certain SDK classes in the non-obfuscation list:
-keep class com.tencent.** { *; }
-keep class com.trtc.uikit.livekit.livestreamcore.** { *; }
-keep class com.trtc.uikit.livekit.component.gift.store.model.** { *; }
-keep class com.squareup.wire.** { *; }
-keep class com.opensource.svgaplayer.proto.** { *; }

-keep class com.tcmediax.** { *; }
-keep class com.tencent.** { *; }
-keep class com.tencent.xmagic.** { *; }
-keep class androidx.exifinterface.** {*;}
-keep class com.google.gson.** { *;}
# Tencent Effect SDK - beauty
-keep class com.tencent.xmagic.** { *;}
-keep class org.light.** { *;}
-keep class org.libpag.** { *;}
-keep class org.extra.** { *;}
-keep class com.gyailib.**{ *;}
-keep class com.tencent.cloud.iai.lib.** { *;}
-keep class com.tencent.beacon.** { *;}
-keep class com.tencent.qimei.** { *;}
-keep class androidx.exifinterface.** { *;}
5. Find the AndroidManifest.xml file under the app directory, add tools:replace="android:allowBackup" and android:allowBackup="false" in the application node, overwrite the settings within component, and use your own settings.
// app/src/main/AndroidManifest.xml
<application
...
// add the following configuration to overwrite the configuration in the dependent sdk
android:allowBackup="false"
tools:replace="android:allowBackup">

Step 4: Logging In

Add the following code in your project. It enables logging in to the TUI component by calling relevant APIs in TUICore. This step is critical. Only after logging in successfully can you use the features provided by TUILiveKit properly.
Kotlin
Java
// Log in
TUILogin.login(applicationContext,
1400000001, // replace with the SDKAppID obtained in step 1
"denny", // replace with your UserID
"xxxxxxxxxxx", // You can count a UserSig in the console and fill it in this location
object : TUICallback() {
override fun onSuccess() {
Log.i(TAG, "login success")
}

override fun onError(errorCode: Int, errorMessage: String) {
Log.e(TAG, "login failed, errorCode: $errorCode msg:$errorMessage")
}
})
// Log in
TUILogin.login(context,
1400000001, // replace with the SDKAppID obtained in step 1
"denny", // replace with your UserID
"xxxxxxxxxxx", // You can count a UserSig in the console and fill it in this location
new TUICallback() {
@Override
public void onSuccess() {
Log.i(TAG, "login success");
}

@Override
public void onError(int errorCode, String errorMessage) {
Log.e(TAG, "login failed, errorCode: " + errorCode + " msg:" + errorMessage);
}
});
Parameter Description
Here introduce the key parameters needed in the login function:
Parameters
Type
Overview
SDKAppID
int
In step 1, you have already obtained it in the final step. No redundancy here.
UserID
String
The current user ID, string type, only allows letters (a-z and A-Z), digits (0-9), hyphens, and underscores.
userSig
String
Step 1: Use the SecretKey obtained in step 3 to encrypt information such as SDKAppID and UserID. This process generates a UserSig, which is an authentication token used by Tencent Cloud to verify if the current user can access the TRTC service. You can generate a temporary UserSig using the auxiliary tool in the console. For more information, see how to calculate and use UserSig.
Note:
Development environment: If you are in the local development and debugging stage, you can adopt the local GenerateTestUserSig.genTestSig function to generate userSig. In this method, the SDKSecretKey is very easy to decompile and reverse engineer. Once your key is leaked, attackers can misappropriate your Tencent Cloud traffic.
Production environment: If your project is ready to launch, use server-side generation of UserSig.