帮你快速理解、总结文档立即下载

Android

最近更新时间:2026-11-09 14:52:03
我的收藏

功能概览

美颜、滤镜、特效(含动态贴纸类特效)统一由 ITAVEffectManager.setEffect 驱动,业务方按效果名与资源路径下发参数,SDK 负责渲染。

相关接口类

接口类名
描述
ITAVEffectManager
设置美颜/滤镜/特效参数、监听加载异常。
TAVEffectTipsListener
特效提示与素材加载失败回调。

设置效果

接口

boolean setEffect(String effectName, int effectValue, String resourcePath, Map<String, String> extraInfo);
参数
说明
effectName
效果 key。美颜项取自 XmagicConstant.BeautyConstant(如 BEAUTY_SMOOTH);滤镜与特效的 key 由各自素材配置定义。
effectValue
效果强度或取值。
resourcePath
素材路径;无需素材(如磨皮强度)时传空。
extraInfo
额外参数键值对,可传 null。
返回 true 表示已受理:渲染线程尚未就绪时会先入队,等就绪后执行,不会因此返回 false。返回 false 表示引擎不可用或下发失败(如美颜引擎未初始化、key 非法)。素材加载失败不体现在返回值上,而是通过 TAVEffectTipsListener.onLoadAssetError(int errCode) 回调。

示例

ITAVEffectManager effectManager = recorder.getEffectManager();

// 美颜:key 取自 XmagicConstant.BeautyConstant
effectManager.setEffect(XmagicConstant.BeautyConstant.BEAUTY_SMOOTH, 60, null, null);

// 滤镜:key 由素材配置定义,resourcePath 传 LUT 路径
Map<String, String> extra = new HashMap<>();
extra.put("intensity", "0.8");
effectManager.setEffect(filterKey, 80, lutPath, extra);

// 关闭某个效果:强度置 0
effectManager.setEffect(XmagicConstant.BeautyConstant.BEAUTY_SMOOTH, 0, null, null);

异常与提示

effectManager.setTipsListener(new TAVEffectTipsListener() {
@Override
public void onTipsShow(String tips, int durationMs) {
// 需要提示用户(如“素材下载中”)
}

@Override
public void onTipsHide(String tips) {
}

@Override
public void onLoadAssetError(int errCode) {
// 素材加载失败
}
});