简体   繁体   English

实时视频流iphone

[英]Live Video Stream iphone

I am new to iphone and Objective-c. 我是iphone和Objective-c的新手。 I want to show a live going match suppose football match to the users who use my app. 我想向使用我的应用程序的用户展示一场实时比赛,假设足球比赛。 What do i need for live video streaming in iphone app ? 我需要在iPhone应用程序中进行实时视频流传输吗?

any info on this is appreciated ! 任何信息对此表示赞赏!

Thanks 谢谢

Guys please help anyone must have done this before ? 伙计们,请帮助任何必须在此之前完成的人?

You only need to give the URL of the movie file and the streams will automatically be setup according to the speed of your connection. 您只需要提供电影文件的URL,就会根据您的连接速度自动设置流。

Mind you, only those videos whose resolution is within iPhone's limits will get played. 请注意,只有分辨率在iPhone限制范围内的视频才能播放。 Higher resolution movies will get played on Simulator but will not work on iPhone. 较高分辨率的电影将在Simulator上播放,但不能在iPhone上播放。

You need to have an object of MPMoviePlayerController and the rest of the code is like this: 您需要有一个MPMoviePlayerController对象,其余代码如下:

-(void) play {

NSURL *movieURL = [NSURL URLWithString:@"http://movies.apple.com/media/us/mac/getamac/2009/apple-mvp-biohazard_suit-us-20090419_480x272.mov"];


if (movieURL != nil) {
    moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];

    moviePlayer.initialPlaybackTime = -1.0;

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

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(endPlay:) 
                                                 name:MPMoviePlayerPlaybackDidFinishNotification 
                                               object:moviePlayer];

    moviePlayer.scalingMode = MPMovieScalingModeAspectFit; 
    moviePlayer.movieControlMode = MPMovieControlModeDefault;
    moviePlayer.backgroundColor = [UIColor blackColor];

    [moviePlayer play];
 }
}

-(void)moviePlayBackDidFinish: (NSNotification*)notification
{
self.navigationItem.hidesBackButton = FALSE;
moviePlayer = [notification object];
[moviePlayer play];
}

-(void)endPlay: (NSNotification*)notification
{
NSLog(@"end Playing");

self.navigationItem.hidesBackButton = FALSE;
//[[UIApplication sharedApplication] endIgnoringInteractionEvents];
[actview stopAnimating];

[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerScalingModeDidChangeNotification object:moviePlayer];
[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer];

[moviePlayer stop];
[moviePlayer release];
}

Presuming you have video rights to the football match in question, you need an encoder which will encode live video, on the fly to the right format (mp4, h263 etc.). 假设您拥有所讨论足球比赛的视频权利,则需要一个编码器,该编码器将实时编码实时视频到正确的格式(mp4,h263等)。 The iPhone method of playing these is to have a dynamic playlist which will look through chunks of the live video to play it out. iPhone播放这些文件的方法是拥有一个动态播放列表,该播放列表将查看实时视频的一部分以进行播放。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM