firefox addon sdk - how to retrieve “currentTime” from youtube player on youtube.com?

試著忘記壹切 提交于 2019-12-06 13:29:46

问题


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!


回答1:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!