Lin*_*ann 53 html iphone video http-live-streaming ios
我想写一个小的iOS视频客户端,并且必须使用HTTP Live Streaming.视频来自支持HTTP直播流的Wowza媒体服务器,因此服务器端实现不是我的问题.我已经观看了WWDC视频,并阅读了有关HTTP直播的Apple文档.
但是没有人解释如何在iOS设备上播放视频.在WWDC中,有人提到有三个组织可以显示视频:
哪一个是最好的?
我如何从像这样的HTML页面中读出视频URL,这些是由服务器提供的?
<html>
<head>
<title>HTTP Live Streaming Example</title>
</head>
<body>
<video
src="http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8"
height="300" width="400"
>
</video>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
(来源:Apple HTTP直播流媒体概述)
我真的不知道从哪里开始编码......也许有人比烦人的"Stitched Stream Player"知道更好的示例代码,或者可以写一点教程......
Gna*_*Dog 55
简短的实施.包含的URL指向有效的流(截至2015年12月15日),但您可以使用自己的URL替换为.m3u8文件.
Objective-C的:
#import <MediaPlayer/MediaPlayer.h>
@interface ViewController ()
@property (strong, nonatomic) MPMoviePlayerController *streamPlayer;
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
NSURL *streamURL = [NSURL URLWithString:@"http://qthttp.apple.com.edgesuite.net/1010qwoeiuryfg/sl.m3u8"];
_streamPlayer = [[MPMoviePlayerController alloc] initWithContentURL:streamURL];
// depending on your implementation your view may not have it's bounds set here
// in that case consider calling the following 4 msgs later
[self.streamPlayer.view setFrame: self.view.bounds];
self.streamPlayer.controlStyle = MPMovieControlStyleEmbedded;
[self.view addSubview: self.streamPlayer.view];
[self.streamPlayer play];
}
- (void)dealloc
{
// if non-ARC
// [_streamPlayer release];
// [super dealloc];
}
@end
Run Code Online (Sandbox Code Playgroud)
迅速:
import UIKit
import MediaPlayer
class ViewController: UIViewController {
var streamPlayer : MPMoviePlayerController = MPMoviePlayerController(contentURL: NSURL(string:"http://qthttp.apple.com.edgesuite.net/1010qwoeiuryfg/sl.m3u8"))
//Let's play
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
streamPlayer.view.frame = self.view.bounds
self.view.addSubview(streamPlayer.view)
streamPlayer.fullscreen = true
// Play the movie!
streamPlayer.play()
}
}
Run Code Online (Sandbox Code Playgroud)
更新了这两种语言的答案.同样MPMoviePlayerController在iOS 9中已弃用,但您可以使用AVPlayerViewController.快乐的编码.!!!
| 归档时间: |
|
| 查看次数: |
46262 次 |
| 最近记录: |