在 3 分钟后从 chrome 控制台暂停 YouTube 视频
Pause a youtube video from the chrome console after it reaches 3 minutes
我可以暂停视频
globalThis.ytPlayerUtilsVideoTagPoolInstance.l[0].pause()
我可以通过globalThis.ytPlayerUtilsVideoTagPoolInstance.l[0].currentTime
获取视频的当前时间
如何在视频到达 currentTime > 180
时自动触发暂停?
一个简单的方法是轮询。
const player = globalThis.ytPlayerUtilsVideoTagPoolInstance.l[0]
setTimeout(function polling() {
if (player.currentTime < 180)
setTimeout(polling, 1000)
else
player.pause()
}, 1000)
另一种方法:
const player = globalThis.ytPlayerUtilsVideoTagPoolInstance.l[0]
const timer = setInterval(() => { // no need of named function as no 'async recursion' is needed
if (player.currentTime >= 180) {
player.pause()
clearInterval(timer)
}
}, 1000)
我可以暂停视频
globalThis.ytPlayerUtilsVideoTagPoolInstance.l[0].pause()
我可以通过globalThis.ytPlayerUtilsVideoTagPoolInstance.l[0].currentTime
如何在视频到达 currentTime > 180
时自动触发暂停?
一个简单的方法是轮询。
const player = globalThis.ytPlayerUtilsVideoTagPoolInstance.l[0]
setTimeout(function polling() {
if (player.currentTime < 180)
setTimeout(polling, 1000)
else
player.pause()
}, 1000)
另一种方法:
const player = globalThis.ytPlayerUtilsVideoTagPoolInstance.l[0]
const timer = setInterval(() => { // no need of named function as no 'async recursion' is needed
if (player.currentTime >= 180) {
player.pause()
clearInterval(timer)
}
}, 1000)