问题
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