在IOS中通过HTTPstream式传输video

我正在我的应用程序工作,有要求在iPhone上播放video服务器。 我有一个video链接http://www.cwtmedia.se/cwtvideo.mp4 。 任何机构可以build议我如何执行此MPMoviePlayerController.I使用此代码,但它不工作。

enter code here NSURL *url = [NSURL fileURLWithPath:@"http://www.cwtmedia.se/cwtvideo.mp4"]; moviePlayer1 = [[MPMoviePlayerController alloc] initWithContentURL:url]; [self.view addSubview:moviePlayer1.view]; moviePlayer1.view.frame = CGRectMake(0, 0, 320, 416); moviePlayer1.fullscreen=YES; [moviePlayer1 setFullscreen:NO animated:YES]; moviePlayer1.controlStyle = MPMovieControlStyleFullscreen; [moviePlayer1 play]; 

顺便说一句,这里是我如何使用mpmovieplayercontroller进行stream式处理:

 NSURL *url = [NSURL URLWithString:videoUrl]; moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url]; [moviePlayer setControlStyle:MPMovieControlStyleDefault]; moviePlayer.scalingMode = MPMovieScalingModeAspectFit; CGRect frame; if(self.interfaceOrientation ==UIInterfaceOrientationPortrait) frame = CGRectMake(20, 69, 280, 170); else if(self.interfaceOrientation ==UIInterfaceOrientationLandscapeLeft || self.interfaceOrientation ==UIInterfaceOrientationLandscapeRight) frame = CGRectMake(20, 61, 210, 170); [moviePlayer.view setFrame:frame]; // player's frame must match parent's [self.view addSubview: moviePlayer.view]; [self.view bringSubviewToFront:moviePlayer.view]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer]; [moviePlayer prepareToPlay]; [moviePlayer play]; 

然后这是委托方法:

 - (void) moviePlayBackDidFinish:(NSNotification*)notification { MPMoviePlayerController *player = [notification object]; [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:player]; if ([player respondsToSelector:@selector(setFullscreen:animated:)]){ //self.navigationController.navigationBarHidden = YES; [player.view removeFromSuperview]; } } 

希望对你有帮助..

据我所知你有两个select:

1)首先下载文件并在本地播放。 喜欢这个:

  NSString *url = [[NSBundle mainBundle] pathForResource:@"cwtvideo" ofType:@"mp4"]; MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:url]]; 

2)使用HTTPstream媒体协议。 据我所知, HTTPstream媒体是MPMoviePlayerController唯一已知的stream媒体协议。

希望这可以帮助。

干杯!