JavaScript API: Widget Class

From DevWiki

Jump to: navigation, search

Back to API Reference


Contents


widget object

The widget object allows you to specify which object on a given url should be used for playback. You can also used this object to do specific actions to the widget itself, such as simulate clicks on the player. To return a valid widget object, use boxee.getActiveWidget() or boxee.getWidgets()


getZIndex

number getZIndex(void)
Returns the current Z-Index for the given widget
zindex = widget.GetZIndex();


isVisible

bool isVisible(void)
Returns 'true' if the given widget is visible on the page.
This is an internal method from Mozilla and not very reliable.
if ( widget.isVisible() ) { ... }


isActive

bool isActive(void)
Return 'true' if the given widget is the active widget.
if ( widget.isVisible() ) { ... }


isFullScreen

bool isFullScreen(void)
Return 'true' if the given widget is fullscreen.
if ( widget.fullscreen() ) { ... }


setActive

void setActive(void)
Sets the given widget to the active widget to be used for playback
widget.SetActive();


setCrop

void setCrop(int left, int top, int right, int bottom)
Defines the crop used on the activeWidget. Use left, top, right, bottom
widget.setCrop(10, 40, 10, 40)


mouseDown

void mouseDown(void)
Simulates the mouse wheel being scrolled down one notch on the active widget.
widget.mouseDown();


mouseUp

void mouseUp(void)
Simulates the mouse wheel being scrolled up one notch on the active widget.
widget.mouseUp();


click

void click(int x, int y)
Clicks at (x,y) on the activeWidget.
Dimensions for X/Y are based on the size of the widget, not the browser page.
widget.click(40, 200);


resize

void resize(int width, int height)
Sets new width and height for the active widget
widget.resize(854, 480);


mouseMove

void mouseMove(int x, int y)
Move the mouse to the specified (x,y) coordinates.
Dimensions for X/Y are based on the size of the widget, not the browser page.
widget.mouseMove(40, 200);


hasAttribute

bool hasAttribute(string)
Return 'true' if the activeWidget (object) contains the specified attribute tag.
if ( widget.hasAttribute('flashvars') ) { ... }


getAttribute

void getAttribute(string attr)
Returns the specified attribute tag for a given widget object
fvars = widget.getAttribute('flashvars');


getTagName

string getTagName(void)
Only available after the widget is created, returns the tag name used (either "embed" or "object") - this value can not be accessed from getAttribute.
if (widget.getTagName() == 'embed') {
   boxee.log('type: embed');
}


getPixelData

object getPixelData(int xcord, int ycord)
Used to identify an RGB color code from the specified (x,y) coordinates for a given widget object
color = widget.getPixelData(133,344)
if ( color.r == 225 && color.g == 225 && color.b == 225 )
   isPaused = true;
Personal tools