Wkwebview required UserActionForMediaPlayback not working

I have wkwebviewone that goes into youtube, and I would like to click on the video without launching it automatically in the player.

I tried to stop this in three different ways.

  • via config.requiresUserActionForMediaPlayback = true
  • in the delegate function, decidePolicyForNavigationActionI check for the presence of YouTube videos and setdecisionHandler(WKNavigationActionPolicy.Cancel)
  • I also added webView.stopLoading()to what I did in # 2

despite this, clicking on the link still causes the video to start automatically.

I have no ideas; any thoughts?

I know, I could try to introduce some javascript, but this seems to me last.

+4
source share

Source: https://habr.com/ru/post/1648687/


All Articles