[4527] in java-interest
AudioClip casting exception doesn't seem right
daemon@ATHENA.MIT.EDU (John D. Kane)
Thu Jan 4 22:46:29 1996
From: "John D. Kane" <john@insightnews.com>
To: "' java@java.sun.com'" <java@java.sun.com>,
"'java-interest@java.sun.com'" <java-interest@java.sun.com>,
"'jug@solect.com'" <jug@solect.com>
Date: Thu, 04 Jan 96 21:16:00 PST
Because I have a need for an AudioClip to play instantaneously (as
soon as I call a play() method), as opposed to waiting for the sound
to download over the internet and then play, I'm using the URL and
URLConnection classes to load the sound into the clients memory from
the server. I then try to cast this object to an AudioClip but get a
ClassCastException error:
[-----------
# Applet exception: exception: netscape.net.URLInputStream
java.lang.ClassCastException: netscape.net.URLInputStream
at RemoteSound.getRemoteSound(RemoteSound.java:64)
at RemoteSound.init(RemoteSound.java:17)
at
netscape.applet.EmbeddedAppletFrame.run(EmbeddedAppletFrame.java:281
)
at java.lang.Thread.run(Thread.java:289)
-----------]
I've tried such things as:
AudioClip sound = (AudioClip)localObject;
((AudioClip)localObject).play();
It doesn't seem right that I can't do this because I can type-cast
an object into other classes. For example, today I brought over a
text file from the server to the client and cast it into a
DataInputStream using:
InputStream inStream = (InputStream)localObject;
DataInputStream dataInStream = new DataInputStream(inStream);
I could then use dataInStream.readLine() to get the lines of text.
Why then, is casting to an AudioClip object not allowed? I feel I'm
so close to the answer, yet so far away. When I use the
URLConnection class' getContentType() method, it says that the
object is of type "audio/basic". Should this cast operation be
possible? If so, will it be in the future?
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com