[英]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.