SDK |
Documentation |
JavaSonics ListenUp is no longer for sale.Controlling the ListenUp Applet with JavaScript.Some browsers, notably Internet Explorer and Netscape on Windows, allow JavaScript in a web page to communicate with a Java Applet. One could, for example, hide the applet transport controls (the play, stop, and record buttons), and substitute simple JavaScript/HTML buttons instead.
Setting up the <applet> TagTo enable a Java applet to communicate with JavaScript, you must include the the following in the applet tag: mayscript="true" You must give the Applet a name in the Applet tag which can be used by JavaScript to refer to the Applet. For example: name="JavaSonicRecorderUploader" You can hide the applet's transport controls by passing it the tag: <param name="showTransport" value="no" Calling the Applet from JavaScriptTo send a command to the applet from JavaScript, use the NAME given with the Applet tag. Call document.appletName.methodName(). For example, to start playback: document.JavaSonicRecorderUploader.play(); See the complete list of the applet methods that can be called from JavaScript. Callbacks from Java to JavaScriptTo enable JavaScript to receive notification when the Recorder Applet starts, plays, records, etc, set the Applet's "requestStateChanges" parameter to "yes". <param name="requestStateChanges" value="yes"> ListenUp will then call a JavaScript function called "LUPJS_StateChanged( previousState, newState )" whenever the state changes. You define that function in JavaScript. This JavaScript function can enable or disable HTML buttons, etc depending on the state of the applet. For example, it can check if the player has stopped then you could disable your "Stop" button. For example: function LUPJS_StateChanged( previousState, newState ) Knowing if the Applet is ReadyYou should tell the Applet to notify JavaScript when the Applet is ready to be called. This can prevent JavaScript from calling the Applet before it is loaded and ready. For example, we could have the Applet call a JavaScript function called "appletIsReady()" that enabled the HTML buttons. <param name="readyScript" value="appletIsReady();"> You can also call the isActive() method to check for Applet readyness. if( document.JavaSonicRecorderUploader.isActive() ) |