te_adapter_livete_adapter_live 库的依赖dependencies{...implementation 'com.tencent.mediacloud:te_adapter_live:版本号'}
.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 时填写的包名。MLVB 能力,所以需要在 Debug module 下找到 com.tencent.mlvb.debug.GenerateTestUserSig.java 文件,并添加对应的 LICENSEURL,LICENSEURLKEY,SDKAPPID,SECRETKEY。com.tencent.mlvb.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.beautyLiveAdapter = new TEBeautyLiveAdapter(XmagicConstant.EffectMode.PRO, TEBeautyKit.getResPath());//设置手机朝向 this.beautyLiveAdapter.notifyScreenOrientationChanged(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);//设置相机是前置摄像头还是后置摄像头,以及是否编码镜像 this.beautyLiveAdapter.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.beautyLiveAdapter.bind(this, mLivePusher, new ITEBeautyAdapter.CallBack() {@Overridepublic void onCreatedTEBeautyApi(XmagicApi xmagicApi) {mBeautyKit = new TEBeautyKit(xmagicApi);tePanelView.setupWithTEBeautyKit(mBeautyKit);setTipListener(mBeautyKit);setLastParam(mBeautyKit);Log.e("beautyLiveAdapter", "onCreatedTEBeautyKit");}@Overridepublic void onDestroyTEBeautyApi() {mBeautyKit = null;Log.e("beautyLiveAdapter", "onDestroyTEBeautyKit");}});
this.beautyLiveAdapter.bind(this, mLivePusher, new ITEBeautyAdapter.CallBack() {@Overridepublic void onCreatedTEBeautyKit(TEBeautyKit beautyKit) {mBeautyKit = beautyKit;tePanelView.setupWithTEBeautyKit(mBeautyKit);setTipListener(mBeautyKit);setLastParam(mBeautyKit);Log.e("beautyLiveAdapter", "onCreatedTEBeautyKit");}@Overridepublic void onDestroyTEBeautyKit() {mBeautyKit = null;Log.e("beautyLiveAdapter", "onDestroyTEBeautyKit");}});
//当相机或画面镜像变化时需要调用notifyCameraChanged告诉adapter 最新的状态 this.beautyLiveAdapter.notifyCameraChanged(isFront, this.isEncoderMirror);//当屏幕方向变化的时候 需要调用 notifyScreenOrientationChange方法this.beautyLiveAdapter.notifyScreenOrientationChanged(orientation);
//当不再需要美颜时可以调用unbind方法解除绑定关系this.beautyLiveAdapter.unbind();
/** * 用于恢复贴纸中的声音 * 恢复陀螺仪传感器,一般在Activity的onResume方法中调用 */ this.mBeautyKit.onResume()
/** * 用于暂停贴纸中的声音 * 暂停陀螺仪传感器,一般在Activity的onPause方法中调用 */ this.mBeautyKit.onPause()
文档反馈