In my Firefox addon, I have a custom button on nav toolbar. In my *.xul file, I have the following:
<toolbarpalette id="BrowserToolbarPalette">
<toolbarbutton id="myaddon-button-1"/>
</toolbarpalette>
<!-- button details -->
<toolbarbutton id="myaddon-button-1"
label="MyAddon"
tooltiptext="My Addon Desc"
oncommand="myaddon[1]()"
class="toolbarbutton-1 chromeclass-toolbar-additional myaddon"
/>
In my *.js script, I have the following:
myaddon = {
1: function () {
ytplayer = gBrowser.contentDocument.getElementById("movie_player");
alert ("before");
alert (ytplayer.getCurrentTime());
alert ("after");
},
After clicking on a custom toolbar button, I get alert "before" and don't get alert "after". In Error Console, I have
Error: ytplayer.getCurrentTime is not a function
In the similar question related to GreaseMonkey, I have read about embedding a piece of html and calling YouTube API inside. And it works, I tested it in Firefox. But I don't want to inject any html elements and click on them. Could you please give me any clue on how to call YouTube API functions like getCurrentTime in toolbar button handler?
Thanks, Racoon