1

I would like to control the playback of a YouTube video with JavaScript (jquery).

I tried various things but they all refer to embedded youtube video, is it possible to do it with videos on the official YouTube website? The YouTube webpage is shown in an embedded QWebPage (Qt)

Here is my use case : picture

What I tried so far (not successful), :

QString jsValue =  "$('#movie_player').get(0).pauseVideo();";
ui->webView->page()->mainFrame()->evaluateJavaScript(jsValue);
Ross
  • 1,313
  • 4
  • 16
  • 24
Astro
  • 123
  • 2
  • 13
  • Have you tried this http://stackoverflow.com/questions/15164942/stop-embedded-youtube-iframe – Kevin Lynch Jan 20 '15 at 17:48
  • this is for embedded video, I can't add "&enablejsapi=1" to the URL, i'm using youtube website directly.. – Astro Jan 20 '15 at 18:02
  • 1
    Did you embed jQuery in the page? Try `document.getElementById('movie_player').pauseVideo()`. – Pavel Strakhov Jan 20 '15 at 23:44
  • This is working! I just figured Youtube page doesn't use Jquery so normal Javascript did the trick. Perfect, now only if the movie could take the full browser, remove the top annoying bar and be responsive.. to be continued... :) – Astro Jan 21 '15 at 14:38

0 Answers0