如何在控制台中播放和暂停Youtube视频? [英] How to play and pause a Youtube video in the console?

查看:309
本文介绍了如何在控制台中播放和暂停Youtube视频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

转到以下网址:

https://www.youtube.com/embed/zvCBSSwgtg4

并打开Chrome控制台。我想知道javascript命令将播放youtube视频以及javascript命令将暂停youtube视频。

and open the chrome console. I want to know what javascript command will play the youtube video and what javascript command will pause the youtube video.

我尝试使用探查器和检查器查找这些命令但他们太隐蔽了。如果有人真的擅长javascript调试,这将是一个很大的帮助。谢谢!

I've tried using the profiler and inspector to find these commands but they are too well hidden. If someone is really good at javascript debugging, this would be a big help. Thanks!

是的,我知道youtube有iframe的API,但我的用例不同。

Yes, I know youtube has API for iframes, but my use case is different.

推荐答案

您是否尝试触发实际播放/暂停按钮的单击?

Have you tried triggering a click on the actual play/pause button?

document.getElementsByClassName('ytp-play-button')[0].click();

这篇关于如何在控制台中播放和暂停Youtube视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆