QTKit strange error

允我心安 提交于 2019-12-25 08:54:15

问题


just simple peace of code (file 1.mp3 clicked and playing as well in iTunes) :

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {

NSError *outError = nil;
QTMovie *newMovie = [QTMovie movieWithURL:[NSURL URLWithString:@"/Users/Alex/1.mp3"] error:&outError];
if (newMovie) {
    //[newMovie setAttribute:[NSNumber numberWithBool:YES] forKey:QTMovieEditableAttribute];

    [self setMovie:newMovie];
}
[movie play];

give me error

  • Error Domain=NSOSStatusErrorDomain Code=-2000 UserInfo=0x2004a6de0 "A necessary data reference could not be resolved."

回答1:


Changing

[movie play];

to

[movie autoplay];

might help you. QTMovie loads the data in the background, so asking it to play right after it's created might be too quick for the QTMovie to really play the file.




回答2:


You need to create a file:-based NSURL using fileURLWithPath:, not URLWithString:. URLWithString: is meant for URLs like http:, etc.

Try:

QTMovie *newMovie = [QTMovie movieWithURL:
   [NSURL fileURLWithPath:@"/Users/Alex/1.mp3"] error:&outError];


来源:https://stackoverflow.com/questions/5582274/qtkit-strange-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!