• 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
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Audio player

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have made a audio player in java and used on Jframe to play audio.
in my program there is a moving ball, whenever it touches the frame a sound has to be played(this is what i want to do)
What was actually happened ball just pauses before touching the frame and sound plays, after plyind sound ball continues its motion
I want to do them simultaneously.
Please help.
Thank u.
I m attaching code,a .gif and .wav file.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello kshitiz, and welcome to the Ranch!

kshitiz khandelwal wrote:... a moving ball, whenever it touches the frame a sound has to be played(this is what i want to do)
What was actually happened ball just pauses before touching the frame and sound plays, after plyind sound ball continues its motion
I want to do them simultaneously.
Please help.


One can't be sure without seeing your code, but I'd guess that you need to learn about Concurrency in Swing.
 
kshitiz khandelwal
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the help Burke.
I have attached my coding file in my post.
Here i again pasting my code.


 
Master Rancher
Posts: 4222
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to read the link Darryl posted.
You are playing the sound on the EDT (Event Dispatch Thread), which means Swing cannot do anything else until the sound has finished.
 
Darryl Burke
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Like I said, you need to learn about and understand concurrency in Swing. While you're there, also learn how to use a Swing Timer.
 
Darryl Burke
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Dave Tolls wrote:You need to read the link Darryl posted.




Dave Tolls wrote:You are playing the sound on the EDT (Event Dispatch Thread), which means Swing cannot do anything else until the sound has finished.


Actually, no. The animation and sound routine are both on the same Thread, but it isn't the EDT.
 
To avoid criticism do nothing, say nothing, be nothing. -Elbert Hubbard. Please critique this tiny ad:
Enterprise-grade Excel API for Java
https://products.aspose.com/cells/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!