Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Java/Real Audio

Posted on 1997-05-01
8
Medium Priority
?
385 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 6

Accepted Solution

by:
jpk041897 earned 200 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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
 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Before we dive into the marketing strategies involved with creating an effective homepage, it’s crucial that EE members know what a homepage is. In essence, a homepage is the introductory, or default page, of a website that typically highlights the …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses

730 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