Swift (latest) UIwebView no sound ?

When i load a local site in my webView, no sound is played


I use this code to play the sound in the index.html :

var audio = new Audio('AUDIO PATH');
audio.play();


And this code in the ViewController.swift to load HTML :

let localfilePath = Bundle.main.url(forResource: "www/index", withExtension: "html")
let myRequest = NSURLRequest(url: localfilePath!);
webView.loadRequest(myRequest as URLRequest);


Maybe i forgot to check a option to enable sound in the Main.storyboard or there is a secret line i dont know about.


Thanks for the help !

Answered by KMT in 226575022

In that case, you may be using outdated code/tutorials.


Webview was deprecated w/iOS 8. You should now be using WKWebView.


Also note:

- Xcode v8.2.1 includes Swift 3.0.2 (not latest)

- Latest Xcode is v8.3.2 / Swift 3.1

macOS, iOS...?


Which version(s) of which OS does that app support?

Swift (latest) UIwebView no sound ?
 
 
Q