Boxee :: Wiki :: JavaScript API

From Boxee
Jump to: navigation, search

Contents

JavaScript API

The Boxee JavaScript API is designed to facilitate interaction with media in the Boxee browser. Each time media is loaded, a set of JS control files that are stored on Boxee's remote server, are referenced. Each file represents an associated domain and specific to the player utilized on that domain. A list of known JS control files can be found below as examples of proper API usage:

Anyone can write their own custom control files for an application. You can test your modifications by saving your domain.js file to the installed /boxee/system/players/flashplayer directory. This is not the boxee directory where your local profile data, log, and apps are stored. When you are sufficiently happy with the results, submit the controller to app-submit@boxee.tv where it will be reviewed and made available to every user in the Boxee community.



Class: boxee

Functions

void enableLog(bool enable)
Enable error/message logging.
Widget getActiveWidget()
Returns the current active widget.
string getParam(string param)
Returns any specific parameter for the widget.
float getVersion()
Returns the current boxee browser version.
Widget getWidgets()
Returns a list of widgets (possible playable media) on the target webpage.
void log(string msg)
Append a message to the boxee log.
void notifyCurrentTime(int time)
Tell boxee the current time position in the media duration.
void notifyCurrentProgress(int percent)
Tell boxee what position the media is currently playing at.
void notifyPlaybackEnded()
Tell boxee that the media has finished playing.
void runInBrowser(string javascript)
Pushes javascript code that can run in the browser. Useful for sending player commands.
void setCanPause(bool can)
Enable user play/pause in the player window.
void setCanSetVolume(bool can)
Enable user volume control in the player window.
void setCanSkip(bool can)
Enable user skip next/prev in the player window.
void setDefaultCrop(int left?, int right?, int top?, int bottom?)
Sets the cropping for the media in the player window.
void setDuration(float dur)
Tell boxee how long the media is.

Functions (User Definable)

Browser
void onDocumentLoaded = function()
As of Boxee 0.9.20 this method/callback seems to belong to the "boxee" class rather than "browser".
void onInit = function()
void onNewWindow = function()
string rewriteSrc = function(string source)
Player
void onBack = function()
void onBigBack = function()
void onBigSkip = function()
void onPause = function()
void onPlay = function()
void onSetVolume = function(int volume)
void onSkip = function()


Variables

bool autoChoosePlayer
Allow boxee to determine what media player to use when loading.
int browserHeight
Force height of the boxee browser.
int browserWidth
Force width of the boxee browser.
bool renderBrowser
Utilize the boxee browser to load the corresponding media.



Class: Widget

Functions

void click(int x, int y)
Move the user's mouse to a pixel position and "clicks".
string getAttribute(string attribute)
Returns any specific attributes for the widget.
int getPixel(int x, int y)
Returns pixel color information.
void mouseMove(int x, int y)
Move the user's mouse to a pixel position.
void setActive(bool active)
Enable the media widget.

Variables

int height
Media widget height.
int width
Media widget width.
Personal tools