Java AudioInputStream Read loadSound(String soundLocation)

Here you can find the source of loadSound(String soundLocation)

Description

Load a sound without cache-ing it.

License

Open Source License

Parameter

Parameter Description
soundLocation the location of the sound

Return

the sound that was loaded

Declaration

public static Clip loadSound(String soundLocation) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import javax.sound.sampled.*;

import java.io.*;

public class Main {
    /**//from   ww  w  .  java2s  .c o  m
     * Load a sound without cache-ing it.
     * @param soundLocation the location of the sound
     * @return the sound that was loaded
     */
    public static Clip loadSound(String soundLocation) {
        try {
            AudioInputStream stream = AudioSystem.getAudioInputStream(new File(soundLocation));
            try {
                Clip clip = AudioSystem.getClip();
                return clip;
            } catch (LineUnavailableException e) {

            }
        } catch (UnsupportedAudioFileException e) {
        } catch (IOException e) {
        }
        return null;
    }
}