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 a
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];
}
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.
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