<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - WKWebView set mediaPlaybackRequiresUserAction = false not working to auto play a video"
   href="https://bugs.webkit.org/show_bug.cgi?id=162329">162329</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>WKWebView set mediaPlaybackRequiresUserAction = false not working to auto play a video
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>WebKit
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>Other
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>iPhone / iPad
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>iOS 10
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>Blocker
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P2
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>WebKit API
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>webkit-unassigned&#64;lists.webkit.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>rainer&#64;126.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Hi I am working on iOS 10 with Swift3 right now.

My scenario is to autoplay a youtube video inline using WKWebView. I set the config's mediaPlaybackRequiresUserAction to false in order to enable the video autoplay, as suggested by Apple Dev Docs.

However this config does not seem to work, the video loaded correctly, but you have to press the play button to make it actually play.

Code below:

let config = WKWebViewConfiguration()
            config.requiresUserActionForMediaPlayback = false
            config.allowsInlineMediaPlayback = true
            config.mediaPlaybackRequiresUserAction = false
            config.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone
            let webView = WKWebView(frame: self.topView.bounds, configuration: config)
            webView.addObserver(self, forKeyPath: self.webViewLoadingKey, options: .new, context: nil)</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>