我正在尝试从文档目录播放视频文件,但它没有在 xcode6.2 和 ios8.2 中播放

I am trying to play video file from document directory but its not playing in xcode6.2 with ios8.2

你好,我已经在研究 MPMoviePlayerController 但现在我面临着问题,我认为这可能是 xcode 或 ios

的版本问题

NSString*theMoviePath=[NSString stringWithFormat:@"%@/9441426768774.mp4", [[AppDelegate appdelegate] getDocumentDirectoryPath]]; AnandLog(@"theMovieURL :--->%@", theMoviePath); NSURL*theMovieURL=[NSURL fileURLWithPath:theMoviePath]; self.moviePlayer=[[MPMoviePlayerController alloc] initWithContentURL:theMovieURL]; [self.moviePlayer.view setFrame:CGRectMake(40, 197, 240, 160)]; [self.moviePlayer prepareToPlay]; [self.moviePlayer setShouldAutoplay:NO]; // And other options you can look through the documentation. [self.view addSubview:self.moviePlayer.view];

错误

heMovieURL :--->/Users/ndot/Library/Developer/CoreSimulator/Devices/B147415A-F1F1-4576-972B-D1AE2C36993D/data/Containers/Data/Application/36777A8E-DE7D-4B7F-A74F-DF0835568C5D/Documents/9441426768774.mp4

2015-03-20 18:47:51.948 SampleConcepts[3266:86205] 18:47:51.948 错误:98:错误“!obj”试图获取默认输入设备的采样率 2015-03-20 18:47:51.949 SampleConcepts[3266:86205] 18:47:51.949 错误:100:获取音频输入设备采样率时出错:'!obj' 2015-03-20 18:47:51.949 SampleConcepts[3266:86205] 18:47:51.949 警告:230:输入设备为 0x0; '(无效的)' 2015-03-20 18:47:51.949 SampleConcepts[3266:86205] 18:47:51.949 警告:234:输出设备为 0x26; 'AppleHDAEngineOutput:1B,0,1,2:0' 2015-03-20 18:47:51.949 SampleConcepts[3266:86205] 18:47:51.949 错误:404:错误“!obj” 2015-03-20 18:47:51.949 SampleConcepts[3266:84774] 18:47:51.949 错误:404:错误 -66680 2015-03-20 18:47:51.949 SampleConcepts[3266:86205] 18:47:51.949 错误:113:* * * NULL AQIONode 对象 2015-03-20 18:47:51.950 SampleConcepts[3266:84774] 18:47:51.949 错误:404:错误 -66680 2015-03-20 18:47:51.950 SampleConcepts[3266:86205] 18:47:51.950 错误:703:无法制作 UISound 渲染器 2015-03-20 18:47:51.950 SampleConcepts[3266:84774] 18:47:51.950 错误:404:错误 -66680 2015-03-20 18:47:51.950 SampleConcepts[3266:84774] 18:47:51.950 错误:404:错误 -66680

我的想法是问题可能在 xcode6.2 和 ios8.2, 之前有人处理过这个场景吗?

指导我解决这个问题。

是的,您的代码是正确的。您可以 运行 MPMoviePlayerControlleriOS8.1 及以上使用 XCode6.0.1 它对我来说工作正常。