te_adapter_trtcte_adapter_trtc 库的依赖。dependencies{...implementation 'com.tencent.mediacloud:te_adapter_trtc:版本号'}
.aar 文件到 app 工程 libs 目录下。build.gradle 添加依赖引用:dependencies{...implementation fileTree(dir: 'libs', include: ['*.jar','*.aar']) //添加 *.aar}
com.tencent.thirdbeauty.xmagic.LicenseConstant.java 文件中添加您申请的 License 信息,并将 App module 下的 build.gradle 中的 applicationId 修改为您申请 License 时填写的包名。Debug module 下找到 com.tencent.trtc.debug.GenerateTestUserSig.java 文件,并添加对应的 APPID,SDKAPPID,SECRETKEY。com.tencent.trtc.thirdbeauty.ThirdBeautyActivity.java 文件。TEBeautyKit.setupSDK(this.getApplicationContext(),LicenseConstant.mXMagicLicenceUrl,LicenseConstant.mXMagicKey, (i, s) -> { if (i == LicenseConstant.AUTH_STATE_SUCCEED) {runOnUiThread(() -> { Intent intent = new Intent(MainActivity.this, ThirdBeautyActivity.class); startActivity(intent);}} else {Log.e(TAG, "te license check is failed,please checke ");}});
this.beautyAdapter = new TEBeautyTRTCAdapter(XmagicConstant.EffectMode.PRO, TEBeautyKit.getResPath());//设置手机朝向 this.beautyAdapter.notifyScreenOrientationChanged(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);//设置相机是前置摄像头还是后置摄像头,以及是否编码镜像 this.beautyAdapter.notifyCameraChanged(isFront, this.isEncoderMirror);//初始化面板代码private void initBeautyPanelView() { RelativeLayout panelLayout = findViewById(R.id.live_pusher_bp_beauty_panel); this.tePanelView = new TEPanelView(this); if (lastParamList != null) { //用于恢复美颜上次效果 this.tePanelView.setLastParamList(lastParamList); } this.tePanelView.showView(this); panelLayout.addView(this.tePanelView); }
TEPanelView,美颜属性调用 TEBeautyKit 的 setEffect 设置美颜属性。this.beautyAdapter.bind(this, this.mTRTCCloud, new ITEBeautyAdapter.CallBack() {@Overridepublic void onCreatedTEBeautyApi(XmagicApi xmagicApi) {Log.e(TAG, "onCreatedTEBeautyApi ");mBeautyKit = new TEBeautyKit(xmagicApi);mPanelView.setupWithTEBeautyKit(mBeautyKit);setTipListener(mBeautyKit);setLastParam(mBeautyKit);}@Overridepublic void onDestroyTEBeautyApi() {Log.e(TAG, "onDestroyTEBeautyApi ");mBeautyKit = null;}});
this.beautyAdapter.bind(this, this.mTRTCCloud, new ITEBeautyAdapter.CallBack() {@Overridepublic void onCreatedTEBeautyKit(TEBeautyKit beautyKit) {mBeautyKit = beautyKit;//将mBeautyKit和美颜面板进行绑定tePanelView.setupWithTEBeautyKit(mBeautyKit);setTipListener(mBeautyKit);setLastParam(mBeautyKit);Log.e("beautyLiveAdapter", "onCreatedTEBeautyKit");}@Overridepublic void onDestroyTEBeautyKit() {mBeautyKit = null;Log.e("beautyLiveAdapter", "onDestroyTEBeautyKit");}});
//当相机或画面镜像变化时需要调用notifyCameraChanged告诉adapter 最新的状态 this.beautyAdapter.notifyCameraChanged(isFront, this.isEncoderMirror);//当屏幕方向变化的时候 需要调用 notifyScreenOrientationChange方法this.beautyAdapter.notifyScreenOrientationChanged(orientation);
//当不再需要美颜时可以调用unbind方法解除绑定关系 this.beautyAdapter.unbind();
/** * 用于恢复贴纸中的声音 * 恢复陀螺仪传感器,一般在Activity的onResume方法中调用 */ this.mBeautyKit.onResume()
/** * 用于暂停贴纸中的声音 * 暂停陀螺仪传感器,一般在Activity的onPause方法中调用 */ this.mBeautyKit.onPause()
文档反馈