OMTK
Open Media Toolkit

Javascript - Documentation

Note: The OMTK Javascript player requires that either Flash 10 (or newer) or Java 5 (1.5) or newer is installed.

The OMTK Javascript library constists mainly of two modules: OMTK_C to detect browser capabilities and OMTK_P, a bridge between the Flash or Java backend player and Javascript. Ususally, the capability detector is used to see if the browser has a suitable Flash player or Java plugin and then the player is initialized to use one of the supported backends. The functions can be used from a web page, by including the scripts omtkc.js and omtkp.js.

OMTK_C

function OMTK_C_detect( preferred ) : string

Checks if the Flash player or the Java plugin is available in a supported version and returns either "flash", "java" or null if no plugin is available. By default, the Flash player plugin is preferred and if it's detected, no further attempts are made to check for the Java plugin. The function can be called with the preferred argument set to "java" to first check for a Java plugin, before the Flash capabilities of the browser are tested if no Java plugin was found.

function OMTK_C_detectJava() : boolean

Checks only if the Java plugin is available in a supported version and returns true or false.

function OMTK_C_detectFlash() : boolean

Checks only if the Flash player is available in a supported version and returns true or false.

OMTK_P

function OMTK_P_init( backend )

Initializes the player with the specified backend ("flash" or "java").

function OMTK_P_play( url )

Plays an Ogg/Vorbis stream or file from the specified URL. Note that the Flash and Java security restrictions must be obeyed, meaning that the URL must be resolve to the same IP address, from which the Flash movie or the Java applet was loaded. Both single Ogg/Vorbis files and chained Ogg streams (as commonly produced by media servers) are supported.

function OMTK_P_getMetaData( key )

Returns the Vorbis comment header with the specified key from the currently playing file or null if no stream is playing or there is no comment header for the given key.

function OMTK_P_getPosition()

Returns the time position of the currently playing Vorbis stream or -1 if no stream is playing.

function OMTK_P_addCompleteListener( function )

Adds a Javascript callback function, which is invoked when the currently playing file is finished. The callback function is called with no arguments.

function OMTK_P_addMetadataUpdateListener( function )

Adds a Javascript callback function, which is invoked when the stream metadata changes. This happens after a new stream has been started with the OMTK_P_play function, or for chained Ogg streams for each contained Vorbis stream. The callback function is called with no arguments.