Spread the love

How to Work with AudioClip in Java?

Spread the love

audioclip in java
audioclip in java

How to Work with AudioClip in Java

Remember the issues with the plain audio class? If not then I recommend you to check this link quickly to find more on Audio.

To resolve the issues of audio, java came up with AudioClip class which solves the limitation of play() method.

The methods of AudioClip are defined below:

public AudioClip getAudioClip(URL url);//returns an audio clip object from the url. This method will not return
//until the audio clip has been loaded from the specified URL.So one should place it in a separate thread if
// the file is expected to take a while to download.
public AudioClip getAudioClip(URL url,String name);//Does the same but finds the audio file using base url and
// filename

AudioClip object provides the below methods:

public abstract void loop();//plays the clip in a continuous loop.
public abstract void play();//plays the clip from begining.
public abstract void stop();//stops the clip that is currently playing.

Here is an example how to work with AudioClips:

AudioClip tabla;
AudioClip flute;
Button startButton=new Button("Start");
Button conButton=new Button("Continue");
Button stopButton=new Button("Stop");
public void start(){
public void stop(){
public boolean action(Event e,Object button)
return true;

Spread the love
READ  File Concept Simplified In Java
Animesh Chatterjeehttps://techtravelhub.com/
I am the founder and owner of the blog - TechTravelHub.com, always love to share knowledge on test automation,tools,techniques and tips.I am a passionate coder of Java and VBScript.I also publish articles on Travel ideas and great honeymoon destinations.Apart from these, I am a gear-head,love to drive across India. I have shared lots of articles here on How to travel several parts of India.Customization of cars aka car modification is my another hobby.Get in touch with me on ani01104@gamil.com

Related Articles

Super Keyword in Java Simplified

Super Keyword Super Keyword in Java Simplified: Java defines a special keyword called...



Please enter your comment!
Please enter your name here

Recent Posts

Super Keyword in Java Simplified

Super Keyword Super Keyword in Java Simplified: Java defines a special...

Learn Object Repository in UFT in An Efficient and Fast Manner

Object Repository in UFT The post will cover the following...

Learn What Primary Tools For Test Automation

Primary Tools For Test Automation According to the Gartner report...


Spread the love