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 Support / iPhone Simulator / 7.0.3 / Applications / F0B3AD63-7E46-4069-8845-8B0C05425CD2 / CosMos.app / PTCL.mp4
> file:/// Users / utkal / Library / Application Support / iPhone Simulator / 7.0.3 / Applications / F0B3AD63-7E46-4069-8845-8B0C05425CD2 / CosMos.app / PTCL.mp4
我有alos使用
NSURL *videoURL = [[NSURL alloc]init]; videoURL = [[NSBundle mainBundle] URLForResource:@"PTCL" withExtension:@"mp4"];
但我的视频播放器总是显示文件正在加载,没有任何反应.
我知道我在哪里做错了,但我的运气不好.
请更正我的错误或告诉我是否有其他方式播放本地视频文件.请.
解决方法
也许为时已晚,但我会尝试这样的事情:
MPMoviePlayerViewController *movieVC = [[MPMoviePlayerViewController alloc] initWithContentURL:file.location]; movieVC.moviePlayer.movieSourceType = MPMovieSourceTypeFile; movieVC.moviePlayer.fullscreen = YES; movieVC.moviePlayer.allowsAirPlay = YES; movieVC.moviePlayer.controlStyle = MPMovieControlStyleFullscreen; [self presentMoviePlayerViewControllerAnimated:movieVC];
注意“movieVC.moviePlayer.movieSourceType = MPMovieSourceTypeFile;”
原文地址:https://www.jb51.cc/iOS/328160.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。