Solved

Java/Real Audio

Posted on 1997-05-01
8
375 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

776 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