3.1 导入SDK
将camerafilter2.2.1.aar、shortvideo2.2.1.aar添加到libs目录(没有目录的自行创建),在app的build.gradle文件下配置。
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
//引用SDK配置
repositories {
flatDir {
dirs 'libs'
}
}
}
//添加依赖
dependencies {
implementation(name:'shortvideo2.2.1', ext:'aar')
implementation(name:'camerafilter2.2.1', ext:'aar')
}
3.2 配置权限:
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permissionandroid:name="android.permission.WRITE_EXTERNAL_STORAGE" />
3.3 初始化滤镜
在自定义的ShortVideoApplication(这个类名可以自定义)初始化滤镜:
public class ShortVideoApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
LocalVideoFilter.init(this);
}
}
在AndroidManifest.xml文件中配置自定义的ShortVideoApplication:
<application
android:name=".ShortVideoApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">