Editor:
Robin Berjon (Joost™) <robin@joost.com>
Revision:
0.9, last modified: 2008-01-16T14:34:22+01:00

Abstract

This document describes the Engine API.

Any and all use of the Joost API is subject to the Joost API Terms of Use

The API may change and although we will try and keep these changes to a minimum, some API calls may be deprecated in the future.

Table of Contents

1. Overview

2. Runtime Engine Information

The Engine interface provides access to information about the current state of the Joost engine, such as what is currently playing, whether the video is running or paused, how far into a given program we are, what the volume level is, etc. It also allows one to switch channels and control various aspects of playback.

The Engine interface

interface Engine {

           attribute boolean  paused;
           attribute Number   volume;
           attribute boolean  mute;
  readonly attribute Entry    currentEntry;
  readonly attribute Number   currentChannelPosition;
  readonly attribute Channel  currentChannel;
  readonly attribute Number   currentTimeMS;
  readonly attribute Number   currentDuration;
  readonly attribute Number   numChannels;
  void               play(in String channel, in Number entry, in Number position);
  void               addListener(in EngineListener callback);
  void               removeListener(in EventListener callback);
  void               retrieveURL(in String url, in ChannelListener callback);
  void               addVideoCallback(in Number time, in Function cb, in boolean once);
  boolean            canSeek();
  Number             getMaxSeekTimeMS();
  boolean            seekToTimeMS(in Number ms, in Function cb);
  Sprite             createSprite(in String url, in Number x, in Number y, in Number h, in Number w, in Number opacity);
  Subtitle           createSubtitle();
};

Attributes

currentChannel of type Channel, readonly

The channel currently being watched.

currentChannelPosition of type Number, readonly

The position of the entry currently playing in the current channel.

currentDuration of type Number, readonly

The total length in milliseconds of the entry currently playing.

currentEntry of type Entry, readonly

The Entry that is currently playing, null when not playing an entry.

currentTimeMS of type Number, readonly

The current offset in milliseconds in the entry currently playing.

mute of type boolean

Get or set the mute status.

numChannels of type Number, readonly

The number of channels in the EPG.

paused of type boolean

Get the paused status of the current entry; set to pause or resume the video.

volume of type Number

Get or set the volume, between 0 and 1. Note that setting the volume to 0 does not cause the mute field to become true or the sound necessarily to be silent. Instead it corresponds to the lowest volume level desired by the user.

Methods

addListener

Add a callback listener for runtime information.

Parameters
callback of type EngineListener
The EngineListener object for which to receive callbacks on runtime events.
No Return Value
No Exceptions
addVideoCallback

Add a callback that will be called when the given time offset in milliseconds in the current entry is passed.

Parameters
time of type Number
The time offset in milliseconds at which the callback is to be called.
cb of type Function
The callback to call.
once of type boolean
If true, the callback will only be called the first time that the time offset is reached, and will be discarded afterwards. Otherwise, it will be called every time that the offset is passed for this entry.
No Return Value
No Exceptions
canSeek

Indicates whether the current entry is seekable or not.

No Parameters
Return Value
True or false depending on seekability.
No Exceptions
createSprite

Create a 'sprite' - a small HTML document which can be positioned on the screen by a widget. Only 6 sprites can be created in one session, but they can be reused using hide() and navigate(). All sprites are released when enable / disable is toggled, which also removes all sprites from the screen.

Parameters
url of type String
url can be a remote HTML file, a local HTML or image file bundled with the widget, or a data: URI (http://en.wikipedia.org/wiki/Data:_URI_scheme).
x of type Number
x provides the initial position of the sprite, measured in pixels on the horizontal from the top left.
y of type Number
y provides the initial position of the sprite, measured in pixels on the vertical from the top left.
h of type Number
The height in pixels of the sprite.
w of type Number
The width in pixels of the sprite.
opacity of type Number
The opacity of the sprite, a number between 0 and 1.
Return Value
A newly minted Sprite.
No Exceptions
createSubtitle

Creates a subtitle object for use. A utility method that enables you to easily create sprites with text, by default placed at the bottom centre of the screen.

No Parameters
Return Value
A newly minted empty Subtitle.
No Exceptions
getMaxSeekTimeMS

Get the maximal offset one can seek to, in milliseconds.

No Parameters
Return Value
The millisecond offset to which one can seek.
No Exceptions
play

Plays an entry in a given channel, optionally at a given position in case the entry is repeated in the channel.

Parameters
channel of type String
The ID of the channel in which to play the entry.
entry of type Number
The number of the entry to play in that channel.
position of type Number
The offset of the entry to play, or null to play the first occurrence of that entry in that channel.
No Return Value
No Exceptions
removeListener

Remove an existing EventListener.

Parameters
callback of type EventListener
The EventListener object to remove.
No Return Value
No Exceptions
retrieveURL

Retrieves a Joost Link URL, making information about the channel and the entry available. Use in conjunction with a listener to check if a Joost Links is playable, geo-restricted, or no longer available.

Parameters
url of type String
The URL of the object to retrieve
callback of type ChannelListener
The ChannelListener object that will be notified of the update.
No Return Value
No Exceptions
seekToTimeMS

Request that the engine seek to the given millisecond offset.

Parameters
ms of type Number
The millisecond offset to which to seek.
cb of type Function
An optional callback to call immediately after the seeking has taken place. The callback is passed a boolean indicating whether the seek was immediate or not.
Return Value
True if the seek was immediate, false otherwise.
No Exceptions

3. Engine Listener

The EngineListener interface is a simple interface meant to be implemented in Javascript code when one needs to be notified of events coming from the Engine, through callbacks. All methods are optional, if a method is not implemented it is simply not called. Details of the information that can be obtained by implementing this interface and passing the resulting object to the Engine's addListener are given below.

The EngineListener interface

interface EngineListener {

  void engineReady();
  void engineStop();
  void engineShutdown();
  void playFailure(in String entryID, in String channelID, in Number errCode);
  void channelChange(in String channelID, in String entryID);
  void channelsChanged(in Array channels);
  void entryChange(in String entryID);
  void entryStart(in String entryID, in Number ms);
  void entryEnd(in String entryID, in Number ms);
  void entryPaused(in Number ms);
  void entryUnpaused(in Number ms);
};

Methods

channelChange

The viewer has request to switch to a new channel.

Parameters
channelID of type String
The ID of the channel that is requested.
entryID of type String
The ID of the entry that is requested.
No Return Value
No Exceptions
channelsChanged

The channels in the EPG have been updated and changed.

Parameters
channels of type Array
An array of IDs of channels that have changed. If channels is null, all the channels in the EPG have been changed.
No Return Value
No Exceptions
engineReady

Notification that the engine is ready. No useful information can be obtained from it before this stage.

No Parameters
No Return Value
No Exceptions
engineShutdown

Notification that the engine has shut down (i.e. the application is exiting).

No Parameters
No Return Value
No Exceptions
engineStop

Notification that the engine has been stopped.

No Parameters
No Return Value
No Exceptions
entryChange

The viewer requested to view another entry.

Parameters
entryID of type String
The ID of the entry that was requested.
No Return Value
No Exceptions
entryEnd

An entry has stopped playing.

Parameters
entryID of type String
The ID of the entry that has stopped.
ms of type Number
The offset in milliseconds at which it is stopped.
No Return Value
No Exceptions
entryPaused

The current asset has been paused.

Parameters
ms of type Number
The offset in milliseconds at which it is paused.
No Return Value
No Exceptions
entryStart

An entry has started to play.

Parameters
entryID of type String
The ID of the entry that has started.
ms of type Number
The offset in milliseconds at which it is playing.
No Return Value
No Exceptions
entryUnpaused

The current asset has been restarted.

Parameters
ms of type Number
The offset in milliseconds at which it is restarted.
No Return Value
No Exceptions
playFailure

Playing has completely failed, something bad has happened.

Parameters
entryID of type String
The ID of the entry that failed.
channelID of type String
The ID of the channel that failed.
errCode of type Number
The error code.
No Return Value
No Exceptions

4. Channels

The Channel interface encapsulates information describing a channel, and allows one to listen to specific events on the channel.

The Channel interface

interface Channel {

  readonly attribute String   id;
  readonly attribute String   title;
  readonly attribute String   description;
  readonly attribute String   logo;
  readonly attribute boolean  isSmartChannel;
  readonly attribute boolean  isShownInEpg;
  readonly attribute Number   numEntries;
  Entry              getEntry(in Number lookup);
};

Attributes

description of type String, readonly

The description of the channel.

id of type String, readonly

The public identifier for the channel.

isShownInEpg of type boolean, readonly

A boolean indicating whether this channel is shown in the EPG, and that it is not empty.

isSmartChannel of type boolean, readonly

A boolean indicating whether this channel was created from a search or a hodgepodge channel.

The URL of the logo of the channel.

numEntries of type Number, readonly

The number of Entry objects in the channel.

title of type String, readonly

The title of the channel.

Methods

getEntry

Get an entry by its position in the channel in the local EPG.

Parameters
lookup of type Number
The position of the entry.
Return Value
The corresponding Entry, or null if none is found at this offset.
No Exceptions

The ChannelListener interface is implemented by objects that wish to be notified of events targeting a specific channel, or all channels.

The ChannelListener interface

interface ChannelListener {
  void updateSuccess(in Channel channel, in Entry entry);
  void updateFailure(in String code);
};

Methods

updateFailure

Updating (or adding) the channel failed.

Parameters
code of type String
The code is "load:" followed by the HTTP return code. 404 means that this is not a Joost Link, 403 means geo-restrictions are being applied.
No Return Value
No Exceptions
updateSuccess

The channel was successfully updated (or added). If the Joost Link points to a channel it returns the corresponding Channel object and the channel's first Entry object; if the Joost Link is an entry it returns the Channel object encapsulating the Joost Links virtual channel and the given Entry object.

Parameters
channel of type Channel
The Channel, see above.
entry of type Entry
The Entry, see above.
No Return Value
No Exceptions

5. Entries

The Entry interface encapsulates information describing an entry (i.e. an individual programme) in a channel.

The Entry interface

interface Entry {

  readonly attribute String   id;
  readonly attribute String   title;
  readonly attribute String   description;
  readonly attribute String   logo;
  readonly attribute Number   duration;
  readonly attribute String   thumbnail;
  readonly attribute boolean  noThumbnailProvided;
  readonly attribute String   joostLink;
};

Attributes

description of type String, readonly

The description of the entry.

duration of type Number, readonly

The duration of the entry, in milliseconds.

id of type String, readonly

The public identifier for the entry.

The Joost Link for this entry.

The URL of the logo of the entry.

noThumbnailProvided of type boolean, readonly

True if there was no thumbnail and the default one is being used.

thumbnail of type String, readonly

The URL of the thumbnail for the entry. If there is none, a default one is returned.

title of type String, readonly

The title of the entry.

6. Sprites

A sprite is a small HTML document which can be positioned on the screen by a widget. Only 6 sprites can be created in one session, but they can be reused using hide() and navigate(). All sprites are released when enable / disable is toggled, which also removes all sprites from the screen.

The Sprite interface

interface Sprite {

  void hide();
  void navigate(in String url);
  void place(in Number x, in Number y, in String opacity);
  void moveTo(in Number x, in Number y, in Number duration);
  void fade(in Number opacity, in Number duration);
  void remove();
  void captureClick(in Function cb, in boolean captureOnce);
};

Methods

captureClick

Captures a click from the user that enables you to, for example draw a sprite in that place using the callback function

Parameters
cb of type Function
Callback function to call when click is captured.
captureOnce of type boolean
captureOnce if true only captures a single click and if false keeps capturing clicks until the widget is disabled.
No Return Value
No Exceptions
fade

Fades away the display of the sprite.

Parameters
opacity of type Number
Opacity is between 0 and 1.
duration of type Number
Duration is in milliseconds.
No Return Value
No Exceptions
hide

Allows you to reuse a sprite after creation. Use with navigate() and place() to change the content and position of an existing sprite.

No Parameters
No Return Value
No Exceptions
moveTo

Moves a sprite visibly from its initial position to the x,y coordinates specified, taking the duration in milliseconds specified.

Parameters
x of type Number
The x-axis point (from top left, in pixels) to move to.
y of type Number
The y-axis point (from top left, in pixels) to move to.
duration of type Number
The time it takes to make the transition.
No Return Value
No Exceptions
navigate

Changes the content of the sprite.

Parameters
url of type String
No Return Value
No Exceptions
place

This places a sprite onscreen. Resizing the Joost window does not change the placement of the sprite relative to the size of the screen, so resizing may mean sprites go off the visible space.

Parameters
x of type Number
x and y are in pixels from top left of the screen.
y of type Number
x and y are in pixels from top left of the screen.
opacity of type String
Opacity is between 0 and 1.
No Return Value
No Exceptions
remove

Removes the sprite completely. Sprite cannot be retrieved or reused until enable / disable of the widget has been toggled. Don't use this unless you really don't want to use it any more.

No Parameters
No Return Value
No Exceptions

7. Subtitles

A Subtitle object for use, enabling you to quickly create sprites with text, by default placed at the bottom centre of the screen.

The Subtitle interface

interface Subtitle {

           attribute String  text;
           attribute String  verticalAlign;
           attribute String  horizontalAlign;
           attribute String  font;
  void               show();
  void               hide();
};

Attributes

font of type String

String as used in css, defaulting to "sans-serif".

horizontalAlign of type String

String as used in css, defaulting to "middle".

text of type String

The text content of the subtitle.

verticalAlign of type String

String as used in css, defaulting to "bottom".

Methods

hide

Hides the subtitle from the screen. Can be used with setTimeout or Engine.addVideoCallback for example.

No Parameters
No Return Value
No Exceptions
show

Displays the subtitle onscreen. Can be used with setTimeout or Engine.addVideoCallback for example.

No Parameters
No Return Value
No Exceptions

8. References