Clipstream audio JavaScript methods
All examples assume that the name of the applet (object) is clipstream_applet.
| Method | Description |
| stop_audio | Stop the audio stream |
| play_audio | Start the audio stream |
| pause_audio | Pause the audio stream |
| toggle_audio | Play/stop - if stopped will play, if playing will stop |
| toggle_audio_pause | Play/pause - if paused will play, if playing will pause |
| set_audiostreamurl | Set new value to AudioStreamURL (change value in parameter list) |
| get_currentstreamurl | Returns the name of the current audio stream |
| fast_forward | Skip to the next URL in the playlist. Loop back to the first if it hits the last one |
| fast_backward | Skip to the previous URL in the playlist. Loop back to the last if it hits the first one |
| set_callbackOnPlay | Set the JavaScript method to call on play |
| set_callbackOnTimer | Set the JavaScript method to call on timer |
| set_callbackOnStop | Set the JavaScript method to call on stop |
| get_pos | Returns the current position in the audio stream (in miliseconds) |
| get_length | Returns the current clips length (in miliseconds) |
| get_status | Returns the current status of the applet |
| seek_audio | Set the audiostream to value specified (in miliseconds) |
| seek_audio_percentage | Set the audiostream to value specified (in percent) |
Stop the audio stream
Prototype
void stop_audio(void)
Parameters
None
Returns
Nothing
Description
Call this function to stop the audio stream. Same as pressing the stop button on the applet.
Example
document.clipstream_applet.stop_audio();
You can view a working demo here
Start the audio stream
Prototype
void play_audio(void);
Parameters
None
Returns
Nothing
Description
Call this function to start the audio stream. Same as pressing the play button on the applet.
Example
document.clipstream_applet.play_audio();
You can view a working demo here
Pause the audio stream
Prototype
void pause_audio(void);
Parameters
None
Returns
Nothing
Description
Call this function to pause the audio stream. Same as pressing the pause button on the applet.
Example
document.clipstream_applet.pause_audio();
You can view a working demo here
Play/stop - if stopped will play, if playing will stop
Prototype
void toggle_audio(void);
Parameters
None
Returns
Nothing
Description
This function will start the audio if the applet is stopped or stop the audio if it's playing. Useful if you want one button to start and stop the audio.
Example
document.clipstream_applet.toggle_audio();
You can view a working demo here
Play/pause - if paused will play, if playing will pause
Prototype
void toggle_audio_pause(void);
Parameters
None
Returns
Nothing
Description
This function will start the audio if the applet is stopped or pause the audio if it's playing. Useful if you want one button to start and pause the audio.
Example
document.clipstream_applet.toggle_audio_pause();
You can view a working demo here
Set new value to AudioStreamURL (change value in parameter list)
Prototype
void set_audiostreamurl(int x, String newURL);
Parameters
x - an integer value to specify which audio url to change. Values can range from 0 to 98 (as you can have AudioStreamURL1 .. AudioStreamURL99).
newURL - a string specifying the new AudioStreamURL value.
Returns
Nothing
Description
Use this function to update the audio files the applet will play. This is useful if you have multiple files to play with one applet.
Example
document.clipstream_applet.set_audiostreamurl(0, "newFile.22");
You can view a working demo here
Returns the name of the current audio stream
Prototype
String get_currentstreamurl(void);
Parameters
None
Returns
A string with the URL of the current audio file
Description
Use this function to get the name of the file being played
Example
var currentFile = document.clipstream_applet.get_currentstreamurl();
You can view a working demo here
Skip to the next URL in the playlist. Loop back to the first if it hits the last one
Prototype
void fast_forward(void);
Parameters
None
Returns
Nothing
Description
Use this function to jump to the next audio file in the playlist. If you reach the end it will loop back to the first one.
Example
document.clipstream_applet.fast_forward();
You can view a working demo here
Skip to the previous URL in the playlist. Loop back to the last if it hits the first one
Prototype
void fast_backward(void);
Parameters
None
Returns
Nothing
Description
Use this function to jump to the previous audio file in the playlist. If you reach the first it will loop back to the last one.
Example
document.clipstream_applet.fast_backward();
You can view a working demo here
Set the JavaScript method to call on play
Prototype
void set_callbackOnPlay(String newFunction);
Parameters
newFunction - a string with the name of the new JavaScript function to call.
Returns
Nothing
Description
Overrides the value specified in the applet parameter CallbackOnPlay. This function will be called by the applet when playback is started
Example
document.clipstream_applet.set_callbackOnPlay("playFunc()");
You can view a working demo here
Set the JavaScript method to call on timer
Prototype
void set_callbackOnTimer(String timerFunction, double x);
Parameters
timerFunction - JavaScript function to call when timer is triggered
x - time in seconds when to trigger the callback function specified by timerFunction
Returns
Nothing
Description
Use this for applications such as a timed slide show. You can start a timer and tell the applet to call a specific function when the timer is triggered.
Example
document.clipstream_applet.set_callbackOnTimer("timerFunction()", 30);
You can view a working demo here
Set the JavaScript method to call on stop
Prototype
void set_callbackOnStop(String stopFunction);
Parameters
stopFunction - a string with the name of the new JavaScript function to call.
Returns
Nothing
Description
This function will be called by the applet when playback is stopped.
Example
document.clipstream_applet.set_callbackOnStop("stopFunc()");
You can view a working demo here
Returns the current position in the audio stream (in miliseconds)
Prototype
int get_pos(void);
Parameters
None
Returns
Integer value specifying the current position of the audio stream in miliseconds.
Description
Call this function to determine current position.
Example
var currentPosition = document.clipstream_applet.get_pos();
You can view a working demo here
Returns the current clips length (in miliseconds)
Prototype
int get_length(void);
Parameters
None
Returns
Integer value specifying the current length of the audio stream in miliseconds.
Description
Call this function to determine current clips length.
Example
var currentLength = document.clipstream_applet.get_length();
You can view a working demo here
Returns the current status of the applet
Prototype
String get_status(void);
Parameters
None
Returns
String with one of the following values:
Description
Call this function to determine current status of the applet.
Example
var currentStatus = document.clipstream_applet.get_status();
You can view a working demo here
Set the audiostream to value specified (in miliseconds)
Prototype
void seek_audio(int newPos);
Parameters
newPos - integer value specifying the new position of the audio stream (in miliseconds).
Returns
Nothing
Description Used to set the playback position of the current audio stream in miliseconds.
Example
document.clipstream_applet.seek_audio(8000);
You can view a working demo here
Set the audiostream to value specified (in percent)
Prototype
void seek_audio(double newPercent);
Parameters
newPercent - value specifying the new position of the audio stream (in percent). Valid values range from 0 to 1.
Returns
Nothing
Description
Used to set the playback position of the current audio stream as a percentage.
Example
document.clipstream_applet.seek_audio_percentage(0.5);
You can view a working demo here