You may wish to control the ListenUp Applets from JavaScript. This would allow you to combine HTML FORMs, Flash and other goodies with ListenUp. This page describes the public methods that you can call from JavaScript.
Note that the ListenUp Applet's methods may only be called by JavaScript on systems that support LiveConnect technology. As of 1/4/06 that is only supported on Windows, or on Mac with Firefox or Safari 2.0.2 or later! For more information on LiveConnect click here.
If you want to use JavaScript with a Java Applet then you should set the mayscript parameter in the Applet tag:
It can take a while for an Applet to load and start. These methods should only be called after the Applet is ready. You can use the "readyScript" Applet parameter to request notification of when the Applet is ready. You can also call the isActive() method to check for Applet readyness.
Note that RecorderApplet is a subclass of PlayerApplet so all of the methods of PlayerApplet are also methods of RecorderApplet. Similarly RecorderUploadApplet is a subclass of RecorderApplet.
Methods of PlayerApplet. Inherited by RecorderApplet and RecorderUploadApplet
void erase() |
Erase the entire recording from memory. |
void eraseSelected() |
Erase the currently selected range. |
void displayMessage( text ) |
Set the status message that appears next to the "Send" button. |
void fastForward() |
Play forward faster than normal. It will go faster each time you call it. Requires "transcription" license option. |
double getMaxPlayableTime() |
Return length of the current recording in seconds. |
int getUploadQueueDepth() |
This is used along with the "queueUploads" parameter. You should use the JavaScript "onbeforeupload" feature to make sure this is zero before allowing the user to exit the page. Here is a related example. Since V1.90. |
String getJavaVendor() |
Return System.getProperty("java.vendor"). |
String getJavaVersion() |
Return System.getProperty("java.version"). |
double getPositionInSeconds() |
Return time in seconds current cursor position. This changes when playing or recording. V1.99.5 |
double getStartTime() |
Return time in seconds for the start of the selected region. V1.99.5 |
double getStopTime() |
Return time in seconds for the end of the selected region. V1.99.5 |
boolean isEditable() |
Can the waveform be edited? |
boolean isPlayable() |
Does the current recording have any playable data? |
boolean isPlaying() |
Is audio player currently playing? |
boolean isStopped() |
Is audio player currently stopped? |
void loadRecordingFromDisk() |
Asks the user to select a file from their hard drive then loads the selected file. The file must be a mono WAV, AIFF or Speex file. V1.99.5 |
int loadRecording( String URL ) |
Stops any current playback or recording. Then starts loading a recording from the given URL. It will wait until enough audio has been downloaded that playback can begin. It returns zero if no error, -1 if the download timed out, and -2 if the download failed. |
void loadRecording( String URL, boolean autoPlay ) |
Set autoPlay to true if you want playback to start as soon as the recording is ready to play. |
void loadRecordingNoWait( String URL ) |
Stops any current playback or recording. Then starts loading a recording from the given URL. It will return immediately and not wait for the audio to be downloaded. See setDownloadCompletionScript() below. |
void pauseAudio() |
Temporarily stop playback of recorded audio. Stays at current position so play() can
continue from the same spot. |
void play() |
Begin playing recorded audio. Continue until stopAudio() is called or end of recording is reached. |
void playBetween( startTime, endTime ) |
Select a specified region of the current audio message and then play just the selected region. |
void rewind() |
Rewind while playing. It will go faster each time you call it. Requires "transcription" license option. |
void setAudioSelection( startTime, endTime ) |
Selected a range of audio data in seconds. If you play() then that range will be played. If record() or eraseSelected() then that range will be deleted. |
void setDownloadCompletionScript( String scriptText ) |
Specify JavaScript command to be executed when the loading of a file using loadRecordingNoWait() or loadRecordingFromDisk() has completed successfully. For example:
document.RecorderApplet.setDownloadCompletionScript("downloadComplete()");
Added in V1.99.5 |
void setDownloadFailureScript( String scriptText ) |
Specify JavaScript command to be executed when the loading of a file fails. For example:
document.RecorderApplet.setDownloadFailureScript("downloadFailed()");
Added in V1.99.5 |
void setEditable( boolean flag ) |
If set true then the recording can be edited using the waveform display. |
void slowForward() |
Play forward at normal speed. This is used to turn off fastForward(). (Yes, the name could be better.) Requires "transcription" license option. |
void stopAudio() |
Stop playing or recording audio. Rewind to beginning. |
Methods of RecorderUploadApplet
, inherits methods of
RecorderApplet
void addNameValuePair( String name, String value ) |
Add to list of name/value pairs to be uploaded with next sound file. List will be cleared internally after calling sendRecordedMessage(). |
void addUploadHeaderPair(name,value) |
Add the pair to the HTTP Request header for the next uploaded recording. It will be cleared before the next recording is uploaded. |
void erase() |
Delete any previously recorded material. |
void saveRecordedMessage() |
Save the current recording to the user local hard drive. The user will be shown a file dialog and allowed to name the file and specify the folder to save it in. Since V1.90.
Important: The uploading will happen asynchronously so do not follow this code with a redirection to another page. Otherwise the ListenUp Applet will be unloaded before the save has completed. |
void setUploadCompletionScript( String scriptText ) |
Specify JavaScript command to be executed when upload has completed. For example:
document.RecorderApplet.setUploadCompletionScript("uploadComplete();");
Important: note that the SUCCESS, WARNING or ERROR result must be returned from your server script in order for this functions to be called. |
void setUploadFailureScript( String scriptText ) |
Specify JavaScript command to be executed when an upload attempt has failed. For example:
document.RecorderApplet.setUploadCompletionScript("uploadFailed();");
Important: note that the SUCCESS, WARNING or ERROR result must be returned from your server script in order for this functions to be called. |
void sendRecordedMessage() |
Start uploading a recorded sound file to the server along with any name/value pairs.
Important: The uploading will happen asynchronously so do not follow this code with a redirection to another page. Otherwise the ListenUp Applet will be unloaded before the upload has completed. If you want to go to another page as soon as the upload has finished then please use the refreshURL parameter, or use setUploadCompletionScript() above to cause the redirection. Then the redirection will occur after the upload has finished. |
void sendRecordedMessage( String uploadFileName ) |
Upload a recorded sound file to the server using a specified name for the file on the server. |