Solved

Java/Real Audio

Posted on 1997-05-01
8
365 Views
Last Modified: 2013-11-18
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)
0
Comment
Question by:darryl robinson
  • 5
  • 3
8 Comments
 
LVL 6

Accepted Solution

by:
jpk041897 earned 100 total points
ID: 1220018
Yes, I ran into a similar problem writing a demo for one of my clients.

Since I was in a rush, I cheated (counts as a work arround, I guess).

What I did was create a page that contained a parent Frame with the RA script in it using one row. Created the frame with the FRAMBORDER set to No so as to not show what I was doing.

I then placed my applet in a child frame.

In this way I could control loading an initial page that contained no scripts. And when Java requested to play an RA script I would call:

showDocument(MyRAScriptURL, "_parent");

This call changes thepage of the parent frame to one with identical content plus the RA script.

The customer didn't buy so I didn't look much more into the problem but I did find that the source of the problem is that the RA classes are added to class libraries of scripting language and not to the browsers java CLASSLIB path which changes from browser to browser but is never the same as the JDK's.


0
 

Author Comment

by:darryl robinson
ID: 1220019
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.
0
 
LVL 6

Expert Comment

by:jpk041897
ID: 1220020
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.
0
 

Author Comment

by:darryl robinson
ID: 1220021
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.
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 6

Expert Comment

by:jpk041897
ID: 1220022
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.
0
 
LVL 6

Expert Comment

by:jpk041897
ID: 1220023
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.
0
 

Author Comment

by:darryl robinson
ID: 1220024
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)
0
 
LVL 6

Expert Comment

by:jpk041897
ID: 1220025
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.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
pairstar challenge 2 42
stringclean challenge 26 58
topping2 challenge 13 62
JDeveloper 12c for 32 bit 4 36
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now