How to play audio file in Applet in Java?

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

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

/**
 * Created by http://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);
        }
    }
}

Please Post Your Comments & Reviews

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.