【发布时间】:2012-07-16 03:00:41
【问题描述】:
所以我有一个UITableView,它读取NSDocumentDirectory 并在此表中显示(在一个数组中)它的内容。
当您触摸一个单元格时,比如说 “21 Jump Street.mp4”(这是一个电影预告片应用程序),它应该会为您播放标题为 “21 Jump Street.mp4”的预告片。 mp4" 在文档文件夹中。
但是当我播放电影时,我得到的只是黑屏。如果您点击屏幕,您会看到状态栏出现,然后在您点击时一遍又一遍地消失。这是我在“didSelectRowAtIndexPath”中的代码:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSArray *fileList = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:documentsDirectory error:nil];
NSString *movieLocal = [fileList objectAtIndex:indexPath.row];
NSURL *fileURL = [NSURL fileURLWithPath:movieLocal isDirectory:NO];
NSLog(@"%@", fileURL);
moviePlayer3 = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
moviePlayer3.controlStyle = MPMovieControlStyleDefault;
moviePlayer3.shouldAutoplay = YES;
[self.view addSubview:moviePlayer3.view];
[moviePlayer3 setFullscreen:YES animated:YES];
当我NSLog fileURL时,它显示的是这样的:
21%20Jump%20Street.mp4 -- file://localhost/
任何帮助都会很棒。非常感谢!
【问题讨论】:
-
moviePlayer3是实例变量还是局部变量?
-
抱歉,这是我的 .h 中的一个实例变量。一个 mpmovieplayer 控制器。
标签: iphone ios mpmovieplayercontroller movieplayer nsdocumentdirectory