DOWNLOADS EXAMPLES SKINS DOCS SUPPORT
 
 

Function Reference

The following page explains all of the function calls that are available for interacting with Wasp via Javascript ( AJAX ).

Please refer to the "Source Code Explained" page for general information on how the code for the player is established. This page also includes information on the "instanceID" associated with each instance of a player.

Since you can have more than one player on a page at a time, when making calls to control the player, the "instanceID" is used to indentify which instance of the player is being referred to. It is important to recognize that the only the instanceID is used -- no Key Words are included -- it is just a number

NOTE: Try not to use the following characters: & ' ? space " # ! \   We recommend only using alpha-numeric characters within arguments. Double-byte and non-alpha-numeric characters must be URL encoded. You may want to apply Javascript's escape() function to any questionable arguments that may contain non-alpha-numeric characters.

 

wasp()

Renders Wasp within a page under the assumption that an external configuration file (waspConfigs.xml) is being used to configure additional options.

This function accepts the following arguments:

wasp(instanceID, bkgdColor, width, height, mediaFile, posterGraphic, configFile)

Arguments:

instanceID

The Wasp instance ID number.

bkgdColor

The background color for the player.

width

The overall width of the player.

height

The overall height of the player.

mediaFile

The URL to the media file you wish to play.

posterGraphic

The URL to the poster graphic to display while the player is static.

configFile

The URL to the config file.

Example:

<script>
wasp("12345",
"FFFFFF",
"240",
"335",
"http://www/path/to/file.mp3",
"http://www/path/to/file.jpg",
"http://www/path/to/waspConfigs.xml"
);
</script>

NOTE: In the above example, each argument has been placed on a new line to make it easier to read.

 

writeWasp()

Renders Wasp within a page using a "config object" to configure the player.

This function accepts the following arguments:

writeWasp(configObject)

Arguments:

configObject

A Javascript object that contains all of the configuration options.

Example:

<script>
// Define a "config object":
var waspConfigs0805132330 = new Object();
// Add configuration variables to the object:
waspConfigs0805132330.instanceID="0805132330";
waspConfigs0805132330.waspSwf="wasp.swf";
waspConfigs0805132330.pageColor="000000";
waspConfigs0805132330.fp="example1.html";
waspConfigs0805132330.im="example1_poster.jpg";
waspConfigs0805132330.f="example1.flv";
waspConfigs0805132330.a="1";
waspConfigs0805132330.me="0";
waspConfigs0805132330.s="0";
waspConfigs0805132330.wm="2";
waspConfigs0805132330.ph="158";
waspConfigs0805132330.pw="210";
waspConfigs0805132330.waspSkin="sz_1|1|3...etc...^sr_1|1";
// Execute the function using the config object as the argument:
writeWasp(waspConfigs0805132330);
</script>

Configuration variable names (and explanations for each) can be obtained from the Wasp API section of this documentation.

 

wasp_amReady_ask()

Call this function to manually check if Wasp is initialized and ready to accept function calls.

wasp_amReady_ask(instanceID)

Arguments:

instanceID

The Wasp instance ID number.

Example:

var isWaspReady = wasp_amReady_ask('12345');
// Returns boolean TRUE or FALSE (NULL).

NOTE: See also "handleWaspInit()" in the "Handlers" section below.

 

wasp_load()

Loads a media file into the player.

wasp_load(instanceID, theMediaFile, thePoster, startPlaying)

Arguments:

instanceID

The Wasp instance ID number.

theMediaFile

URL to media file

thePoster

URL to poster graphic

startPlaying

Set to TRUE to start playing the file as soon as it is loaded. If set to FALSE, user input will be required to start playing the track.

Example:

wasp_load("12345", "example.mp4", "example.jpg", TRUE);

 

wasp_play()

Starts the player or resumes playback.

wasp_play(instanceID)

Arguments:

instanceID

The Wasp instance ID number.

Example:

<a href="javascript:;"
onClick="wasp_play('12345');">
Play
</a>

 

 

wasp_stop()

Stops the track and rewinds the playhead to zero seconds. If a poster graphic is used, the poster graphic will load.

wasp_stop(instanceID)

Arguments:

instanceID

The Wasp instance ID number.

Example:

<a href="javascript:;"
onClick="wasp_stop('12345');">
Play
</a>

 

wasp_pause()

Pauses the track

wasp_pause(instanceID)

Arguments:

instanceID

The Wasp instance ID number.

Example:

<a href="javascript:;"
onClick="wasp_pause('12345');">
Pause
</a>

 

wasp_prev()

Rewinds the play head to the beginning of the track (zero seconds).

wasp_prev(instanceID)

Arguments:

instanceID

The Wasp instance ID number.

Example:

<a href="javascript:;"
onClick="wasp_prev('12345');">
Pause
</a>

 

wasp_share()

Opens the "share" dialog within the player to reveal the URL to the player and the embed code for inclusion within a web page.

wasp_share(instanceID)

Arguments:

instanceID

The Wasp instance ID number.

Example:

<a href="javascript:;"
onClick="wasp_share('12345');">
Pause
</a>

 

wasp_setVolume()

Sets the volume of the player. Can be any number from 1 to 100.

wasp_setVolume(instanceID, thePercent)

Arguments:

instanceID

The Wasp instance ID number.

thePercent

Any number from 1 to 100

Example:

<a href="javascript:;"
onClick="wasp_setVolume('12345', 50);">
Pause
</a>

 

wasp_setMuteState()

Sets the volume to 0 or 100 percent. Also sets the mute button's state.

wasp_setMuteState(instanceID, theState)

Arguments:

instanceID

The Wasp instance ID number.

theState

Can be "on" or "off".

Example:

<a href="javascript:;"
onClick="wasp_setMuteState('12345', "off");">
Pause
</a>

 

wasp_setLoopTrackState()

Sets the loop state and sets the button's state.

wasp_setLoopTrackState(instanceID, theState)

Arguments:

instanceID

The Wasp instance ID number.

theState

Can be "on" or "off".

Example:

<a href="javascript:;"
onClick="wasp_setLoopTrackState('12345', "on");">
Pause
</a>

 

 

wasp_getPlayheadPercent()

Returns the current percentage (0-100) of the playhead.

wasp_getPlayheadPercent(instanceID)

Arguments:

instanceID

The Wasp instance ID number.

Example:

var playHeadPosition = wasp_getPlayheadPercent('12345');

wasp_getPlayheadSeconds()

Returns the tracks current time in seconds.

wasp_getPlayheadSeconds(instanceID)

Arguments:

instanceID

The Wasp instance ID number.

Example:

var playHeadSeconds = wasp_getPlayheadSeconds('12345');

wasp_setPlayheadPercent()

Sets the playhead a percentage point.

wasp_setPlayheadPercent(instanceID, thePercent)

Arguments:

instanceID

The Wasp instance ID number.

theSeconds

A specific point (in percent) to move the playhead to. If the track is not yet fully loaded the playhead will advance to the maximum time available for playback.

For example, if this function is called and you are attempting to position the playhead to 10 percent, but the track is still loading and not enough data is available to to move the playhead to the 10 percent mark, the playhead will advance to the maximum time available based on the amount of data loaded. However if the 10 percent mark is available for playback the playhead will go to 10 percent and continue loading.

Example:

var playHeadPercent = wasp_setPlayheadPercent('12345', 10);

wasp_setPlayheadSeconds()

Sets the playhead to X number of seconds.

wasp_getPlayheadSeconds(instanceID, theSeconds)

Arguments:

instanceID

The Wasp instance ID number.

theSeconds

A specific point (in seconds) to move the playhead to. If the track is not yet fully loaded the playhead will advance to the maximum time available for playback.

For example, if this function is called and you are attempting to position the playhead at 30 seconds, but the track is still loading and not enough data is available to to move the playhead to 30 seconds, the playhead will advance to the maximum time available based on the amount of data loaded. However if the 30 second mark is available for playback the playhead will go to 30 seconds and continue loading.

Example:

var playHeadSeconds = wasp_setPlayheadSeconds('12345', 30);

wasp_getLoadPercent()

Returns a number representing a percentage of the total amount of data loaded.

wasp_getLoadPercent(instanceID)

Arguments:

instanceID

The Wasp instance ID number.

Example:

var percentLoaded = wasp_getLoadPercent('12345');

wasp_getLoadState()

Returns an object that contains percent, bytes loaded, bytes total and status.

wasp_getLoadState(instanceID)

Arguments:

instanceID

The Wasp instance ID number.

Example:

var returnedObject = wasp_getLoadState('12345');
// Returns and object containing the following variables:
returnedObject.percent = 80     // percent loaded
returnedObject.loaded = 1322108 // bytes loaded
returnedObject.total = 1652636  // total bytes
returnedObject.status = 1       // 1 = loading in progress
                                // -1 = not loading

 

wasp_getPlayerState()

Returns an object that contains percent, bytes loaded, bytes total and status.

wasp_getPlayerState(instanceID)

Arguments:

instanceID

The Wasp instance ID number.

Example:

var returnedObject = wasp_getPlayerState('12345');
// Returns and object containing the following variables:
returnedObject.buffering = false
returnedObject.bufferState = 1
returnedObject.buffer = 15.138
returnedObject.printTime = 6:26
returnedObject.remaining_nice = 11:16
returnedObject.remaining = 676.976
returnedObject.current_nice = 6:26
returnedObject.current = 386.063
returnedObject.duration_nice = 17:43
returnedObject.duration = 1063.039
returnedObject.percent = 0.363169
returnedObject.status = 1
returnedObject.init = 1

buffering

TRUE = buffering
FALSE = not buffering

bufferState

1 = buffering full
0 = buffering
-1 = buffer empty

buffer

number of seconds available in buffer

printTime

Nicely formatted time based on the way the time stamp has been formatted using the format time configuration option.

remaining

Total seconds remaining

remaining_nice

Nicely formatted remaining time

current_nice

Nicely formatted current time

duration

Total seconds

duration_nice

Nicely formatted total time

percent

A float number representing the current time in percentage

status

1 = playing
0 = paused
-1 = not loaded / stopped

init

1 = media is formatted and playback has begun
0 = media is formatted and available for playback, but is paused or stopped.
-1 = media is not fully set up / nothing loaded / no media

wasp_memory_clear()

Clears the memory (if set) so that the next time the page is loaded, it will not resume playback.

wasp_memory_clear(instanceID)

Arguments:

instanceID

The Wasp instance ID number.

Example:

<a href="javascript:;"
onClick="wasp_memory_clear('12345');">
Pause
</a>

 

 

 

 

 

  ©Copyright Plaino LLC. All rights reserved.