【问题标题】:Why is my audio stream in WKWebView on iOS 9 not playing?为什么我在 iOS 9 上的 WKWebView 中的音频流无法播放?
【发布时间】:2015-09-21 18:13:59
【问题描述】:

我有一个 WKWebView,其内容有一个 <audio> 元素,指向在 Shoutcast 服务器上运行的标准音频流,但不会播放。 JavaScript 控制台中没有错误或信息,Xcode 中的调试器中也没有错误。

【问题讨论】:

    标签: ios ios9 wkwebview


    【解决方案1】:

    我将此添加到应用程序传输安全设置 plist 中,它为我解决了问题:

    <key>NSAllowsArbitraryLoadsForMedia</key>
        <true/>
    

    【讨论】:

      【解决方案2】:

      问题原来是App Transport Security。 iOS 9 中的这项新安全功能可以静默阻止&lt;audio&gt; 元素连接到不安全的音频流。通过将其添加到我的info.plist 来允许任意加载解决了这个问题:

      <key>NSAppTransportSecurity</key>
      <dict>
          <key>NSAllowsArbitraryLoads</key>
          <true/>
      </dict>
      

      【讨论】:

      【解决方案3】:

      如果某些&lt;audio&gt;的问题仍然存在,请将js中的“touchstart click”事件替换为“touchend click

      查看link了解更多详情

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-12-27
        • 2015-12-23
        • 1970-01-01
        • 1970-01-01
        • 2021-11-11
        • 1970-01-01
        • 2018-03-12
        • 2012-03-22
        相关资源
        最近更新 更多