This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Sound problem in Java  RSS feed

 
Klaas Vredevort
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys!

Anyone have any idea why this program isnt running?

Thanks

Klaas

 
Campbell Ritchie
Marshal
Posts: 55694
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But it does run. I have just tried it.
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\user>a:

A:\>javac G.java

A:\>java G
Exception in thread "main" java.io.FileNotFoundException: Confused.au (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at G.main(G.java:12)

A:\>
Only it would have been better if I had the Confused.au file
 
Klaas Vredevort
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont understand. The program does compile, but no sound. Try any .au file on your side please... listen if you can hear it\

Thank you so much

Klaas
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you stop it (almost) at the same time you start it

AudioPlayer.player.start (as);
// Similarly, to stop the audio.
AudioPlayer.player.stop (as);

try adding a thread sleep, see if the sound plays now
AudioPlayer.player.start (as);
// Similarly, to stop the audio.
try{Thread.sleep(2000);}catch(Exception e){}//<-------
AudioPlayer.player.stop (as);
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!