我是iphone和Objective-c的新手。我想向使用我的应用程序的用户展示一场实况转播比赛,假设是足球比赛。iphone应用程序中的直播视频流需要什么?
任何关于这方面的信息都将不胜感激!
谢谢
伙计们,请帮帮我,有没有人以前做过这个?
发布于 2009-09-29 14:07:31
您只需提供电影文件的URL,流将根据您的连接速度自动设置。
请注意,只有分辨率在iPhone限制范围内的视频才会被播放。较高分辨率的影片将在模拟器上播放,但不能在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];
}发布于 2009-09-29 13:30:09
这里有一个关于直播的参考文档,可能会对你有所帮助,http://developer.apple.com/iphone/library/documentation/NetworkingInternet/Conceptual/StreamingMediaGuide/Introduction/Introduction.html
发布于 2009-09-29 18:24:30
假设你有视频权利的足球比赛,你需要一个编码器,将现场视频编码,在飞行到正确的格式(mp4,h263等)。播放这些视频的iPhone方法是有一个动态播放列表,它将通过实时视频的块来播放它。
https://stackoverflow.com/questions/1491641
复制相似问题