|
setting.gradle
中完成导入,参考如下:include ':tuiroom'include ':debug'include ':tuibeauty'
build.gradle
文件中添加对 tuiroom、debug、tuibeauty 的依赖:api project(':tuiroom')api project(':debug')api project(':tuibeauty')
build.gradle
文件中添加 TRTC SDK
和 IM SDK
的依赖:ext {liteavSdk = "com.tencent.liteav:LiteAVSDK_TRTC:latest.release"imSdk = "com.tencent.imsdk:imsdk-plus:latest.release"}
<uses-permission android:name="android.permission.INTERNET" /><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /><uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /><uses-permission android:name="android.permission.RECORD_AUDIO" /><uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /><uses-permission android:name="android.permission.CAMERA" /><uses-feature android:name="android.hardware.camera"/><uses-feature android:name="android.hardware.camera.autofocus" />
-keep class com.tencent.** { *; }
// 1.组件登录TUILogin.addLoginListener(new TUILoginListener() {@Overridepublic void onKickedOffline() { // 登录被踢下线通知(示例:账号再其他设备登录)}@Overridepublic void onUserSigExpired() { // userSig过期通知}});TUILogin.login(context, "您的SDKAppId", "您的userId", "您的userSig", null);// 2.初始化TUIRoom实例TUIRoom tuiRoom = TUIRoom.sharedInstance(this);
tuiRoom.createRoom(12345, TUIRoomCoreDef.SpeechMode.FREE_SPEECH, true, true);
tuiRoom.enterRoom(12345, true, true);
// 1.房主调用解散房间mTUIRoomCore.destroyRoom(new TUIRoomCoreCallback.ActionCallback() {@Overridepublic void onCallback(int code, String msg) {}});成员端会收到 onDestroyRoom 回调消息,通知房间解散@Overridepublic void onDestroyRoom() {//房主解散,退出房间}
// 1.非房主身份调用离开房间mTUIRoomCore.leaveRoom(new TUIRoomCoreCallback.ActionCallback() {@Overridepublic void onCallback(int code, String msg) {}});//成员端会收到 onRemoteUserLeave 回调消息,通知有人离开@Overridepublic void onRemoteUserLeave(String userId) {Log.d(TAG, "onRemoteUserLeave userId: " + userId);}
// 1.在 AndroidManifest.xml 文件中添加 SDK 录屏功能的 activity 和权限<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /><application><activityandroid:name="com.tencent.rtmp.video.TXScreenCapture$TXScreenCaptureAssistantActivity"android:theme="@android:style/Theme.Translucent" /></application>// 2.在您的界面中申请悬浮窗的权限if (Build.VERSION.SDK_INT >= 23) {if (!Settings.canDrawOverlays(getApplicationContext())) {Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getPackageName()));startActivityForResult(intent, 100);} else {startScreenCapture();}} else {startScreenCapture();}// 3.系统回调结果protected void onActivityResult(int requestCode, int resultCode, Intent data) {if (requestCode == 100) {if (Build.VERSION.SDK_INT >= 23) {if (Settings.canDrawOverlays(this)) {// 用户成功授权startScreenCapture();} else {}}}}// 4.打开屏幕分享private void startScreenCapture() {TRTCCloudDef.TRTCVideoEncParam encParams = new TRTCCloudDef.TRTCVideoEncParam();encParams.videoResolution = TRTCCloudDef.TRTC_VIDEO_RESOLUTION_1280_720;encParams.videoResolutionMode = TRTCCloudDef.TRTC_VIDEO_RESOLUTION_MODE_PORTRAIT;encParams.videoFps = 10;encParams.enableAdjustRes = false;encParams.videoBitrate = 1200;TRTCCloudDef.TRTCScreenShareParams params = new TRTCCloudDef.TRTCScreenShareParams();mTUIRoom.stopCameraPreview();mTUIRoom.startScreenCapture(encParams, params);}
本页内容是否解决了您的问题?