Live Video Stream iphone

对着背影说爱祢 提交于 2019-12-18 13:47:15

问题


I am new to iphone and 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 ?

any info on this is appreciated !

Thanks

Guys please help anyone must have done this before ?


回答1:


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.

Mind you, only those videos whose resolution is within iPhone's limits will get played. Higher resolution movies will get played on Simulator but will not work on iPhone.

You need to have an object of MPMoviePlayerController and the rest of the code is like this:

-(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];
}



回答2:


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.). 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.




回答3:


Heres a reference to a doc that talks about live streaming, might be of help to you http://developer.apple.com/iphone/library/documentation/NetworkingInternet/Conceptual/StreamingMediaGuide/Introduction/Introduction.html



来源:https://stackoverflow.com/questions/1491641/live-video-stream-iphone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!