Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

could not get audio input stream from input stream  RSS feed

 
olze oli
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

following problem:


throws the exception:
Exception in thread "main" javax.sound.sampled.UnsupportedAudioFileException: could not get audio input stream from input stream
at javax.sound.sampled.AudioSystem.getAudioInputStream(AudioSystem.java:1102)
at test.Main.main(Main.java:35)
Java Result: 1


i understand that mp3 is not supported by java, but what really confuses me, theres a java player which is open source, called: jlGui
and it just plays nearly everything, even the mp3 stream... so i checked the source and... i cant get it

the following source is used by jlgui:

and

m_dataSource is a BufferedInputStream without any modification...

please can someone tell me how is that working? i just dont understand it
 
Rob Spoor
Sheriff
Posts: 21090
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It may install support for MP3 earlier, perhaps in a static initializer or something. (This is just a guess though.)
 
olze oli
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for your quick reply

sounds interesting, can you give me some informations how this could be achieved?
i just saw a .jar file which looks like the implementation i'm looking for, called mp3spi - it is a part of the player - unfortunatly without documentation (howto)
maybe i can find what i'm looking for in the source...
 
olze oli
Ranch Hand
Posts: 174
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

just copied jl.jar mp3spi.jar and tritonus_share.jar to my classpath and its just working
 
Rob Spoor
Sheriff
Posts: 21090
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just downloaded mp3spi as well, and found out it's using the ServiceLoader mechanism: inside the JAR file, inside the META-INF/services folder, there are two files that will be used by ServiceLoader to inject the MP3 decoder into the Java audio system.
 
Damaso Lopez
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
olze oli wrote:
just copied jl.jar mp3spi.jar and tritonus_share.jar to my classpath and its just working


I download these files and copy en my project, but don't run because always says the message. Are there others things that those?? Can you help me, please???

I've this code:



 
olze oli
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean with "says the message"? The same message as mine in the first post? I noticed that some mp3 files are not recognized. First check on a "regular" mp3 file if its working.
You can use the mp3spi player (on the same site, javalayer) to test if it *should* work. If it does in that player, you can be sure that the problem exists in your application.
Make sure your classpath contains that classes. If so, it should play that file/stream.
 
Damaso Lopez
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
olze oli wrote:What do you mean with "says the message"? The same message as mine in the first post? I noticed that some mp3 files are not recognized. First check on a "regular" mp3 file if its working.
You can use the mp3spi player (on the same site, javalayer) to test if it *should* work. If it does in that player, you can be sure that the problem exists in your application.
Make sure your classpath contains that classes. If so, it should play that file/stream.


Yeah your message "couldn't get audio input stream from input stream" Ok! I prove it, the problem is I do not have any mp3 file, it all comes from UDP. Do you change anything next posts? because after then receive(datagrampacket);
I put this line:

line.write(datagrampacket.getData(),0,datagrampacket.getLenght()); I can listen to the music
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!