Contact us
tel:15797766463
mail:business@seeshiontech.com
Update time : 2019-10-26 22:59:40
Create an instance of SXTemplate by calling its contructor, pass template package file path and SXTemplateUsage::SXTemplateUsagePreview as arguments.
Pass user asset files to SXTemplate instance by calling its setReplaceableFilePaths method.
Create an instance of SXTemplatePlayer 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.
Call commit method of your SXTemaplate instance.
(Optional) You can accesss assets and layers by their UI Keys.
Get bound SXPlayerView for your SXTemplatePlayer instance by calling its getPlayerView method. SXPlayerView is a subclass of UIView, add it to your insterface to display the rendering result.
Set the delegate property for the SXTemplatePlayer instance.
Control the preview playback by calling start, seek, pause, stop methods of your SXTemplatePlayer instance.
SXTemplate *sxTemplate = [[SXTemplate alloc] init:@\"Your template path\" type:SXTemplateUsagePreview];
[sxTemplate setReplaceableFilePaths:@[@\"asset path\"]];
SXTemplatePlayer *player = [[SXTemplatePlayer alloc] initWithTemplate:sxTemplate audioPath:@\"audio path\"];
UIView *playView = [player getPlayerView];
int videoWidth = [sxTemplate mainCompWidth];
int videoHeight = [sxTemplate mainCompHeight];
CGFloat scale = videoHeight / self.view.bounds.size.height;
playView.bounds = CGRectMake(0, 0, videoWidth / scale, self.view.bounds.size.height);
playView.center = CGPointMake(self.view.bounds.size.width/2, self.view.bounds.size.height / 2);
[self.view addSubview:playView];
player.delegate = self;
[sxTemplate commit];
[player start];
SXTemplate instance with SXTemplateUsagePreview type. setReplaceableFilePaths method, you need to pass local file paths