Package service

Source Code of service.SoundUtil

package service;

import java.net.URISyntaxException;
import java.net.URL;

import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;

public class SoundUtil {
  public static void playSound() {
    try {
      URL url = null;
      try {
        url = PSAUtil.class.getResource("/sounds/beep-6.wav").toURI().toURL();
      } catch (URISyntaxException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
      }
      AudioInputStream audioInputStream = AudioSystem
          .getAudioInputStream(url);
      Clip clip = AudioSystem.getClip();
      clip.open(audioInputStream);
      clip.start();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }

}
TOP

Related Classes of service.SoundUtil

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.