[英]Live Video Stream iphone
我是iphone和Objective-c的新手。 我想向使用我的应用程序的用户展示一场实时比赛,假设足球比赛。 我需要在iPhone应用程序中进行实时视频流传输吗?
任何信息对此表示赞赏!
谢谢
伙计们,请帮助任何必须在此之前完成的人?
您只需要提供电影文件的URL,就会根据您的连接速度自动设置流。
请注意,只有分辨率在iPhone限制范围内的视频才能播放。 较高分辨率的电影将在Simulator上播放,但不能在iPhone上播放。
您需要有一个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];
}
假设您拥有所讨论足球比赛的视频权利,则需要一个编码器,该编码器将实时编码实时视频到正确的格式(mp4,h263等)。 iPhone播放这些文件的方法是拥有一个动态播放列表,该播放列表将查看实时视频的一部分以进行播放。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.