tencent cloud

Feedback

Last updated: 2024-09-14 09:39:20

    SDK Integration

    1. Integration TencentEffect
    2. Integration TEBeautyKit
    Add panel JSON file(optional if not using default panel)
    3. Integrationte_adapter_live
    Maven Dependencies
    AAR Dependencies
    Add the dependency for te_adapter_live in dependencies
    dependencies{
    ...
    implementation 'com.tencent.mediacloud:te_adapter_live:Version number'
    }
    Download AAR file (a zip file will be downloaded; extract it to get the AAR file).
    Add the downloaded te_adapter_live_xxxx.aar file to the app project libs directory.
    Open build.gradle in the app module and add a dependency reference:
    dependencies{
    ...
    implementation fileTree(dir: 'libs', include: ['*.jar','*.aar']) //add *.aar
    }
    Refer to MLVB demo project.

    SDK Usage Steps

    Step 1: Set the Effect Resoures Path

    TEBeautyKit.setResPath((new File(getFilesDir(), "xmagic_dir").getAbsolutePath()));

    Step 2: Set Panel's JSON File

    Please append the path of the JSON file added to your project in the second step of the 'How to Integrate' section in the TEBeautyKit Integration Document. If there is no JSON file, then the path Setting should be null.
    TEUIConfig.getInstance().setTEPanelViewRes("beauty_panel/beauty.json",null, "beauty_panel/lut.json", "beauty_panel/motions.json", "beauty_panel/makeup.json", "beauty_panel/segmentation.json");
    Note: If you do not use the provided beauty panel, please ignore this step.

    Step 3: Copy Effect Resources

    Copy the beauty resources to the path under Step One in Setting, one version only needs to be copied successfully once.
    new Thread(() -> { boolean result = TEBeautyKit.copyRes(MainActivity.this.getApplicationContext()); runOnUiThread(() -> { if (result) { saveCopyData(); } teProgressDialog.dismiss(); checkLicense(); }); }).start();

    Step 4: Authenticate

    TEBeautyKit.setTELicense(this.getApplicationContext(),LicenseConstant.mXMagicLicenceUrl,LicenseConstant.mXMagicKey, (i, s) -> { if (i == LicenseConstant.AUTH_STATE_SUCCEED) { Intent intent = new Intent(MainActivity.this, ThirdBeautyActivity.class); startActivity(intent); } else { Log.e(TAG, "te license check is failed,please checke "); } });

    Step 5: Initialize the adapter and the panel

    this.beautyLiveAdapter = new TEBeautyLiveAdapter();
    // Set the phone orientation this.beautyLiveAdapter.notifyScreenOrientationChanged(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    // Set the camera to front-facing or rear-facing, and whether to use encoding mirror 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) { // Used to restore the last beauty effects this.tePanelView.setLastParamList(lastParamList); }
    this.tePanelView.showView(this); panelLayout.addView(this.tePanelView); }
    Note:If you do not want to use the provided panel, you can skip creating TEPanelView and configure the beauty attributes yourself by calling TEBeautyKit's setEffect to set beauty attributes.

    Step 6. Create Beauty

    this.beautyLiveAdapter.bind(this, mLivePusher, new ITEBeautyAdapter.CallBack() {
    @Override
    public void onCreatedTEBeautyKit(TEBeautyKit beautyKit) {
    mBeautyKit = beautyKit;
    tePanelView.setupWithTEBeautyKit(mBeautyKit);
    setTipListener(mBeautyKit);
    setLastParam(mBeautyKit);
    Log.e("beautyLiveAdapter", "onCreatedTEBeautyKit");
    }
    
    @Override
    public void onDestroyTEBeautyKit() {
    mBeautyKit = null;
    Log.e("beautyLiveAdapter", "onDestroyTEBeautyKit");
    }
    });
    

    Step 7. Notify adapter while Parameter Changed

    //Notify adapter of the latest status when the camera or screen mirror changes this.beautyLiveAdapter.notifyCameraChanged(isFront, this.isEncoderMirror);
    //When the screen orientation changes, you need to call the notifyScreenOrientationChange method
    this.beautyLiveAdapter.notifyScreenOrientationChanged(orientation);
    

    Step 8: Destroy Effect

    //You can call the unbind method to unbind when the beauty filter is no longer needed
    this.beautyLiveAdapter.unbind();

    Step 9: Resume Audio

    /** * Used to restore sound in stickers * Restore gyroscope sensor, usually called in the onResume method of Activity */ this.mBeautyKit.onResume()

    Step 10: Pause Audio

    /** * Used to pause sound in stickers * Pause gyroscope sensor, usually called in the onPause method of Activity */ this.mBeautyKit.onPause()
    
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support