Contact us

tel:15797766463

mail:business@seeshiontech.com

中文
English
中文
登录/注册

{user.username}

ID: {user.id}

VE Development document

Preview template

Update time : 2019-10-26 22:59:40

Preview template

  1. Create an instance of SXTemplate by calling its contructor, pass template package file path and SXTemplateUsage::SXTemplateUsagePreview as arguments.

  2. Pass user asset files to SXTemplate instance by calling its setReplaceableFilePaths method.

  3. 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.

  4. Call commit method of your SXTemaplate instance.

  5. (Optional) You can accesss assets and layers by their UI Keys.

  6. 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.

  7. Set the delegate property for the SXTemplatePlayer instance.

  8. Control the preview playback by calling start, seek, pause, stop methods of your SXTemplatePlayer instance.

Example Codes

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];

Remarks