Contact us
tel:15797766463
mail:business@seeshiontech.com
Update time : 2019-10-16 14:54:37
SXTemplate by calling its contructor, pass template package file path and TemplateUsage.kForRender as arguments.SXTemplate instance by calling its setReplaceableFilePaths method.SXTemaplate instance, you need call its commit method first. Then you can accesss assets and layers by their UI Keys.SXTemplateRender by calling its constructor, and passing your SXTemplate instance as an argument, you can also set a audio file as background audio by passing its file path as second argument, set the output file path by pass a absolute file pass as the third argument. The output file path must be a absolute file path that ends with .mp4 extension.null to music path argument, then the rendering result will have template\'s default music file as background music(if the template has a default music file exported).setRenderListener method of your SXTemplateRender instance to set a render status listener. start method of your SXTemplateRender instance to start rendering. SXTemplateRender instance and SXTemplate instance to null to free memory.String folder = \"path/to/your/template/folder\";//unzipped template folder path
String[] paths = {\"user/asset/file/1.png\", \"user/asset/file/2.png\", \"user/asset/file/3.png\"}; //user asset files, used to replace template\'s editable asset files
SXTemplate template = new SXTemplate(mTemplateFolder, SXTemplate.TemplateUsage.kForRender);
template.setReplaceableFilePaths(paths);
template.commit();
String outputPath = \"path/to/your/output/file.mp4\";//absolute output video file path
SXTemplateRender render = new SXTemplateRender(template, null, outputPath);
//set render status listener
render.setRenderListener(new SXRenderListener() {
@Override
public void onStart() {
// render started
}
@Override
public void onUpdate(int progress) {
// render updated, progress is current rendered frame count
}
@Override
public void onFinish(boolean success, String msg) {
// render finished, if failed, msg contains the error message
}
@Override
public void onCancel() {
// render concelled by user
}
});
render.start();
If onFinish callback is called with the success argument as false, it means the render has filed.Then you can check the error code by calling getErrorCode method of SXTemplateRender class.
NO_ERROR = 0; // No error
UNKNOWN_ERROR = 1; // Unknown system error, you can check msg argument of onFinish for detail
CANCELLED = 2; // Render is cancelled
LICENSE_ERROR = 3; // License is invalid
CODEC_ERROR = 4; // Media encoder error, can not encode video
NETWORK_ERROR = 5; // Can not connect to network
AUDIO_NOT_SUPPORT = 6; // Unsupported audio file encode format