Justin Michael
Justin Michael

Reputation: 6475

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.

Upvotes: 2

Views: 2609

Answers (3)

JShel
JShel

Reputation: 41

I added this to the App Transport Security Settings plist and it solved the problem for me:

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

Upvotes: 4

Guillaume Taupin
Guillaume Taupin

Reputation: 1

If problem persist for some <audio>, replace "touchstart click" event by "touchend click" in js

Check this link for more details

Upvotes: 0

Justin Michael
Justin Michael

Reputation: 6475

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>

Upvotes: 3

Related Questions