更新时间 : 2023-07-18 09:33:10
直接渲染
//如果无需替换素材,可以用渲染引擎直接渲染
//SXTemplateUsageRender 渲染模板
SXTemplate *sxTemplate = [[SXTemplate alloc] init:@"Your template path" type:SXTemplateUsageRender];
NSString *musicPath = [:@"Your template path" stringByAppendingPathComponent:@"music.mp3"];
if (![[NSFileManager defaultManager] fileExistsAtPath:musicPath]) {
musicPath = @"";
}
SXTemplateRender *render = [[SXTemplateRender alloc] initWithTemplate:sxTemplate audioPath:musicPath];
render.delegate = self;
[sxTemplate commit];
[render start];
代理方法
//渲染成功返回视频地址
- (void)templateRenderFinished:(NSURL *) tempUrl {
}
//渲染失败
- (void)templateRenderFailed:(NSError *)error {
}
//开始渲染
- (void)templateRenderStarted {
//注:切换app,锁屏或退出到后台会导致渲染失败
}
//渲染取消 [render cancel];
- (void)templateRenderCancelled {
}
//渲染进度回调
- (void)templateRenderProgress:(float)progress {
}
直接渲染
//如果无需替换素材,可以用渲染引擎直接渲染
//SXTemplateUsageRender 渲染模板
SXTemplate *sxTemplate = [[SXTemplate alloc] init:@"Your template path" type:SXTemplateUsageRender];
NSString *musicPath = [:@"Your template path" stringByAppendingPathComponent:@"music.mp3"];
if (![[NSFileManager defaultManager] fileExistsAtPath:musicPath]) {
musicPath = @"";
}
SXTemplateRender *render = [[SXTemplateRender alloc] initWithTemplate:sxTemplate audioPath:musicPath];
render.delegate = self;
[sxTemplate commit];
[render start];
代理方法
//渲染成功返回视频地址
- (void)templateRenderFinished:(NSURL *) tempUrl {
}
//渲染失败
- (void)templateRenderFailed:(NSError *)error {
}
//开始渲染
- (void)templateRenderStarted {
//注:切换app,锁屏或退出到后台会导致渲染失败
}
//渲染取消 [render cancel];
- (void)templateRenderCancelled {
}
//渲染进度回调
- (void)templateRenderProgress:(float)progress {
}