Audio not playing in scenes

Here you are friend...

import UIKit
import WebKit
class ViewController: UIViewController, WKUIDelegate {

var webView: WKWebView!

override func loadView() {
    let webConfiguration = WKWebViewConfiguration()

That's the start of apple's code. The trick is to add this...

But how do you do that? :thinking:

It's attached to "webConfiguration"... which appears to be variable, where you can give it a different name. But if you keep the same name, the following code should fix the sound problem...

webConfiguration.mediaTypesRequiringUserActionForPlayback = []

So basically, it's saying no media types require user action to play. After many hours of fighting with Xcode, on this issue and Mac app issues, I thought it didn't work. Heh, but then I heard the music playing.

2 Likes