I am developing a firefox addon with SDK. What I want to do:
- If user is on a video of youtube the firefox addon knows the current position of youtube player (getCurrentTime())
I developed it with tabs
var tabs = require("sdk/tabs");
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")]
});
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");
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
How can I access to the youtube player properly to get this stuff done?
Thx!
Change
var playerelement=document.getElementById("movie_player");
to
var playerelement=document.getElementById('movie_player').wrappedJSObject;
Now getCurrentTime
will be accessible.
来源:https://stackoverflow.com/questions/26616771/firefox-addon-sdk-how-to-retrieve-currenttime-from-youtube-player-on-youtube