我必须在我的Iphone
应用程序中播放视频,但我无法找到以下链接是什么类型以及如何播放它? This video。在许多方面进行了测试,但仍未找到最佳实践。
答案 0 :(得分:0)
试试吧
在.h文件中声明的MPMoviePlayerController
-(void)playVideo:(id)sender
{
NSURL *movieURL = [NSURL URLWithString:[[newsFeedsMA objectAtIndex:0] valueForKey:@"url"]];
_player = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
[self.view addSubview:_player.view];
[_player prepareToPlay];
_player.controlStyle = MPMovieControlStyleDefault;
_player.shouldAutoplay = YES;
[_player setFullscreen:YES animated:YES];
}
//Notification method:
- (void) moviePlayBackDidFinish:(NSNotification*)notification
{
MPMoviePlayerController *player = [notification object];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification object:player];
if ([player respondsToSelector:@selector(setFullscreen:animated:)])
{
[player.view removeFromSuperview];
}
}