This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Abstract Window Toolkit Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Abstract Window Toolkit" Watch "Abstract Window Toolkit" New topic
Author

Abstract Window Toolkit

LaTeef Lusk
Greenhorn

Joined: Mar 28, 2009
Posts: 15
Is there a class that is available in the awt that will allow you to play music in a program or applet?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41124
    
  45
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


Ping & DNS - my free Android networking tools app
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19654
    
  18

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Abstract Window Toolkit