Contact us
tel:15797766463
mail:business@seeshiontech.com
Update time : 2020-08-31 10:23:33
SXPlayerSurfaceView in your layout for preview.SXTemplate by calling its contructor, pass template package file path and TemplateUsage.kForPreview 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.SXPlayerSurfaceView instance from your layout, call its setTemplate method and pass your SXTemplate instance as argument, the method will return a SXTemplatePlayer object.SXTemplatePlayer instance, you can call its replaceAudio method to set background audio.SXTemplatePlayer instance by calling its setPlayCallback method.start, seek, pause, stop methods of your SXTemplatePlayer instance.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(folder, SXTemplate.TemplateUsage.kForPreview);
template.setReplaceableFilePaths(paths);
template.commit();
SXPlayerSurfaceView playerView = findViewById(R.id.player_surface_view);
playerView.setPlayCallback(new SXTemplatePlayer.PlayStateListener() {
@Override
public void onProgressChanged(int frame) {
// render updated, frame is current rendered frame index
}
@Override
public void onFinish() {
// realtime preview finished
}
});
playerView.setTemplate(template);
SXTemplatePlayer player = playerView.getPlayer();
player.start();
pause method.stop method in your activity\'s onDestory method to make sure preview is stopped when related activity in no longer in use.setTemplate, a new player object will be returned. If you call setTemplate after calling setPlayCallback of SXPlayerSurfaceView, all the playCallback
will automatically add to the new player object. playCallback only works for current player object.