QTMovie 分配问题,有时结果为空
所以我的程序中有一个奇怪的错误,我有一个 QTMovieView 在电影之间随机播放,这很完美。在程序的另一部分中,您可以录制一些视频,稍后在视频随机播放器中显示。这是我可能遇到问题的地方。
有时,大约 75% 的情况下,当视频循环尝试分配新视频之一时,它会返回 null。但如果我重新启动程序,显示这些视频就没有问题。
由于视频文件位于正确的位置,因此调用完全相同,它认为很奇怪,它有时只在录制后起作用,并且在我重新启动应用程序时总是起作用。
下面的代码是我用来加载视频的代码,文件名是正确的,并且文件存在于其查找的位置。并且在我重新启动程序后它总是有效。但并不总是在录制新视频后立即进行。
我从中得到的错误是 Error Domain=NSOSStatusErrorDomain Code=-50 “操作无法完成。(OSStatus 错误 -50。)”(用户参数列表中的错误)
NSString *moviePath = [NSBundle pathForResource:fileName ofType:@"mov" inDirectory:@"/Users/Shared/Real/Movies"];
QTMovie *movie = [[QTMovie alloc] initWithFile:moviePath error:nil];
NSLog(@"fil att leta efter: %@",fileName); //the right filename
NSLog(@"vald film resultat: %@",movie); // Turns out (null) if the file is recorded in the same session
So i have this wierd error in my program where i have a QTMovieView that shuffles between movies, this works perfect. And in another part of the program you can record some videos that shows in the video shuffler later. This is where i can get problems.
Sometimes like 75% of the time when the videoloop tries to allocate one of the new videos it returns null. But if i restart my program there is no problem with showing these videos.
Since the video files are in the right place, the call is exactly the same it think its wierd that it only works sometimes after record, and always if i restart my application.
The code below is the one that i use to load my videos, fileName is right, and the file exists in where its looking. And it always works after i restart the program. But not always directly after recording a new video.
The error i get out from it is Error Domain=NSOSStatusErrorDomain Code=-50 "The operation couldn’t be completed. (OSStatus error -50.)" (error in user parameter list)
NSString *moviePath = [NSBundle pathForResource:fileName ofType:@"mov" inDirectory:@"/Users/Shared/Real/Movies"];
QTMovie *movie = [[QTMovie alloc] initWithFile:moviePath error:nil];
NSLog(@"fil att leta efter: %@",fileName); //the right filename
NSLog(@"vald film resultat: %@",movie); // Turns out (null) if the file is recorded in the same session
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的解决了,问题是 NSBundle 没有找到写入文件夹的新文件。不知道为什么它没有,但确实用
NSString* stringMoviePath = [NSString stringWithFormat:@"/Users/Shared/Real/Movies/%@.mov",fileName]; 替换了它,现在它一切都好
Okay solved it, problem was that NSBundle didn't find the new files that where written to the folder. Dont know why it doesn't but did replaced it with
NSString* stringMoviePath = [NSString stringWithFormat:@"/Users/Shared/Real/Movies/%@.mov",fileName];
and now its all good