Search code examples
iosios9wkwebview

Why is my audio stream in WKWebView on iOS 9 not playing?


I have a WKWebView with content that has an <audio> element pointing to a standard audio stream running on a Shoutcast server that will not play. There are no errors or information in the JavaScript console and no errors in the debugger in Xcode.


Solution

  • The problem turned out to be App Transport Security. This new security feature in iOS 9 was silently preventing the <audio> element from connecting to the insecure audio stream. Allowing arbitrary loads by adding this to my info.plist solved the problem:

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