This week's book giveaway is in the Design and Architecture forum.
We're giving away four copies of Communication Patterns: A Guide for Developers and Architects and have Jacqui Read on-line!
See this thread for details.
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Beep Sound continuously for 1 min??

 
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Can any one plz tell me How Can I create Beep sound for 1min continuously.Now I can create Beep sound only once by below code.Eagerly waiting for someone reply.
Toolkit.getDefaultToolkit().beep();
Regards
Bikash
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can write a loop, in the loop you can invoke the
for(int i = 0 ; i < 600; i++){
Toolkit.getDefaultToolkit().beep();
try{
Thread.sleep(100);
}catch(Exception e){
}
}
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"smartHawk" -

Welcome to the JavaRanch! Please adjust your displayed name to meet the
JavaRanch Naming Policy.
You can change it here.

Thanks! and welcome to the JavaRanch!

Bikash,

I would use a separate Thread instead of a loop to sound the bell...

 
Author
Posts: 6055
8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's a another key question when doing this. Is there any way to get Java to turn the audio on in windows and turn up the volume? In my application, we want to make sure the user hears us when we trash talk him for doing something stupid. (Otherwise the user may simply hace the sound off, and not hear it.)
--Marek
 
Bikash Paul
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Thanks for all of ur's help.
Thanks & Regards
Bikash
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mark, we're talking about the system speaker here... that's what the beep() method sounds. I don't think that you can turn off the system speaker through the control panel. If you want to use real sounds (.WAV sound files or other types), you'll have to use JMF (Java Media Framework), which also gives you a lot more control of playback, and supports most video and sound formats. There isn't a built-in way of turning up the system sound (as far as I know), you'd have to do some kind of JNI to get Windows to control the system sound. But this really seems like overkill... if the user turns sounds off at the system level, that probably means they want sounds off... I'd be pretty mad if I turned sound off and then some stupid program that thought it knew better than me turns sound back on to sound an error message. For example, you could be breaking into a high security facility and using your PDA to hack into the security systems to disable it. You have sounds turned off because you are perched inside an air duct above the guard station. Whoops! You accidently mis-typed a command! The program re-enables system sound to beep at you. You're dead...
 
Blueberry pie is best when it is firm and you can hold in your hand. Smell it. And smell this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic