This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Five Lines of Code and have Christian Clausen on-line!
See this thread for details.
Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Playing a sound in a stand alone Java program

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to play an audioclip in a standalone java program. I have tried extending applet but ultimately ran into security problems. I can get sound using AudioClip by extending applet, but i have searched in vain to be able to do this as a stand-alone. I have tried many things with AudioClip and i'm giving up hope. Is there any way to do this? Any other classes so i don't have to worry about he nitty gritty details of reading a .wav file . . . Also, do you know of any mp3 processing classes around, so that i may use mp3's instead of wav's? Thank you so much for looking at this.
*matt*
 
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, first, you don't need to extend Applet, or even instantiate it to play a sound.
Just use the static methods Applet.newAudioClip() to get an AudioClip, then the static AudioClip.play() to play it.
A more robust way is to use a media package. I've use Quicktime for Java before for this - it runs on Windows machines as well as Apple's, and it's free from Apple Computer. It's a really good library, but you'll have to get into more detail to take advantage of it.
Another library is the all-java Java Media Framework (JMF) which is supposed to provide these kinds of services, although I have not played with this yet.
Good luck!
 
Matt Carr
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That worked perfectly, thank you so much!!!
 
I'm not sure if I approve of this interruption. But this tiny ad checks out:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic