Question about Computers & Internet
Here's how the code for these steps looks:
AudioClip ac = getAudioClip(getCodeBase(), soundFile);
ac.play(); //play once
ac.stop(); //stop playing
ac.loop(); //play continuously
It would seem logical to use this same code to play audio clips in a Java application. Unfortunately, if you do that you will get errors from the compiler. Why? Because the AudioClip object and the getAudioClip() method are part of the java.applet package -- and are not part of applications. The good news is we can dive down and make things work ourselves.
The trick to solving this problem is to use some undocumented features that are provided by Sun in its JDK. Taking a peek inside the classes.zip file from the Sun JDK (using any of the various zipfile utilities), we find not only the standard Java packages such as java.applet but also sun.audio. (These are in the directory sun/audio.)
The sun.audio package contains everything we need to be able to play audio clips! Here's the code:
import sun.audio.*; //import the sun.audio package
//** add this into your application code as appropriate
// Open an input stream to the audio file.
InputStream in = new FileInputStream(Filename);
// Create an AudioStream object from the input stream.
AudioStream as = new AudioStream(in);
// Use the static class member "player" from class AudioPlayer to play
// Similarly, to stop the audio.
To use a URL as the audio stream source, substitute the following for the input stream and audio stream setup:
AudioStream as = new AudioStream (url.openStream());
Playing the audio stream continuously adds a bit more complexity:
// Create audio stream as discussed previously.
// Create AudioData source.
AudioData data = as.getData();
// Create ContinuousAudioDataStream.
ContinuousAudioDataStream cas = new ContinuousAudioDataStream (data);
// Play audio.
// Similarly, to stop the audio.
Posted on Jan 22, 2009
a 6ya expert can help you resolve that issue over the phone in a minute or two.
best thing about this new service is that you are never placed on hold and get to talk to real repairmen in the US.
the service is completely free and covers almost anything you can think of (from cars to computers, handyman, and even drones).
click here to download the app (for users in the US for now) and get all the help you need.
Posted on Jan 02, 2017
Tips for a great answer:
Mar 10, 2011 | Computers & Internet
Mar 02, 2011 | Computers & Internet
Jan 09, 2011 | Samsung SC-DC173 DVD Camcorder
This course uses (Java applets (Suns' Java technology) In older version of Microsoft internet Browser the Microsoft Virtual is already installed in your machine. In newer version of windows installation, the Java is not install automatically. In most cases, now you must install the Java separately into your machine http://java.com/en/index.jsp (download free Java software)
DursulQuran is also available in "Printed version", in theory does not require a computer and the course may be follow independently by using a booklet. In addition, the sound of each lessons have been recorded that may be run from stand alone CD player as well the audio cassettes. The course material may be downloaded freely from this site. The printed material are prepared in Acrobat Pdf. format and easily printable on 8.5 x 11 paper. the sound clips are in MP3 format that can be burned into a audio CD (and latter transfer into an audio cassette) as well as run in your hard disk.
Obtain Printed version click here
Dec 02, 2010 | GPX Audio Players & Recorders
Jul 09, 2009 | SanDisk Sansa Clip MP3 Player
May 05, 2009 | AT&T CECT Unlocked i68+ Quadband GSM FM...
Oct 01, 2008 | Acer Extensa 503T Notebook
Aug 18, 2007 | Motorola Mobility RAZR V3
288 people viewed this question
Usually answered in minutes!