在iPhone上播放视频

时间:2012-06-18 09:05:30

标签: iphone ios streaming video-streaming

我想在iPhone中从ftp流式传输大型视频。该视频的大小超过500 MB。我从未做过流媒体,所以不知道它。我已经检查了Apple的实时流媒体指南,但它没有提供有关iPhone编码的任何帮助。有人能帮助我在iPhone编码中做些什么吗?到目前为止,我已经做了以下事情:

MPMoviePlayerViewController *mpvc = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:@"http://www.defencecourse.com/digital-reproductions/yellow-belt.mp4"]];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification
                                           object:nil];
mpvc.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;

[self presentMoviePlayerViewControllerAnimated:mpvc];
[mpvc release];

此编码是否足以播放流媒体视频?

我有一个人为我准备视频我应该如何要求他对服务器上的视频做些什么?我应该问他只是在服务器或别的东西上分割视频吗? 有人可以建议我最好的前进方式吗?

问候
的Pankaj

2 个答案:

答案 0 :(得分:0)

查看这些教程AVFoundation Tutorials并阅读Apple的AVFoundation Framework编程指南here

AVFoundation Framework功能更强大。

答案 1 :(得分:0)

嗨,你必须在iPhone手机上做一些事情......

- (void)btnClose_clicked {

[appDelegate.navShowController dismissModalViewControllerAnimated:YES];

} - (IBAction)btnPlay_clicked {

//    NSString *urlStr = [[NSBundle mainBundle] pathForResource:@"3idiots.mov" ofType:nil];
//   NSURL *url =[NSURL fileURLWithPath:urlStr];
NSURL *url = [[NSURL alloc] initWithString:[self.DiscAnsDetail objectForKey:@"product_video"]];  
MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];  

// Register to receive a notification when the movie has finished playing.  
[[NSNotificationCenter defaultCenter] addObserver:self  
                                         selector:@selector(moviePlayBackDidFinish:)  
                                             name:MPMoviePlayerPlaybackDidFinishNotification  
                                           object:moviePlayer];  

if ([moviePlayer respondsToSelector:@selector(setFullscreen:animated:)]) {  
    // Use the new 3.2 style API  
    moviePlayer.controlStyle = MPMovieControlStyleDefault;  
    moviePlayer.shouldAutoplay = YES;  
    [self.view addSubview:moviePlayer.view];  
    [moviePlayer setFullscreen:YES animated:YES];  
} else {  
    // Use the old 2.0 style API  
    moviePlayer.movieControlMode = MPMovieControlModeHidden;  
    [moviePlayer play];  
}  

} - (void)moviePlayBackDidFinish:(NSNotification *)通知{
    MPMoviePlayerController * moviePlayer = [通知对象];
    [[NSNotificationCenter defaultCenter] removeObserver:self
                                                    名称:MPMoviePlayerPlaybackDidFinishNotification
                                                  对象:moviePlayer];

// If the moviePlayer.view was added to the view, it needs to be removed  
if ([moviePlayer respondsToSelector:@selector(setFullscreen:animated:)]) {  
    [moviePlayer.view removeFromSuperview];  
}  

[moviePlayer release];  

}