简体   繁体   English

AVExportSession完成更改视图

[英]AVExportSession change view on completion

I'm having a number of related issues using AVExportSession. 我在使用AVExportSession时遇到了许多相关问题。 I'm very aware that I could be attempting this wrong, but have tried a couple of solutions to no avail. 我非常清楚自己可能会尝试这种错误,但是尝试了几种解决方案,但均无济于事。

I'm exporting a composition using AVExportSession and then using the completion handler to trigger other code once it is done (should be within 3 seconds normally). 我正在使用AVExportSession导出合成,然后使用完成处理程序在完成后触发其他代码(通常应在3秒钟之内)。 The problem comes when I want to change view on completion. 当我想在完成时更改视图时,问题就来了。 For example, I have a button in a modal view that triggers the audio export, but I would like it subsequently shut the view on completion. 例如,我在模式视图中有一个按钮可以触发音频导出,但是我希望它随后在完成时关闭视图。 The error message i receive is quite obvious - "This may be a result of calling to UIKit from a secondary thread." 我收到的错误消息非常明显-“这可能是从辅助线程调用UIKit的结果。”

NSURL *exportURL = [NSURL fileURLWithPath:saveSong];
exportSession.outputURL = exportURL;
exportSession.outputFileType = @"com.apple.m4a-audio";
[exportSession exportAsynchronouslyWithCompletionHandler:^{
    if (AVAssetExportSessionStatusCompleted == exportSession.status) {
        NSLog(@"AVAssetExportSessionStatusCompleted");



        [[NSNotificationCenter defaultCenter] 
         postNotificationName:@"end" 
         object:self];



    } else if (AVAssetExportSessionStatusFailed == exportSession.status) {
        // a failure may happen because of an event out of your control
        // for example, an interruption like a phone call comming in
        // make sure and handle this case appropriately
        NSLog(@"AVAssetExportSessionStatusFailed");
    } else {
        NSLog(@"Export Session Status: %d", exportSession.status);
    }
}];

My current attempt involves sending a NSNotification to close the view in an attempt to jump onto the main thread. 我当前的尝试涉及发送NSNotification来关闭视图,以尝试跳到主线程上。

Very sorry if this appears unclear - part of the problem I am having in finding a solution is in expressing quite what is going wrong. 非常抱歉,如果这看起来不清楚-我在寻找解决方案时遇到的部分问题是表达了出了什么问题。 I hope that by posting my fumbled attempt at a description, somebody may have exactly the right question to ask me and thus a clue to the answer! 我希望通过将我摸索的描述发布出去,以使某人可能有正确的问题要问我,从而找到答案的线索!

This also occurs as an offshoot of another issue I am trying to resolve. 这也是我要解决的另一个问题的分支。 When I start the export, I unhide an animated UIActivityView, but when trying to hide on completion, it is about 20 seconds after the completion (NSLog-ed) that the UIActivityView finally hides 开始导出时,我会取消隐藏动画的UIActivityView,但是当尝试在完成时隐藏时,UIActivityView最终会在完成后约20秒(NSLog-ed)隐藏

solution: use [self performSelectorOnMainThread:@selector(stopActivityIndicator) withObject:nil waitUntilDone:YES]; 解决方案:使用[self performSelectorOnMainThread:@selector(stopActivityIndi​​cator)withObject:nil waitUntilDone:YES];

then call my view change/activity indicator stuff from -(void)stopActivityIndicator 然后从-(void)stopActivityIndi​​cator调用我的视图更改/活动指示符

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 iPhone 中更改键盘单词完成视图的框架? - How do I change the frame of keyboard word completion view in iPhone? 集合视图完成处理程序的PerformBatchUpdates未执行 - PerformBatchUpdates for collection view completion handler not being executed 我可以使用AVAssetWriter代替AVExportSession吗? - Can i use AVAssetWriter in place of AVExportSession? 通知活动视图完成后台任务 - Notifying the active view of background task completion 使用presentViewController呈现视图:动画:完成:当presentViewController:animated:completion:hotspot enabled时不工作 - Presenting view with presentViewController:animated:completion: not working when presentViewController:animated:completion: hotspot enabled 当应用程序进入后台状态时如何取消AVExportSession? - How to Cancel AVExportSession when app goes to background state? 使用 AVExportSession 重写 mp3 文件的 ID3 标签 - Using AVExportSession to rewrite ID3 tags of mp3 file transitionFromView:toView:duration:options:completion视图内存管理? - transitionFromView:toView:duration:options:completion view memory management? Swift:Dismiss View 的完成块什么时候执行? - Swift: When Does the Completion Block of Dismiss View Get Executed? 播放声音完成后如何关闭视图 - how can i close view after completion of playing sound
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM