I want to be able to pause and play the videos from inside the JavaScript console in Chrome DevTools. Is that possible?
If you are using HTML5-based player, you can interact with the <video>
element directly using its DOM API, as you've been told in Toni's answer.
If you are using Flash-based player, you can interact with it using YouTube JavaScript Player API. The player element seems to have id movie_player
, and I don't have any problems using API methods right on YouTube.com:
$('#movie_player').playVideo();
$('#movie_player').seekTo(60);
$('#movie_player').pauseVideo();
Also, don't get confused by $
, there's no jQuery.
If viewing using the HTML5-based player, then
$('.video-stream').play()
$('.video-stream').pause()
OR
$('video').play()
$('video').pause()
Refer here.
If viewing using the Flash-based player, then
player.playVideo()
player.pauseVideo()
Refer here.
That would depend on if you are using html5 or the flash player.
I don't think you can talk with the flash player, but html5 is possible.
You can either send a click-event to the html5-client's buttons or use the video-element's play() and pause() methods directly.
http://www.w3schools.com/tags/ref_av_dom.asp
$("video").play();
$("video").pause();
//seems like jquery has some support of its own for these basic functions too
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With