编写应用程序以将视频流式传输到iPhone

Jam*_*son 23 iphone video objective-c video-streaming

我有兴趣创建一个可以从YouTube中央服务器流式传输视频的iPhone应用程序.我想知道是否有人曾尝试过这样做,最不具有抵抗力的现有API的路径是什么?我真的一无所知.我会使用套接字吗?只是在这里寻找一些方向.谢谢!

duh*_*bel 19

如果你已准备好流媒体服务器,那么实现一个弹出youtube风格的视频控制器非常容易.

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];
Run Code Online (Sandbox Code Playgroud)

您需要处理显示视频播放器视图的控制器(self在这种情况下).

在iOS 3.2+中,MPMoviePlayerViewController使它更容易:

NSString *videoURLString = @"http://path-to-iphone-compliant-video-stream";
NSURL *videoURL = [NSURL URLWithString:videoURLString];
MPMoviePlayerViewController *moviePlayerView = [[[MPMoviePlayerViewController alloc] initWithContentURL:videoURL] autorelease];
[self presentMoviePlayerViewControllerAnimated:moviePlayerView];
Run Code Online (Sandbox Code Playgroud)

presentMoviePlayerViewControllerAnimated是一个MediaPlayer的附加方法FWViewController,你可以在iOS 3.2+中找到它,它负责创建一个视图控制器并将其推入堆栈,使用从下滑动的动画制作动画,如在youtube.app中.


Ant*_*ton 7

Apple有一篇关于为媒体流设置服务器端的详细文章:

https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/StreamingMediaGuide/Introduction/Introduction.html

和最佳实践注意:

https://developer.apple.com/library/content/technotes/tn2224/_index.html

它不仅包含有关流服务架构和用于构建它的工具的信息,而且还对必须满足的此类服务和对实时测试流的引用有一些要求.