JSAPI Boxee

From DevWiki

Jump to: navigation, search

< JavaScript API

Contents


Boxee Object

The boxee object allows you to communicate and send video/control information to the Boxee player. It also allows you to specify basic properties and call functions to assist in locating/searching for widgets on the active page.


Variables

autoChoosePlayer
Boolean [default true]
Tells boxee to automatically locate the appropriate widget (flash object) or not.
boxee.autoChoosePlayer = false;


renderBrowser
Boolean [default true]
Determines if Boxee will render the entire page, making it visible to the user, until a specific widget is active.
boxee.renderBrowser = false;


Methods

getVersion
getVersion() -> Number
Returns boxee-js version. (Different from Boxee client version)
if (boxee.getVersion() > 3.1) {
   boxee.log('version > 3.1');
}


enableLog
enableLog(Boolean)
Enable/disable printing to terminal, defaults to false.
boxee.enableLog(true);


log
log(String)
Send output to the terminal. Requires enabelLog(true)
boxee.log("testing 1 2 3");


getWidgets
getWidgets() -> Array -> Widget
Returns an array of each widget/object found on the active page.
boxee.getWidgets().forEach(function(widget) { ... });


getActiveWidget
getActiveWidget() -> Widget
Returns the currently active widget, whether made active manually or automatically. Not dependent on autoChoosePlayer property.
if (boxee.getActiveWidget().height == 450) { </span>. }


runInBrowser
runInBrowser(String) [depreciated]
Please use browser.execute() instead.
Executes JavaScript code on the active page.
boxee.runInBrowser( "if (document.getElementsByName('plugin').length > 1) { ... }" );


getParam
getParam(String)
returns parameter values of the flash:// url if exists.
boxee.getParam("src");


rewriteSrc
rewriteSrc
Allows rewriting of the src parameter for the active widget. Fires onload.
boxee.rewriteSrc = function(src) { return src +'&autoplay=1'; }


setCanPause
setCanPause(Boolean) [default false]
Enables pause control in the OSD
boxee.setCanPause(true);


setCanSkip
setCanSkip(Boolean) [default false]
Enables seeking controls in the OSD
boxee.setCanSkip(true);


setCanSetVolume
setCanSetVolume(Boolean) [default false]
Enables volume control in the OSD
boxee.setCanSetVolume(true);


setDefaultCrop.
setDefaultCrop(Integer left, Integer top, Integer right, Integer left)
Set the default crop for the active Widget.
boxee.setDefaultCrop(10,40,10,40);


setDuration
setDuration(Float)
Sets the length in seconds of the currently playing video
var dur = '675.4856'
boxee.setDuration( parseFloat(dur) );


notifyConfigChange
notifyConfigChange(Integer width, Integer height)
Notify boxee of height and width of flash player
boxee.notifyConfigChange(658,400)


notifyCurrentTime
notifyCurrentTime(Float)
Sets the current playhead time in the boxee osd.
var time = '675.4856'
boxee.notifyCurrentTime( parseFloat(time) );


notifyCurrentProgress
notifyCurrentProgress(Number)
Sets the position of the player's progress bar. (percentage)
progress = Math.round((currentTime/duration)*100);
boxee.notifyCurrentProgress(progress);


notifyPlaybackPaused
notifyPlaybackPaused()
Notify player that playback has been pause
Note that this is not needed if users paused video themselves.
boxee.notifyPlaybackPaused()


notifyPlaybackResumed
notifyPlaybackResumed()
Notify player that playback has been resumed
Note that this is not needed if users unpaused video themselves.
boxee.notifyPlaybackResumed()


notifyPlaybackEnded
notifyPlaybackEnded()
Tells the player that video playback has ended. if there are no more items in the playlist, player will exit and return to the last active window.
boxee.notifyPlaybackEnded();


Events

onPlay
fires when user presses play with remote or keyboard
boxee.onPlay = function() {
   boxee.log('user pressed play');
}


onPause
fires when user presses pause with remote or keyboard
boxee.onPause = function() {
   boxee.log('user pressed pause');
}


onBack
fires when user presses back with remote or keyboard
boxee.onBack = function() {
   boxee.log('user pressed back');
}


onSkip
fires when user presses skip with remote or keyboard
boxee.onSkip = function() {
   boxee.log('user pressed skip');
}


onBigBack
fires when user presses bigback with remote or keyboard
boxee.onBigBack = function() {
   boxee.log('user pressed big back');
}


onBigSkip
fires when user presses bigskip with remote or keyboard
boxee.onBigSkip = function() {
   boxee.log('user pressed big skip');
}


onSetVolume
fires when user presses volume up/down with remote or keyboard
boxee.onSetVolume = function(vol) {
   boxee.log('user set volume to: '+vol);
}


onNotifyUrl
fires whenever a url is requested from the active page.
boxee.onNotifyUrl = function(url) {
    if (url == 'http://ad.adnetworks.com/?endvideo_adds=true') {
       boxee.notifyPlaybackEnded();
    }
 }


onInit
Fires when immediately when the control script has been loaded.
Note that this is before the requested url is loaded.
boxee.onInit = function() {
   boxee.log("boxee js engine initialized");
}


onDocumentLoading
Fires when the requested page starts loading.
boxee.onDocumentLoading = function() {
   boxee.log("page is loading");
}


onDocumentLoaded
Fires when the the requested page has finished loading.
boxee.onDocumentLoaded = function() {
   boxee.log("boxee js engine initialized");
}


onNewWindow
Fires when a new window is created.
boxee.onNewWindow = function() {
   boxee.log("new window was created");
}


onPreCreateWindow
Fires when a new window is about to be created.
boxee.onPreCreateWindow = function() {
   boxee.log("new window is about to be created");
}


onSetFullScreen
Fires when the browser is requested to launch fullscreen.
boxee.onSetFullScreen = function() {
   boxee.log("browser in full screen");
}
Personal tools