- Define Banuba SDK version in the android build.gradle:
ext {
bnb_sdk_version = '1.16.+'
}
- Add the source and version of the Banuba SDK in the IOS Podfile:
source 'https://github.com/sdk-banuba/banuba-sdk-podspecs.git'
$bnb_sdk_version = '~> 1.16.0'
- Add NSCameraUsageDescription in the Info.plist:
<key>NSCameraUsageDescription</key>
<string>We use camera to render AR effects</string>
- Init
BanubaSdkManager
:
await _banubaSdkManager.initialize([],
"Client Token",
SeverityLevel.info);
- Attach
EffectPlayerView
toBanubaSdkManager
:
final _epWidget = EffectPlayerWidget(key: null);
...
await _banubaSdkManager.attachWidget(_epWidget.banubaId);
- Start player:
await _banubaSdkManager.openCamera();
await _banubaSdkManager.startPlayer();
- Load and apply Effect:
await _banubaSdkManager.loadEffect("path to the effect", false);
Banuba Face AR SDK product is used on camera for applying various AR effects while making a content:
- Android - Add the folder with your effects to your project and setup it in the android build.gradle app module:
task copyEffects {
copy {
from flutter.source + '/effects'
into 'src/main/assets/bnb-resources/effects'
}
}
gradle.projectsEvaluated {
preBuild.dependsOn(copyEffects)
}
- IOS - just link effects folder into
Runner
Xcode project (File
->Add Files to 'Runner'...
).
- Releases common Banuba SDK resources:
static void deinitialize() {}
- Creates and attaches render processing to a specific view:
void attachWidget(int banubaId);
- Closes Camera:
void closeCamera();
- Stops render processing. Effects will not be applied:
void stopPlayer();
- Unloads effect. Invoke this method after startPlayer:
void unloadEffect();
- Used for passing specific expressions to interact with an effect:
void evalJs(String script);
- Sets camera zoom level:
void setZoom(double zoom);
- Enables flashlight. Available only for back camera facing:
void enableFlashlight(bool enabled);
- Start video recording:
void startVideoRecording(
String filePath, bool captureAudio, int width, int height);
- Stops video recording:
void stopVideoRecording();
- Takes photo from camera:
void takePhoto(String filePath, int width, int height);
- Sets camera facing: front, back:
void setCameraFacing(bool front);
- Processes image with applied effect:
void processImage(String sourceFilePath, String destFilePath);
- Starts image editing mode:
void startEditingImage(String sourceImageFilePath);
- Ending editing image and save result to destination file:
void endEditingImage(String destImageFilePath);
- Discard editing image mode:
void discardEditingImage();