9 Replies - 443 Views - Last Post: 04 March 2013 - 12:20 PM Rate Topic: -----

#1 Scyth3  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 18-November 12

Java playing .wav file problem

Posted 03 March 2013 - 03:28 PM

Its weird, when I am playing my sound, it plays right the first time, but it sound electronic the following times. But it only does it with that sound, my other sound works fine every time. Here is my playing method.

package Sound;

import java.io.InputStream;
import sun.audio.AudioPlayer;

/**
 * @class Player
 * @date Mar 3, 2013 4:22:13 PM
 * @author
 */
public class Player {
    
    static InputStream in;

    public static void run(String sound) {

            in = new Player().getClass().getClassLoader().getResourceAsStream(sound);
            AudioPlayer.player.start(in);
    }
}


Does that make sense?

Is This A Good Question/Topic? 0
  • +

Replies To: Java playing .wav file problem

#2 farrell2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 797
  • View blog
  • Posts: 2,422
  • Joined: 29-July 11

Re: Java playing .wav file problem

Posted 03 March 2013 - 04:17 PM

You're using unsupported APIs. Use Audioclip instead.

EDIT: I mean Clip

 AudioInputStream audio = AudioSystem.getAudioInputStream(new File("x.wav"));
            Clip clip = AudioSystem.getClip();
            clip.open(audio);
            clip.start();


This post has been edited by farrell2k: 03 March 2013 - 04:20 PM

Was This Post Helpful? 0
  • +
  • -

#3 Scyth3  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 18-November 12

Re: Java playing .wav file problem

Posted 03 March 2013 - 04:45 PM

View Postfarrell2k, on 03 March 2013 - 04:17 PM, said:

You're using unsupported APIs. Use Audioclip instead.

EDIT: I mean Clip

 AudioInputStream audio = AudioSystem.getAudioInputStream(new File("x.wav"));
            Clip clip = AudioSystem.getClip();
            clip.open(audio);
            clip.start();



Sounds the same?
Was This Post Helpful? 0
  • +
  • -

#4 farrell2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 797
  • View blog
  • Posts: 2,422
  • Joined: 29-July 11

Re: Java playing .wav file problem

Posted 03 March 2013 - 04:47 PM

Post the audio file somewhere. I will try it out. It may be a driver issue, a java issue, or a file issue. Who knows? The process of elimination may determine which.
Was This Post Helpful? 0
  • +
  • -

#5 Scyth3  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 18-November 12

Re: Java playing .wav file problem

Posted 03 March 2013 - 04:57 PM

View Postfarrell2k, on 03 March 2013 - 04:47 PM, said:

Post the audio file somewhere. I will try it out. It may be a driver issue, a java issue, or a file issue. Who knows? The process of elimination may determine which.



http://dl.dropbox.co...761129/Bomb.WAV
Was This Post Helpful? 0
  • +
  • -

#6 farrell2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 797
  • View blog
  • Posts: 2,422
  • Joined: 29-July 11

Re: Java playing .wav file problem

Posted 04 March 2013 - 04:31 AM

Yeah, right. This has to be a Java issue. I can't get ANY .wav to play on my crappy Windows 8 machine. Why do I waste my time with Java? :(
Was This Post Helpful? 0
  • +
  • -

#7 farrell2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 797
  • View blog
  • Posts: 2,422
  • Joined: 29-July 11

Re: Java playing .wav file problem

Posted 04 March 2013 - 05:03 AM

Yep, most likely a Java and or windows driver issue. I can't get Javafx AudioClip or MediaPlayer to play any wavs either. :(

Anyone have any ideas?

This post has been edited by farrell2k: 04 March 2013 - 05:04 AM

Was This Post Helpful? 0
  • +
  • -

#8 codecsmash49  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 61
  • Joined: 09-December 08

Re: Java playing .wav file problem

Posted 04 March 2013 - 07:06 AM

I would suggest using Applets

Applet.newAudioClip(getClass().getResource(File)).play();
Was This Post Helpful? 0
  • +
  • -

#9 farrell2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 797
  • View blog
  • Posts: 2,422
  • Joined: 29-July 11

Re: Java playing .wav file problem

Posted 04 March 2013 - 10:03 AM

FINALLY! My issue was an outdated audio driver. I played your Bomb.wav 5x and everything worked just fine, Scyth3.
Was This Post Helpful? 0
  • +
  • -

#10 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8315
  • View blog
  • Posts: 31,836
  • Joined: 06-March 08

Re: Java playing .wav file problem

Posted 04 March 2013 - 12:20 PM

View Postfarrell2k, on 04 March 2013 - 12:03 PM, said:

FINALLY! My issue was an outdated audio driver. I played your Bomb.wav 5x and everything worked just fine,

Shoemakers' wives go barefoot and doctors' wives die young.

:)/>

This post has been edited by pbl: 04 March 2013 - 12:37 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1