• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Playing sounds files

 
Ranch Hand
Posts: 336
Firefox Browser Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 22787
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

Milton Ochoa wrote:Thankz


Sorry to nitpick but please UseRealWords: "thanks".
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic