1

How to detect action of Play button clicked in youtube in wkwebview, I have gone through this question, it is some how similar to my question but not duplicate and unanswered.

Any help will be appreciated.

Thanks.

Abhishek Mitra
  • 3,335
  • 4
  • 25
  • 46

1 Answers1

0

If you need only one callback when play button is clicked the very first time (doesn't notify about pause/play).

Use this code and replace http://apple.com with some youtube url.

Set a breakpoint in

func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage)

Run in simulator and tap on youtube play button. You will get a callback in

func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage)

method.

Renatus
  • 1,123
  • 13
  • 20
  • Hi, @Renatus, It is not working, have you checked it and is it working with in your end? let me know. particularly I'm using this url and want to get the action of play button `https://www.youtube.com/embed/owiwCIhc0I0` Thanks for your time though. – Abhishek Mitra May 22 '18 at 06:26