Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Abstract Window Toolkit

 
LaTeef Lusk
Greenhorn
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a class that is available in the awt that will allow you to play music in a program or applet?
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. See e555 and e556 in http://www.exampledepot.com/egs/java.applet/pkg.html for examples. Note that this technique only plays a few file formats, like ".au" files, which otherwise are not widely used. If you have ".wav" files or or something else, you'll need to convert it to ".au" first.

Or you can use the more involved javax.sound package: http://www.exampledepot.com/egs/javax.sound.sampled/pkg.html
 
Rob Spoor
Sheriff
Pie
Posts: 20368
43
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:Note that this technique only plays a few file formats, like ".au" files, which otherwise are not widely used. If you have ".wav" files or or something else, you'll need to convert it to ".au" first.

AudioClip handles WAVE file just fine, and has been doing so since Java 1.4 and probably even earlier. Still, it is limited to only a small list of formats.

The Java Media Framework (JMF) can handle more file formats, but still not everything. You can supposedly get MP3 support by installing an extension but I never got that working. I did find both JLayer and BasicPlayer that are able to play MP3 files; I found the latter to be quite good from a little experimentation. Never really tried JLayer.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic