Results 1 to 7 of 7
Thread: play a wav file repeatedly
- 11-28-2010, 12:17 AM #1
Member
- Join Date
- May 2010
- Posts
- 23
- Rep Power
- 0
- 11-28-2010, 12:19 AM #2
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,561
- Rep Power
- 11
How are you playing it once? Code please.
- 11-28-2010, 12:23 AM #3
Member
- Join Date
- May 2010
- Posts
- 23
- Rep Power
- 0
Java Code:try { File soundFile1 = new File("C:\\won.wav"); if (!soundFile1.exists()) { System.err.println("Wave file(s) not found!"); return; } AudioInputStream audioIn1 = AudioSystem.getAudioInputStream(soundFile1); // Get a sound clip resource. playing = AudioSystem.getClip(); // Open audio clip and load samples from the audio input stream. playing.open(audioIn3); // Play the file playing.start(); } catch (javax.sound.sampled.LineUnavailableException e) { e.printStackTrace(); return; } catch (Exception e) { e.printStackTrace(); return; }
- 11-28-2010, 12:41 AM #4
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,561
- Rep Power
- 11
Try using the Clip methods setLoopPoints(0,-1) and loop(LOOP_CONTINUOUSLY) on playing.
- 11-28-2010, 01:04 AM #5
Member
- Join Date
- May 2010
- Posts
- 23
- Rep Power
- 0
Could you please elaborate?
- 11-28-2010, 01:06 AM #6
Member
- Join Date
- May 2010
- Posts
- 23
- Rep Power
- 0
As I tried it out, I only need to put the "playing.loop(...)". And that'd solve the problem. Correct?
- 11-28-2010, 01:15 AM #7
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,561
- Rep Power
- 11
I've never used AudioSystem.getClip() so I can't really elaborate. You will know if it solves the problem by replacing playing.start() with the other two methods I posted before. My reading of the API docs is that both are needed. (I've always used the Applet method getAudioClip() and the AudioClip method loop() - whether in an applet or not.)
Similar Threads
-
help to play file.wav in java
By jperson in forum New To JavaReplies: 2Last Post: 03-26-2010, 03:10 AM -
Play wave file out of a jar file
By schliz in forum Advanced JavaReplies: 2Last Post: 12-03-2009, 01:37 PM -
Play avi file in JMF
By ramkumarm in forum AWT / SwingReplies: 0Last Post: 04-15-2009, 01:49 PM -
play vedio file and flash file in swing
By rajasekharreddym in forum AWT / SwingReplies: 1Last Post: 07-30-2008, 08:22 PM -
how can I play an mp3 file in java?
By iliana in forum NetworkingReplies: 1Last Post: 05-30-2008, 07:32 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks