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.
Asked
Active
Viewed 2,579 times
2

Justin Michael
- 5,634
- 1
- 29
- 32
3 Answers
4
I added this to the App Transport Security Settings plist and it solved the problem for me:
<key>NSAllowsArbitraryLoadsForMedia</key>
<true/>

JShel
- 41
- 2
3
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>

Justin Michael
- 5,634
- 1
- 29
- 32
-
1As an aside, whitelists can be created: https://developer.apple.com/library/prerelease/ios/technotes/App-Transport-Security-Technote/ – Mike D Sep 21 '15 at 19:17
0
If problem persist for some <audio>
, replace "touchstart click" event by "touchend click" in js
Check this link for more details

Guillaume Taupin
- 1
- 1