2

我是 iphone 和 Objective-c 的新手。我想向使用我的应用程序的用户展示一场现场比赛,假设足球比赛。在 iphone 应用程序中进行实时视频流传输需要什么?

对此的任何信息表示赞赏!

谢谢

伙计们请帮助任何人以前必须这样做过吗?

4

3 回答 3

3

您只需要提供电影文件的 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-29T14:07:31.387 回答
1

下面是一个关于直播的文档的参考,可能对你有帮助http://developer.apple.com/iphone/library/documentation/NetworkingInternet/Conceptual/StreamingMediaGuide/Introduction/Introduction.html

于 2009-09-29T13:30:08.950 回答
1

假设您拥有相关足球比赛的视频版权,您需要一个编码器,它将实时视频编码为正确的格式(mp4、h263 等)。iPhone 播放这些内容的方法是拥有一个动态播放列表,该列表将通过实时视频的块来播放。

于 2009-09-29T10:24:30.260 回答