获取youtube视频的当前播放时间 [英] Getting the current time of the youtube video playing

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

问题描述

因此,我正在开发chrome扩展程序.我正在尝试获取Youtube视频的当前播放时间

So I am developing a chrome extension. I am trying to get the Youtube video current playing time

我知道在其他帖子中也有很多类似的问题,但是它们的代码都不适合我

I am aware that there are many similar questions asked in other posts, but none of their code works for me

我的代码是这样的,我必须先将我的代码注入到内容脚本中

My code is like this, I have to inject my code to the content script first

chrome.tab.query({highlighted: true}, tabs => {
   tab = tabs[0]
   chrome.tabs.executeScript(tab.id, {code: "temp = 
                             document.getElementById('movie_player'); 
alert(temp); alert(temp.getCurrentTime());"}, respond => {});
}

因此,当我运行此命令时,我会收到一条警告,提示[object HTMLDivElement].但不会从temp.getCurrentTime()中得到任何信息.

So when I run this, I will get an alert saying [object HTMLDivElement]. but won't get anything from temp.getCurrentTime().

推荐答案

问题:

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