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文件。TEPanelViewResModel resModel = new TEPanelViewResModel();String combo = "S1_07"; //根据您的套餐进行设置,如果您的套餐没有包含某项功能,客户设置为nullresModel.beauty = "beauty_panel/"+combo+"/beauty.json";resModel.lut = "beauty_panel/"+combo+"/lut.json";resModel.beautyBody = "beauty_panel/"+combo+"/beauty_body.json";resModel.motion = "beauty_panel/"+combo+"/motions.json";resModel.lightMakeup = "beauty_panel/"+combo+"/light_makeup.json";resModel.segmentation = "beauty_panel/"+combo+"/segmentation.json";TEUIConfig.getInstance().setTEPanelViewRes(resModel);
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 ");}});
TEPanelView,美颜属性调用TEBeautyKit的setEffect 设置美颜属性。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);}
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()
文档反馈