firefox插件SDK-如何检索"currentTime"来自youtube.com上的youtube播放器? [英] firefox addon sdk - how to retrieve "currentTime" from youtube player on youtube.com?
问题描述
我正在使用SDK开发firefox插件.我想做什么:
I am developing a firefox addon with SDK. What I want to do:
- 如果用户使用的是youtube视频,则firefox插件会知道youtube播放器的当前位置(getCurrentTime())
我用标签页开发了它
var tabs = require("sdk/tabs");
和当标签是准备好了,我添加contentscripfiles将其与:
and when tab is ready, I added contentscripfiles to it with:
tabs.activeTab.attach({
contentScriptFile: [data.url("jquery-1.11.1.min.js"), data.url("myscript.js")]
});
在脚本"myscript.js"中,我想访问youtube网站上的youtube播放器. 我试过了:
In the script "myscript.js" I want to access to the youtube player on the youtube site. I tried this:
var playerelement=document.getElementById("movie_player");
我得到了< embed>"来自它的DOM元素(ID为"movie_player").但是,当我想使用方法"getCurrentTime()"访问它时,会出现以下错误:
I got the "<embed>" DOM Element from it (with ID "movie_player"). But when I want to access to it with method "getCurrentTime()" there appears the following error:
Message: TypeError: document.getElementById(...).getCurrentTime is not a function
如何正确访问youtube播放器以完成此操作?
How can I access to the youtube player properly to get this stuff done?
谢谢!
推荐答案
更改
var playerelement=document.getElementById("movie_player");
到
var playerelement=document.getElementById('movie_player').wrappedJSObject;
现在可以访问getCurrentTime
.
这篇关于firefox插件SDK-如何检索"currentTime"来自youtube.com上的youtube播放器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!