简体   繁体   English

AVPlayer无法在iOS 9上播放

[英]AVPlayer not playing on iOS 9

I'm trying to build a audio streaming app, like a radio. 我正在尝试构建音频流应用程序,例如收音机。 This is the URL of the stream: http://radio.livesh.com.br:8068/ 这是流的URL: http://radio.livesh.com.br:8068/ : http://radio.livesh.com.br:8068/ : http://radio.livesh.com.br:8068/

This is basically how I do: 基本上,这就是我的工作方式:

player = AVPlayer()
let playerItem = AVPlayerItem( URL:NSURL(string:streamURL)! )
player = AVPlayer(playerItem:playerItem)
player.rate = 1.0;
player.play()

The player var is stored so it does keep playing and is not being deinit'ed. player var会被存储,因此它会继续播放并且不会被取消初始化。 In an iPhone 5S with iOS 8 it works and I can hear the sounds. 在装有iOS 8的iPhone 5S中,它可以正常工作,而且我可以听到声音。 In an iPhone 6 with iOS 9 it doesn't. 在装有iOS 9的iPhone 6中则没有。

What am I doing wrong? 我究竟做错了什么?

could be the ATS (app transport security) which enforces usage of https instead of http 可能是强制使用https而非http的ATS(应用程序传输安全性)

you can either serve your content over https or create an exception on the info.plist file as such: 您可以通过https提供您的内容,也可以在info.plist文件上创建一个例外,例如:

<key>NSAppTransportSecurity</key>
<dict>
  <key>NSExceptionDomains</key>
  <dict>
    <key>radio.livesh.com.br</key>
    <dict>
      <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
      <true/>
    </dict>
  </dict>
</dict>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM