我正在尝试从 URL 播放视频,我想要播放的视频是这样的 iTunes 预览视频:http: //a236.v.phobos.apple.com/us/r1000/051/Video/ec/1d/ 7f/mzm.hwbfvfdq..640x480.h264lc.d2.p.m4v 我在 iPhone 上试过,打开播放器,我看到缓冲区已加载,但如果我播放它我什么都看不到,我怎么能做什么?...这是代码:
- (void) moviePlayBackDidFinish:(NSNotification*)notification {
MPMoviePlayerController *moviePlayer = [notification object];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
if ([moviePlayer
respondsToSelector:@selector(setFullscreen:animated:)])
{
[moviePlayer.view removeFromSuperview];
}
[moviePlayer release];
}
- (IBAction)playVideo:(id)sender {
NSURL *url = [NSURL URLWithString:@"http://a236.v.phobos.apple.com/us/r1000/051/Video/ec/1d/7f/mzm.hwbfvfdq..640x480.h264lc.d2.p.m4v"];
MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
moviePlayer.controlStyle = MPMovieControlStyleDefault;
moviePlayer.shouldAutoplay = YES;
[self.view addSubview:moviePlayer.view];
[moviePlayer setFullscreen:YES animated:YES];
}