Created
February 14, 2010 18:34
-
-
Save scottdavis/304170 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Sets the audio file from which the data-stream will be generated of. | |
* | |
* @param audioFileURL The location of the audio file to use | |
* @param streamName The name of the InputStream. if <code>null</code> the complete path of the audio file will be | |
* uses as stream name. | |
*/ | |
public void setAudioFile(URL audioFileURL, String streamName) { | |
// first close the last stream if there's such a one | |
if (dataStream != null) { | |
try { | |
dataStream.close(); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
dataStream = null; | |
} | |
assert audioFileURL != null; | |
if (streamName != null) | |
streamName = audioFileURL.getPath(); | |
AudioInputStream audioStream = null; | |
try { | |
audioStream = AudioSystem.getAudioInputStream(audioFileURL); | |
} catch (UnsupportedAudioFileException e) { | |
System.err.println("Audio file format not supported: " + e); | |
e.printStackTrace(); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
curAudioFile = new File(audioFileURL.getFile()); | |
for (AudioFileProcessListener fileListener : fileListeners) | |
fileListener.audioFileProcStarted(curAudioFile); | |
setInputStream(audioStream, streamName); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment