TUIRoomKit
组件的接入,跟随本文档,您将在一个小时的时间内完成如下几个关键步骤,并最终得到一个包含完备 UI 界面的音视频会议功能。Android
目录下的timcommon
、 tuiroomkit
子目录到您当前工程中的 app 同级目录中,如下图:setting.gradle(或settings.gradle.kts)
文件,并在其中增加如下代码,它的作用是将tuiroomkit
组件导入到您当前的项目中。include ':timcommon'include ':tuiroomkit'
include (":timcommon") include (":tuiroomkit")
build.gradle(或build.gradle.kts)
文件,并在其中增加如下代码,它的作用是声明当前app
对新加入的tuiroomkit
组件的依赖。api project(':tuiroomkit')
api(project(":tuiroomkit"))
-keep class com.tencent.** { *; }
TUILogin
中的相关接口完成组件的登录。这个步骤异常关键,因为只有在登录后才能正常使用 TUIRoomKit
的各项功能,故请您耐心检查相关参数是否配置正确:TUILogin.login(context,1400000001, // 请替换为步骤一取到的 SDKAppID"denny", // 请替换为您的 UserID"xxxxxxxxxxx", // 您可以在控制台中计算一个 UserSig 并填在这个位置new TUICallback() {@Overridepublic void onSuccess() {Log.i(TAG, "login success");}@Overridepublic void onError(int errorCode, String errorMessage) {Log.e(TAG, "login failed, errorCode: " + errorCode + " msg:" + errorMessage);}});
TUILogin.login(this,1400000001, // 请替换为步骤一取到的 SDKAppID"denny", // 请替换为您的 UserID"xxxxxxxxxxx", // 您可以在控制台中计算一个 UserSig 并填在这个位置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);}})}
login
函数中所需要用到的几个关键参数:SDKSecretKey
对SDKAppID
、UserID
等信息进行加密,就可以得到UserSig
,它是一个鉴权用的票据,用于腾讯云识别当前用户是否能够使用TRTC
的服务。您可以通过控制台中的 辅助工具 生成一个临时可用的UserSig
。<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/conference_container" android:layout_width="match_parent" android:layout_height="match_parent" />
public class ConferenceOwnerActivity extends AppCompatActivity {private static final String TAG = "ConferenceOwnerActivity";private ConferenceObserver mConferenceObserver;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_conference);ConferenceMainFragment fragment = new ConferenceMainFragment();mConferenceObserver = new ConferenceObserver() {@Overridepublic void onConferenceStarted(String conferenceId, ConferenceError error) {super.onConferenceStarted(conferenceId, error);if (error != ConferenceError.SUCCESS) {Log.e(TAG, "Error : " + error);return;}FragmentManager manager = getSupportFragmentManager();FragmentTransaction transaction = manager.beginTransaction();transaction.add(R.id.conference_container, fragment);transaction.commitAllowingStateLoss();}};fragment.setConferenceObserver(mConferenceObserver);// Replace "123456" with the corresponding conference numberfragment.quickStartConference("123456");}}
class ConferenceOwnerActivity : AppCompatActivity() { private val tag: String = "ConferenceOwnerActivity" private var mConferenceObserver : ConferenceObserver? = null override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_conference) var fragment = ConferenceMainFragment() mConferenceObserver = object: ConferenceObserver() { override fun onConferenceStarted(conferenceId: String?, error: ConferenceError?) { super.onConferenceStarted(conferenceId, error) if (error != ConferenceError.SUCCESS) { Log.e(tag, "Error : $error") return } val fragmentManager = supportFragmentManager val transaction = fragmentManager.beginTransaction() transaction.add(R.id.conference_container, fragment) transaction.commitAllowingStateLoss() } } fragment.setConferenceObserver(mConferenceObserver) // Replace "123456" with the corresponding conference number fragment.quickStartConference("123456") } }
public class ConferenceGeneralActivity extends AppCompatActivity {private static final String TAG = "ConferenceGeneralActivity";private ConferenceObserver mConferenceObserver;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_conference);ConferenceMainFragment fragment = new ConferenceMainFragment();mConferenceObserver = new ConferenceObserver() {@Overridepublic void onConferenceJoined(String conferenceId, ConferenceError error) {super.onConferenceJoined(conferenceId, error);if (error != ConferenceError.SUCCESS) {Log.e(TAG, "Error : " + error);return;}FragmentManager manager = getSupportFragmentManager();FragmentTransaction transaction = manager.beginTransaction();transaction.add(R.id.conference_container, fragment);transaction.commitAllowingStateLoss();}};fragment.setConferenceObserver(mConferenceObserver);// Replace "123456" with the corresponding conference numberfragment.joinConference("123456");}}
class ConferenceGeneralActivity : AppCompatActivity() { private val tag: String = "ConferenceGeneralActivity" private var mConferenceObserver : ConferenceObserver? = null override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_conference) var fragment = ConferenceMainFragment() mConferenceObserver = object: ConferenceObserver() { override fun onConferenceJoined(conferenceId: String?, error: ConferenceError?) { super.onConferenceJoined(conferenceId, error) if (error != ConferenceError.SUCCESS) { Log.e(tag, "Error : $error") return } val fragmentManager = supportFragmentManager val transaction = fragmentManager.beginTransaction() transaction.add(R.id.conference_container, fragment) transaction.commitAllowingStateLoss() } } fragment.setConferenceObserver(mConferenceObserver) // Replace "123456" with the corresponding conference number fragment.joinConference("123456789") } }
会议主界面 | 用户列表 |
本页内容是否解决了您的问题?