首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何查看使用QTKit转换影片的进度?

如何查看使用QTKit转换影片的进度?
EN

Stack Overflow用户
提问于 2010-10-03 12:30:43
回答 1查看 556关注 0票数 0

如何查看使用以下QTKit代码转换电影的进度?

代码语言:javascript
复制
NSDictionary *dict = [NSDictionary 
     dictionaryWithObjectsAndKeys:
     [NSNumber numberWithBool:YES], QTMovieExport, 
     [NSNumber numberWithLong:kQTFileType3GPP], 
     QTMovieExportType, nil];

[[movieView movie] writeToFile:@"/tmp/sample.3gp" 
     withAttributes:dict];

即,我想查看电影转换的进度,以便我可以在进度条中显示它。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-10-03 12:46:05

摘自该网站:http://www.mactech.com/articles/mactech/Vol.21/21.08/Threads/index.html

如果电影非常大,则此方法可能需要相当长的时间才能完成。在此期间,用户将无法对应用程序执行任何操作,只能四处移动窗口。不是很令人兴奋。

稍微好一点的解决方案是使用movie:shouldContinueOperation:withPhase:atPercent:withAttributes:委托方法。这是QuickTime的电影进度函数的包装器,它将用于显示显示导出进度的对话框,并允许用户取消操作。这里,试试这个

代码语言:javascript
复制
- (BOOL)movie:(QTMovie *)movie 
      shouldContinueOperation:(NSString *)op 
      withPhase:(QTMovieOperationPhase)phase 
      atPercent:(NSNumber *)percent 
      withAttributes:(NSDictionary *)attributes
{
   OSErr err = noErr;
   NSEvent *event;
   double percentDone = [percent doubleValue] * 100.0;

   switch (phase) {
      case QTMovieOperationBeginPhase:
         // set up the progress panel
         [progressText setStringValue:op];
         [progressBar setDoubleValue:0];

         // show the progress sheet
         [NSApp beginSheet:progressPanel 
            modalForWindow:[movieView window] modalDelegate:nil 
            didEndSelector:nil contextInfo:nil];
         break;
      case QTMovieOperationUpdatePercentPhase:
         // update the percent done
         [progressBar setDoubleValue:percentDone];
         [progressBar display];
         break;
      case QTMovieOperationEndPhase:
         [NSApp endSheet:progressPanel];
         [progressPanel close];
         break;
   }

   // cancel (if requested)
   event = [progressPanel 
         nextEventMatchingMask:NSLeftMouseUpMask 
         untilDate:[NSDate distantPast] 
         inMode:NSDefaultRunLoopMode dequeue:YES];
   if (event && NSPointInRect([event locationInWindow], 
                                          [cancelButton frame])) {
      [cancelButton performClick:self];
      err = userCanceledErr;
   }

   return (err == noErr);
}

希望这能有所帮助。

如果你需要任何帮助,请告诉我。让我知道这是否对lil有帮助。

主键

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3848612

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档