Help coderanch get a
new server
by contributing to the fundraiser
  • 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

Quit audio before application exits.

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my application, I have audio running thrughout the whole time the application is open.

However, whenever I exit the application, my computer makes a noise that makes me think that something went wrong. I dont really know how to explain it other than it is just one tone and it does not sound like the audio that I had playing.

Is there a way to make this sound not occur? Should I stop the audio from playing before the application exits?
 
Sheriff
Posts: 22796
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How are you playing the audio?
 
Braden Steffaniak
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Rob Spoor
Sheriff
Posts: 22796
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know how your application is exited, but unless you call System.exit, the sound playing threads will continue until they end. I'd definitely stop them. Also, you should make the playing variable volatile, as it's clearly meant to be shared among multiple threads.

I don't see any GUI related code here, so I'll move this thread to Java in General.
 
Braden Steffaniak
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I use system.exit(0) to exit the program when the x button is pressed. (and I changed playing to volatile) But it still makes the sound.
 
Braden Steffaniak
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have now added this line to my code, and it runs right before the program exits.

However, it makes a very... very loud annoying sound that scares the crap out of me. And even after the program has exited, it will repeat the sound a few times after when you try to play any audio.

Heres the code:



It is in the Sound.class as seen in the code in my second post.
 
Braden Steffaniak
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now I have edited that code to this:



It does not have a sharp sound anymore, but it still makes the noise that I started out with. Just for a shorter time period.

How could I stop the noise from occurring completely?
 
Saloon Keeper
Posts: 10872
87
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How about:

 
Braden Steffaniak
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That loop just controls whether to loop or not. The nested loops are the ones that play the audio.
 
Carey Brown
Saloon Keeper
Posts: 10872
87
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, but each time through the loop you call line.start() and line.close().
reply
    Bookmark Topic Watch Topic
  • New Topic