ContinuousAudioDataStream problems
ok, so i have lots of audio in my program that only plays once, and that all just works fine and perfect
This is what i do to play music
try
{
InputStream a = new FileInputStream ("Sounds-Music/MainTheme.wav");
theme = new AudioStream (a);
}
catch (java.io.IOException z) //catching the exception
{
}
// Play audio.
AudioPlayer.player.start (theme);
now im trying to make a ContinuousAudioDataStream. This is my code, it compiles fine, but
doesant play any sound?, what am i missing?
try
{
InputStream a = new FileInputStream ("Sounds-Music/MainTheme.wav");
theme = new AudioStream (a);
AudioData themestream = theme.getData ();
// Create ContinuousAudioDataStream.
ContinuousAudioDataStream THEME = new ContinuousAudioDataStream (themestream);
// Play audio.
AudioPlayer.player.start (THEME);
}
catch (java.io.IOException z) //catching the exception
{
}
scheppy
Junior Poster in Training
95 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
When debugging never NEVER NEVER have an empty catch block! There are many reasons why the code in your try block may fail, and for most of them you will get an Exception that describes exactly what went wrong, and exactly where in the code.
change
catch (java.io.IOException z) //catching the IO exception
{ // Pretend it didn't happen. Ignore the error message. Discard the debug info
}
to
catch (Exception z) //catching any exception, checked or unchecked
{
z.printStackTrace(); // display the error message and all debugging info.
}
JamesCherrill
Posting Genius
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
When debugging never NEVER NEVER have an empty catch block! There are many reasons why the code in your try block may fail, and for most of them you will get an Exception that describes exactly what went wrong, and exactly where in the code.
change
catch (java.io.IOException z) //catching the IO exception
{ // Pretend it didn't happen. Ignore the error message. Discard the debug info
}
to
catch (Exception z) //catching any exception, checked or unchecked
{
z.printStackTrace(); // display the error message and all debugging info.
}
ok, thanks for that, i really just totally forgot, really stupid, but now i get this error from the stcktrace or whatever
java.io.IOException: could not create AudioData object
at sun.audio.AudioStream.getData(Unknown Source)
What does this mean
scheppy
Junior Poster in Training
95 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
Sorry, I have expertise in java Audio - but at least you have a message now! ;)
J
JamesCherrill
Posting Genius
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
Sorry, I have expertise in java Audio - but at least you have a message now! ;)
J
ok, well hopefully someone else does
thanks
scheppy
Junior Poster in Training
95 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
Aaarrgghh - just noticed the missing word in my post. What I should have said, of course, is Sorry, I have no expertise in java Audio
JamesCherrill
Posting Genius
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
Aaarrgghh - just noticed the missing word in my post. What I should have said, of course, is Sorry, I have no expertise in java Audio
haha, just seen that
scheppy
Junior Poster in Training
95 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
haha, just seen that
ok, so i was using wav file format and i converted it to mp3, and now i get this error
java.io.IOException: could not create audio stream from input stream
scheppy
Junior Poster in Training
95 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
ok, so i have lots of audio in my program that only plays once, and that all just works fine and perfect
This is what i do to play music
try
{
InputStream a = new FileInputStream ("Sounds-Music/MainTheme.wav");
theme = new AudioStream (a);
}
catch (java.io.IOException z) //catching the exception
{
}
// Play audio.
AudioPlayer.player.start (theme);
now im trying to make a ContinuousAudioDataStream. This is my code, it compiles fine, but
doesant play any sound?, what am i missing?
try
{
InputStream a = new FileInputStream ("Sounds-Music/MainTheme.wav");
theme = new AudioStream (a);
AudioData themestream = theme.getData ();
// Create ContinuousAudioDataStream.
ContinuousAudioDataStream THEME = new ContinuousAudioDataStream (themestream);
// Play audio.
AudioPlayer.player.start (THEME);
}
catch (java.io.IOException z) //catching the exception
{
}
hey i thought these two links may be of help? : http://stackoverflow.com/questions/26305/how-can-i-play-sound-in-java and http://stackoverflow.com/questions/2416935/how-to-play-wav-files-with-java
DavidKroukamp
Practically a Master Poster
693 posts since Dec 2011
Reputation Points: 282
Solved Threads: 169
scheppy
Junior Poster in Training
95 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
ok, i figured it out, if the sound file im trying to play is over 1 mb, it doesant work, if its under 1 mb it does work.
anyone have any ideas on how to compress a 2minute and 18 sec song to under 1 mb, right now it is 1.05 mb
what format?
DavidKroukamp
Practically a Master Poster
693 posts since Dec 2011
Reputation Points: 282
Solved Threads: 169
scheppy
Junior Poster in Training
95 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
DavidKroukamp
Practically a Master Poster
693 posts since Dec 2011
Reputation Points: 282
Solved Threads: 169
see here: http://www.wavpack.com/ and here: http://www.blazemp.com/compress_wav_files.htm dont know how well they work, but Google showed them highest ranked free software for wav compression?
perfect, the program blaze media pro works amazing, alot you can do. alittle complicated at first, but just fool around with it alittle and becomes a great program to use. I managed to compress my wav file to under 750kb, and this is a 2 minute and 18 sec song, I cant notice any quality loss, thanks alot. loops perfectly now
scheppy
Junior Poster in Training
95 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0