获取当前的YouTube视频时间 [英] Getting Current YouTube Video Time

查看:444
本文介绍了获取当前的YouTube视频时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个浏览器插件,需要找到一种方法来获取使用JavaScript在YouTube上播放YouTube视频的当前时间。我一直在玩Chrome JavaScript控制台,但没有运气。

I am writing a Browser Plugin and need to find a way to get the current time a YouTube Video playing on YouTube using JavaScript. I have been playing around in the Chrome JavaScript Console and haven't had any luck.

看来chrome API仅适用于嵌入式视频播放器,而不适用于youtube.com上正在播放的视频。我查看的一个选项是在视频的共享部分,它们是start at:时间的输入框,其中包含视频的当前时间。我试过在这个输入框上使用.value和.text,它们都返回undefined?有没有人有任何想法?

It appears that the chrome API only works with embedded video players not a video that is playing on on youtube.com. One option I looked into is in the share section of a video their is an input box for the "start at:" time that contains the current time of the video. I have tried using .value and .text on this input box and they both return undefined? Does anyone have any ideas?

推荐答案

ytplayer = document.getElementById("movie_player");
ytplayer.getCurrentTime();

参见 api

这篇关于获取当前的YouTube视频时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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