How to play audio file in Applet in Java?

[java]
/****************************************************************************************
* Created on 07-2011 Copyright(c) https://kodehelp.com All Rights Reserved.
****************************************************************************************/
package com.kodehelp.java.applet;

import java.applet.Applet;
import java.applet.AudioClip;
import java.net.URL;

/**
* Created by https://kodehelp.com
* Date: 7/18/11
*/
public class PlayAudioInApplet {
public static void main(String[] args){
try {
URL url = new URL("Audio file" );
AudioClip ac = Applet.newAudioClip(url);
ac.play();
System.in.read();
ac.stop();
} catch (Exception ex) {
System.out.println(ex);
}
}
}
[/java]

Please Post Your Comments & Reviews

Your email address will not be published. Required fields are marked *