问题描述
我对创建一个iPhone应用程序感兴趣,该应用程序可以从YouTube风格的中央服务器流式传输视频.我想知道以前是否有人尝试过这样做,那么抵抗力最低,现有的API等的路径是什么?我真的不知道这通常是如何完成的.我会使用插座吗?只是在这里寻找方向.谢谢!
I'm interested in creating an iPhone app that can stream video from a central server, YouTube style. I was wondering if anyone has ever tried to do this before, what is the path of least resistant, existing APIs, etc? I really know nothing about how this is generally done. Would I be working with sockets? Just looking for some direction here. Thanks!
推荐答案
如果您已经准备好了流服务器,则可以轻松实现弹出YouTube风格的视频控制器.
If you have the streaming server up and ready, it is quite easy to implement a video controller that pops up youtube-style.
NSString *videoURLString = @"http://path-to-iphone-compliant-video-stream";
NSURL *videoURL = [NSURL URLWithString:videoURLString];
MPMoviePlayerController moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];
[moviePlayer prepareToPlay];
[moviePlayer play];
[self.view addSubview:moviePlayer.view];
您需要处理显示视频播放器视图的控制器(在本例中为self
).
You need to handle the controller that display the video player's view (which is self
in this case).
在iOS 3.2及更高版本中,MPMoviePlayerViewController使其变得更加轻松:
In iOS 3.2+ MPMoviePlayerViewController make it even easier:
NSString *videoURLString = @"http://path-to-iphone-compliant-video-stream";
NSURL *videoURL = [NSURL URLWithString:videoURLString];
MPMoviePlayerViewController *moviePlayerView = [[[MPMoviePlayerViewController alloc] initWithContentURL:videoURL] autorelease];
[self presentMoviePlayerViewControllerAnimated:moviePlayerView];
presentMoviePlayerViewControllerAnimated
是MediaPlayer对FWViewController
的附加方法,您可以在iOS 3.2+中找到它,该方法负责创建视图控制器并将其推入堆栈,并使用从底部滑动的动画对其进行动画处理,就像在youtube.app中一样.
presentMoviePlayerViewControllerAnimated
is a MediaPlayer's additional method to FWViewController
that you will find in iOS 3.2+ and it takes care of creating a view controller and pushing it on the stack, animating it with a slide-from-bottom animation, as in youtube.app.
这篇关于编写应用以将视频流式传输到iPhone的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!