Link to home
Start Free TrialLog in
Avatar of darryl robinson
darryl robinson

asked on

Java/Real Audio

I'm hoping someone here may have encountered (and
overcome) similar difficulties in using Java to control
an embedded RealAudio plugin.

Using the sample code provided by Prognet, I created
an applet that simply sets the source of a RealAudio plugin to a URL and then calls the plugin's DoPlayPause method.
The plugin seems to respond to the SetSource method by attempting to find the selected sound (a .rpm file). However, it never begins to play.

An excerpt from the applet source code follows:
import java.awt.*;
import java.applet.*;
import netscape.javascript.JSException;
import netscape.javascript.JSObject;
import RAObserver;
import RAPlayer;
...
        void button1_Clicked(Event event) {
          JSObject jsWin = JSObject.getWindow(this);;
          JSObject jsDoc = (JSObject)jsWin.getMember("document");
          RAPlayer ra = (RAPlayer)jsDoc.getMember("javaPlug1");;
          ra.SetAutoStart(true);    
          ra.SetSource("http://1.1.1.1/audio/bahamas.rpm");
          ra.DoPlayPause();
        }
...

Performing the task using JavaScript works without a hitch. The following code not only sets the source, but it plays the sound:
<SCRIPT LANGUAGE="JavaScript">
  function playURL() {
    document.javaPlug1.SetSource("http://1.1.1.1/audio/bahamas.rpm");
    document.javaPlug1.DoPlayPause();
  }
</SCRIPT>

However, when I call this JavaScript function from my Java applet, Navigator freezes. I've tried calling the function using both "call" and "eval", as follows:
        String args[]={""};
        jsWin.call("playURL", args);
OR
        jsWin.eval("playURL();");

I'm using Netscape Navigator 3.01 Gold with the RealPlayer 4.0 plugin. I also tried it with the RealAudio Player 3.0 plugin.

Has anyone else encountered this problem? If so, did you find a workaround? If you could post and mail your response, it would be helpful.

Darryl Robinson (darrylr@robotica-inc.com)
ASKER CERTIFIED SOLUTION
Avatar of jpk041897
jpk041897

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of darryl robinson
darryl robinson

ASKER

JPK,

Thanks for the reply. I'm going to give your creative workaround a shot and let you know how it goes. Meanwhile, I have some additional info to lend to the discussion. Even when I place RAObserver.class and RAPlayer.class in the same directory as the applet, the problem persists. Shouldn't these classes be found if they're in the same directory as the applet (regardless of the browser's classpath)?

Regards,
Darryl R.
Not necesarily, remember that JAVAScript and JAVA are not the same language. Although Javascript is "inspired " by Java.

Thats the main reason that communicating scripts with applets within the client  is such a nightmare and usualy left to sockets.
But if I'm using Netscape Navigator, the Netscape JavaScript classes (netscape.javascript.JSException and netscape.javascript.JSObject) are built into the browser. I agree that Java/JScript communication is a nightmare (based on the number of hours that I wasted on it yesterday), but I think it may be the RA classes themselves and not the classpath issue.
Its a posibility, I'll try to look into int tommorow or saturday for intelectual pleasures sake.

My e-mail is:

 jkelleghan@usa.net

if you wish to continue this alternate thread.
Finaly had time to look into your problem more deeply

Your right, it looks like an RA implementation over Netscape issue. When attempting a solution using ActiveX (via MSIE) it worked fine.

Let me know how the workarround worked for you.
Finally got around to implementing this yesterday. The workaround works great. The only hitch I encountered after getting the sound to play on demand is that the applet is now incompatible with Internet Explorer (because it relies on Netscape's javacript classes).

Thanks again for a very creative solution to this problem.
Darryl R. (darrylr@robotica-inc.com)
You could use the System getProperties class to work arround this problem.

Use a call to:

String s = System.getProperty("java.vendor");

to determine which browser you are using.

You can then decide if you want to call the page that contains the Netscape Java script or one that contains an ActiveX component.