【发布时间】:2014-01-17 03:12:17
【问题描述】:
NSString *path = [[NSBundle mainBundle] pathForResource:@"PTCL" ofType:@"mp4"];
NSURL *videoURL = [NSURL URLWithString:path];
MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];
[moviePlayerController.view setFrame:self.view.frame];
[self.view addSubview:moviePlayerController.view];
moviePlayerController.controlStyle=MPMediaTypeAnyVideo;
moviePlayerController.fullscreen = YES;
[moviePlayerController prepareToPlay];
[moviePlayerController play];
NSString *path = [[NSBundle mainBundle] pathForResource:@"PTCL" ofType:@"mp4"];
path=[NSString stringWithFormat:@"file:/%@",path];
NSURL *videoURL = [NSURL URLWithString:path];
MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];
[moviePlayerController.view setFrame:self.view.frame];
[self.view addSubview:moviePlayerController.view];
moviePlayerController.shouldAutoplay=YES;
moviePlayerController.controlStyle=MPMediaTypeAnyVideo;
moviePlayerController.fullscreen = YES;
[moviePlayerController prepareToPlay];
[moviePlayerController play];
- file:///Users/utkal/Library/Application%20Support/iPhone%20Simulator/7.0.3/Applications/F0B3AD63-7E46-4069-8845-8B0C05425CD2/CosMos.app/PTCL.mp4
我正在获取第一个代码的这个 videoURL 路径
- file:///Users/utkal/Library/Application%20Support/iPhone%20Simulator/7.0.3/Applications/F0B3AD63-7E46-4069-8845-8B0C05425CD2/CosMos.app/PTCL.mp4
我正在获取第二个代码的这个 videoURL 路径。
我也用过
NSURL *videoURL = [[NSURL alloc]init];
videoURL = [[NSBundle mainBundle] URLForResource:@"PTCL" withExtension:@"mp4"];
但我的视频播放器总是显示文件正在加载,但没有任何反应。 我知道我在哪里做错了,但我的运气不好。 请纠正我的错误或告诉我是否有其他播放本地视频文件的方法。请。
【问题讨论】:
-
请尝试:NSURL * videoURL = [NSURL fileURLWithPath:path];
-
@Horst 这也不起作用。我也有同样的问题。
-
如果你解决了这个问题告诉我,我也有同样的问题。
-
任何解决方案?
标签: ios iphone ios7 mpmovieplayercontroller