我正在开发一个测试应用程序,它将运行来自互联网的 mp4 文件。代码是:
-(IBAction)playRemoteVideo
{
NSString *mp4File = @"http://archive.org/download/Pbtestfilemp4videotestmp4/video_test_512kb.mp4";
MPMoviePlayerViewController *playerController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:mp4File]];
[self presentMoviePlayerViewControllerAnimated:playerController];
playerController.moviePlayer.movieSourceType=MPMovieSourceTypeStreaming;
[playerController.moviePlayer play];
[playerController release];
playerController=nil;
}
当我运行应用程序并播放视频时,播放器会尝试加载视频一段时间,但在控制台上出现此异常后
2012-04-18 22:45:11.309 VideoPlayer[891:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'An AVPlayerItem can occupy only one position in a player's queue at a time.'
*** First throw call stack:
(0x1df1052 0x1333d0a 0x27cfb31 0x27cbb2a 0x27e45cc 0x103b73 0xd4e6a 0x2ff2445 0x2ff44f0 0x1d28833 0x1d27db4 0x1d27ccb 0x16d8879 0x16d893e 0x24ea9b 0x1d12 0x1c85)
terminate called throwing an exception(gdb)
例如,如果我使用 m3u8 文件执行相同的代码;
http://devimages.apple.com/iphone/samples/bipbop/gear1/prog_index.m3u8
我可以让视频运行,但同样不适用于 mp4 文件。
你知道为什么我得到这个异常以及我的代码有什么问题吗?
我在 Iphone 模拟器上运行应用程序,我有 XCode 4.2 Best Regards Tugrul