AVAssetExportSession的进度条 [英] Progress bar for AVAssetExportSession

查看:1744
本文介绍了AVAssetExportSession的进度条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程式会将 AVMutableComposition 汇出为 .mov 档案,以便用户使用进度条查看导出状态,与您发送短信或上传文件时的方式相同。



我知道如何创建一个进度条,当我知道任务的持续时间(如播放音频文件),但由于没有设置的导出时间,我不确定如何继续。



有人有任何指针吗?

解决方案

我想到了一个回答,所以我会发布,以防它可以帮助某人:



首先,在调用 AVAssetExportSession 的方法中,您必须设置一个计时器来更新 UIProgressView 一旦你开始导出:

  //`AVAssetExportSession`代码在这里
self.exportProgressBarTimer = [NSTimer scheduledTimerWithTimeInterval:.1 target:self selector:@selector(updateExportDisplay)userInfo:nil repeats:YES];
...

然后,您需要一种方法来更新您的显示, progress属性 AVAssetExportSession 从0到1:

   - )updateExportDisplay {
self.exportProgressBar.progress = exportSession.progress;
if(self.exportProgressBar.progress> .99){
[self.exportProgressBarTimer invalidate];
}
}


I've got an app that exports an AVMutableComposition into a .mov file, and I'd like for the user to see the status of the export with a progress bar the same way that you would if you sent a text message or uploaded a file.

I know how to create a progress bar when I know the duration of a task (such as playing an audio file), but since there's no set duration for the export I'm unsure how to proceed.

I've got an activity indicator currently but it doesn't provide the best user experience.

Does anyone have any pointers?

解决方案

I came up with an answer a while back so I'll post it in case it can help someone:

First, in the method in which you call AVAssetExportSession you've got to set up a timer to update your UIProgressView once you've initiated the export:

//`AVAssetExportSession` code here
    self.exportProgressBarTimer = [NSTimer scheduledTimerWithTimeInterval:.1 target:self selector:@selector(updateExportDisplay) userInfo:nil repeats:YES];
...

Then you need a method to update your display taking into account that the progress property on AVAssetExportSession goes from 0 - 1:

- (void)updateExportDisplay {
    self.exportProgressBar.progress = exportSession.progress;
    if (self.exportProgressBar.progress > .99) {
        [self.exportProgressBarTimer invalidate];
    }
}

这篇关于AVAssetExportSession的进度条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆