i m not getting how to play a mp3 file using applet? i m using AudioClip A = getAudioClip(x); where x is --> URL x=C:\'Users\'gourav\'java_pr; its just a try! i donot know how to use this. it is showing error. tell me how to use audioclip interface?

"It is showing error" is not helpful to anyone. If you want help resolving an error, you need to post what it is.

You also need to read the forum rules about using clear, relevant titles for your threads. "problem!" is not a useful title.

Edited 4 Years Ago by Ezzaral: n/a

"It is showing error" is not helpful to anyone. If you want help resolving an error, you need to post what it is.

You also need to read the forum rules about using clear, relevant titles for your threads. "problem!" is not a useful title.

public void paint(Graphics g)
    {
        URL url = getDocumentBase();
        //URL x="C:\Users\gourav\java_pr";
        l=url.toString();
        g.drawString(msg,50,20);
        g.drawString(l,200,200);
        showStatus("hello!whats upp!!");
        g.drawString(""+ i,100,100);
try{
                    AudioClip A = getAudioClip(new URL("C:\'Users\'gourav\'java_pr"));

        }catch(Exception e)
                {

    }
        A.play();
    }

this is my function in which i am using audio to be played. it is a applet program. the class in which this function is declared has extends applet class.now,

C:\Users\gourav\java_pr\app.java:60: error: cannot find symbol
        A.play();
        ^
  symbol:   variable A
  location: class app
1 error

Tool completed with exit code 1

this is the error coming when i compile this .java file. now your all question are solved. now please tell :'(

Edited 3 Years Ago by mike_2000_17: Fixed formatting

problem with scope
you're declaring and initializing A within your try block.
put the A.play();
call also in the try block

problem with scope
you're declaring and initializing A within your try block.
put the A.play();
call also in the try block

i have somewhere that applet supports only ".au" files. is it true ?? and should i given full path or only the name of .mp3 file in URL ?

very well possible.
playing .mp3 files is not standard supported in Java.
if you want to play .mp3 files, you can use (for instance) JMF (Java Media Framework), or, what I would recommend, since it's quite easy and all you need to do is add a single .jar file to your classpath, the jLayer library which you can find here.

This article has been dead for over six months. Start a new discussion instead.