我正在使用iphone中的视频应用。 当用户点击按钮时,它将进入第二个视图,然后从那里我正在播放来自网址的视频。
但是当用户从该视图返回并且agin转到该视频没有播放时。
连续显示以下2行
[MPAVController] Autoplay: Likely to keep up or full buffer: 0
[MPAVController] Autoplay: Skipping autoplay, not enough buffered to keep up.
这是我的代码
- (void)viewDidLoad
{
[super viewDidLoad];
self.moviePlayerController = [[MPMoviePlayerController alloc] init];
[self.moviePlayerController prepareToPlay];
self.moviePlayerController.shouldAutoplay = YES;
[[self.moviePlayerController view] setFrame:CGRectMake(-30, 72, 360,140)];
[[self view] addSubview: [self.moviePlayerController view]];
NSString *strng = [NSString stringWithFormat:@"http://quickemee_videos.s3.amazonaws.com/videoStream_1352395870143_616.mp4"];
NSLog(@"strng %@",strng);
NSURL * adurl = [NSURL URLWithString:strng];
[self playVideo:adurl];
}
。 。 。
-(IBAction)back:(id)sender{
[moviePlayerController stop];
[self.navigationController popViewControllerAnimated:YES];
}
答案 0 :(得分:2)
使用此代码
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"video_name" ofType:@"m4v"]];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
[moviePlayer prepareToPlay];
moviePlayer.view.frame = self.view.bounds;
[self.view addSubview:moviePlayer.view];
[moviePlayer play];
[moviePlayer setFullscreen:FALSE];
// if you want no control.
[moviePlayer setControlStyle:MPMovieControlStyleNone];
答案 1 :(得分:1)
首先尝试拨打[self prepareToPlay]
。
如果电话播放器在您拨打电话时尚未准备好播放 play方法,该方法自动调用此方法。但是,要 最小化播放延迟,请在调用播放前调用此方法。
<强>更新强>
确保该文件可用。我无法在浏览器中访问它。
答案 2 :(得分:1)
viewDidLoad
只被调用一次。因此,当您弹出viewController然后返回它时,不会再次调用viewDidLoad
。因此,请尝试在self.moviePlayerController = [[MPMoviePlayerController alloc] init];
- (void)viewWillAppear:(BOOL)animated