您可以使用 HLS 从 HTTPS 服务器流式传输吗?

Can you stream from a HTTPS server using HLS?

我想知道是否可以使用 HLS 从 HTTPS 服务器进行流式传输,使用以下代码 -

let url = NSURL(string:"http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8")
        let player = AVPlayer(URL: url!)
        let playerController = AVPlayerViewController()

        playerController.player = player
        self.addChildViewController(playerController)
        self.view.addSubview(playerController.view)
        playerController.view.frame = self.view.frame

        player.play()

我可以从 HTTP 服务器流式传输,但是当我将 URL 更改为我公司服务器的 URL 时它不起作用,唯一的区别是我公司的视频URL 中有 HTTPS 而苹果的示例视频没有,我正在 XCode

中的模拟器上进行测试

是的,您可以从 HTTPS 服务器流式传输 HLS。 HLS 流通过 HTTP 传输,而 HTTPS 只是通过 TLS 的 HTTP,并且大多数时候它对客户端是透明的。您唯一需要的是所有主要播放器都已经具备的 HTTPS 支持。

https://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8 无效,因为 devimages.apple.com 证书无效。只需使用浏览器浏览 url。它会警告您并为您提供有关具体问题的更多信息。

我猜你公司服务器的问题是一样的 - 错误或自签名证书。

验证 https 服务器的另一种快速方法是用户 curl。例如:

curl "https://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8"

抱怨:

curl: (51) SSL: no alternative certificate subject name matches target host name 'devimages.apple.com'