• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Playing sounds files

 
Milton Ochoa
Ranch Hand
Posts: 336
Firefox Browser Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rancher

Please, someone guide me.

I am building a video game, and I trying to play a sound file when the user change a option.

I am using this code



And when the user change the option menu on the GUI, I use:



But, when I try to change another option, and use play() function again, No sound nothing.

Someone can help me with this.

Thankz
 
Rory Evans
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
*** DISCLAIMER ***
I have absolutely no experience of Java FX - but from your description (the file only plays once and then never again) I'd say that when a file has finished playing, its play position doesn't get set back to the beginning of the track.

This would mean that calling play() again would cause nothing to happen since the play position is already at the end of the track.

I had a quick look at the API and noticed that under the stop() function it says 'Stops playing, resets to beginning of media, and resets the play count'.

The play() function says 'Starts or resumes playing'.

I would say that you need to call stop() before calling play() so you can ensure the track will always play from the beginning.
 
Milton Ochoa
Ranch Hand
Posts: 336
Firefox Browser Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rory Evans, Thank you for you answer.

Its true about you say.

But when I try that: (stop() and then play() again), its the same problem, no sound out comming.

I read on another forum this same problem, its seems that the API (JavaFX) have a problem with files with a small length. The Temporal solution that I could find around this issues, was using the audio API that is used in Applets.

For now I will wait, for one better solution.
 
Rob Spoor
Sheriff
Pie
Posts: 20555
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Milton Ochoa wrote:Thankz

Sorry to nitpick but please UseRealWords: "thanks".
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic