我的应用程序的视频录制功能成功记录并保存在设备的文档目录中(当我插入设备时我可以从iTunes访问)。我的问题是,我使用APP进行播放视频的View UI,无法访问或播放。
这是我的视频网址= /var/mobile/Applications/C13AB577-FFB2-4814-BD39-A9835A2DAE28/Documents/WO-00604-140428101904.349.mp4
我的实施代码是:
mediaUrl = [mediaUrl URLByAppendingPathComponent:mediaName];
mediaPlayer.movieSourceType = MPMovieSourceTypeStreaming;
mediaPlayer = [[MPMoviePlayerController alloc] init];
mediaPlayer.controlStyle=MPMovieControlStyleDefault;
mediaPlayer.contentURL = mediaUrl;
mediaPlayer.shouldAutoplay = YES;
mediaPlayer.controlStyle=MPMediaTypeAnyVideo;
[mediaPlayer prepareToPlay];
[mediaPlayer.view setFrame: CGRectMake(0, 0, 360.0, 480.0)];
[self.view addSubview:mediaPlayer.view];
[mediaPlayer play];
调试中的mediaURL具有该值:http://prntscr.com/3e6ohi
答案 0 :(得分:0)
我使用当前代码成功运行,我认为你应该检查你的mediaURL:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil;
basePath = [basePath stringByAppendingString:@"/MyVideo.mp4"];
NSURL *url = [NSURL fileURLWithPath:basePath];
mediaPlayer.contentURL = url;