How to play a wav file to LINE_OUT with javax.sound.sampled

Hello all,
I need to play a wav file to LINE_OUT port, but not to the SPEAKER. I am trying to do this under window NT. For some reason I get false for isLineSupported(Port.Info.LINE_OUT). I am new to javax.sound so I might be doing something wrong. Here is the code that I am using to iterate through all availible mixers and check if LINE_OUT is supported by any of them:
Mixer.Info[] mixers = AudioSystem.getMixerInfo();
for(int i = 0; i < mixers.length; i++){
Mixer mixer = AudioSystem.getMixer(mixers);
if (mixer.isLineSupported(Port.Info.LINE_OUT)) {
System.out.println("the port is supported");
try {
Port line = (Port) AudioSystem.getLine(
Port.Info.LINE_OUT);
catch(Exception ex){
ex.printStackTrace();
else{
System.out.println("the port is not supported");
Please help

The new bugID of the request to implement Ports is: 4558938.
(If you voted for the old bug id: 4504642, be sure to change your votes to this new bug report since the old one was closed as a duplicate of the new one.)

Similar Messages

  • How to play a wave file through the DAQ board?

    Hi there,
    we want to play a wave file that is saved on the harddrive via the DAQ board. Means we want to connect a amp to the analog output of the DAQ to amplify the sound and play it through a speaker.
    We couldn't find any VI that does that. Can anybody tell us how to play a wave file, or perhaps even send us a VI that can do that?
    Thanks a lot for your help
    Martin - Physical Optics Corporation

    Hi Martin,
    The only example that I could find on how to do this was using our
    older Traditional DAQ drivers version 6.9.3.  If you're using Traditional
    DAQ drivers, the vi can be found here. 
    The example reads a 8-bit mono .wav file (an example .wav file is included in the .zip file) and writes it to the analog out of your DAQ card.  I've updated the
    example to work with our newer DAQmx drivers and attached it here.  
    I hope this helps,
    Paul C.
    Message Edited by Paul C. on 08-14-2007 05:47 PM
    Attachments:
    daqmx_wav_file_to_ao_output.zip ‏27 KB

  • How to play DTS wav files on hd from sounblasterplay

    Hello,
    I've got many wav files on my harddisk. They are dts wav files.
    On cd-rom they play with software player soundblaster, no problem.
    But when i play them by harddisk there is no dts sound.
    What must i do to play them?
    greetings

    forgotten to say it is a X-fi music card
    thanks

  • Why, when I bounce to iTunes, do my wave files show up with no sound?

    When I bounce wave files to iTunes the file has a time and the title shows up, but no sound when you double click on it. The time bar moves like its playing but no sound!!

    If you bounce as AAC or MP3, you will lose some quality. Better to bounce in AIF or WAV if you intend to burn to CD. Now, why you can't play it in iTunes or from finder, that is weird. Like someone suggested, try AIF format. That is all I use and I can play anywhere. When you go to "Get Info" in iTunes (for the song), does it have a time? You can also try opening the file (from your Bounced folder) into Audacity? It's a free app and very nice. You will be able to see the sound wave. This will verify that you actually have sound in the file.
    Let us know what you find.

  • How do you open/play a .wav file (music file) without play sound file .vi

    I am having big problems to create a music background for my project. I am newbie using labview and maybe my questions is not so dificult to solve (I hope so)
    I was using play sound file vi but the problem is that I dont want the music file start automatically. I wanna control the start time using a button. I tried include a sound output stop but when the app start and I add more wav files in my vi, the sound file start, then stop abruptally because the stop vi and the everything is normal. I would like to eliminate that error.
    Someone have any idea, maybe using open file or another way. 
    Thanks in advance
    I add a screenshot of my vi and also the vi in this post
    Attachments:
    test sound.vi ‏11 KB

    I leave an example that can provide, use it in your program
    Atom
    Certified LabVIEW Associate Developer
    Attachments:
    playsound.zip ‏58 KB

  • How do I play the .wav file google mail sends me on my Iphone 5?

    I have cable phone service that sends out a .wav file of any voicemails I recieve to my e-mail account.  I use google mail on my Iphone, and cannot play the .wav file that is attached to that e-mail.  When I click on the "audio message box", it brings up a circle containing a south-west facing arrow which has a slash through it. 

    I have the latest software (6.1.4) and I can play the attachment if I go through "Mail" instead of "GMail".  I am still not certain why I have a widget called "Mail". 
    Inside the "Mail" app, there are it's own Inbox, VIP, Flagged, etc which are all in color.  Further down the list is my GMail boxes and sub-boxes.  They are all grayed out, but still funtional.
    Do I have something set up wrong causing me to be unable to play the .wav files that come to me through gmail?

  • How to play an audio file through a button?

    I have a form in which I have a button (Command object). When the user clicks on this command button it is supposed to play a wav file. The wav is residing in my hard disk at "C:\tada.wav"
    I have tried to include the following code in the commandAction() method, which technically is the right way of performing this operation:
    But I get a warning when I compile saying that this operation should be performed in a seperate thread as opposed to commandAction().
    if(c == cmdPlay)
    try     
    String wav = "file:///c:/tada.wav";
    Player p = Manager.createPlayer(wav);
    p.start();
    catch (IOException x)
    x.printStackTrace();
    } catch (MediaException x) {
    x.printStackTrace();
    Can anyone please tell me how to implement this solution properly or just suggest a new way of creating a "play" button in my form? Urgent HELP NEEDED PLEASE!
    THANKS.

    Hi Ibrahim,
    Rob has pointed you to the Lingo for playing a sound. There is a behavior in the Library Palette that makes this very easy without needing to write a script yourself. In the Media > Sound category, there is a 'Play Sound' behavior. You can click and drag this behavior onto a sprite and then in the Parameters dialog, you can choose the sound to play, the channel in which it should play, the event to activate the sound, and if you want the sound to loop.
    Dean
    Director Lecturer / Consultant / Director Enthusiast
    http://www.deansdirectortutorials.com/
    http://www.multimediacreative.com.au

  • Subsequent play of WAV files from HTTP

    Hi,
    I have to subsequently play many WAV files from HTTP in a nokia series 60 emulator.
    Everything is ok for the first two files, but at the third I catch an exception:
    "java.io.IOException: exceeded the configured maximum number of connections"
    I tried two ways to load the files from HTTP:
    Manager.CreatePlayer(InputStream...)
    Manager.CreatePlayer("http:\\...")
    Below there is the code of the two methods I use. Please note that I try in every way to close the connection before open a new one!!!
    public void Method_1(String src, String type){
    int iLen=0;
    is = null;
    httpCon = null;
    byte[] bBuf;
    try {
    if (p != null) {
    if (p.getState() == Player.STARTED) {
    p.stop();
    p.removePlayerListener(this);
    p.deallocate();
    p.close();
    p=null;
    if (is!=null){
    is.close();
    is=null;
    if (httpCon!=null){
    httpCon.close();
    httpCon=null;
    httpCon = (HttpConnection) Connector.open(src);
    if (httpCon.getResponseCode() != HttpConnection.HTTP_OK) {
    System.out.println("Bad response code");
    return;
    System.out.println("Connection OK! (audio)");
    iLen = (int) httpCon.getLength();
    System.out.println("audio file length : " + iLen);
    is = httpCon.openInputStream();
    p = Manager.createPlayer(is, type);
    p.addPlayerListener(this);
    p.setLoopCount(1);
    p.prefetch();
    p.start();
    vc = (VolumeControl)p.getControl("VolumeControl");
    catch (MediaException ex) {
    ex.printStackTrace();
    catch (IOException ex) {
    ex.printStackTrace();
    public void Method_2(String src){
    try {
    if (p!=null){
    if (p.getState() == Player.STARTED)
    p.stop();
    p.deallocate();
    p.close();
    p=null;
    p = Manager.createPlayer(src);
    p.addPlayerListener(this);
    p.setLoopCount(1);
    p.start();
    vc = (VolumeControl)p.getControl("VolumeControl");
    catch (java.io.IOException e) {
    e.printStackTrace();
    catch (MediaException e) {
    e.printStackTrace();

    My question is:
    how can I load (from a HTTP server) and play more than two WAV files without crashing?
    Do I have to close the connection in a better way in order to re-open it without problems (and more than two times)?
    It is simply an emulator bug?
    Thanks.

  • Play a wav file once

    how do I play a wav file just once using the play sound
    file.vi. i keep getting it to repeat over and over
    thanks

    First may I recommend some reading here. This is not meant to be cocky just to help you.  
    Getting Started with NI LabVIEW Student Training
    LabVIEW101
    Second I have included sort of template. Notice the wire that ends in the while loop. This will ensure that the wav is played before the loop starts.
    Good luck with your Labview labwork
    Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
    (Sorry no Labview "brag list" so far)
    Attachments:
    play wav file[2].vi ‏9 KB

  • Playing a wav file (byte array) using JMF

    Hi,
    I want to play a wav file in form of a byte array using JMF. I have 2 classes, MyDataSource and MyPullBufferStream. MyDataSource class is inherited from PullStreamDataSource, and MyPullBufferStream is derived from PullBufferStream. When I run the following piece of code, I got an error saying "EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x7c9108b2, pid=3800, tid=1111". Any idea what might be the problem? Thanks.
    File file = new File(filename);
    byte[] data = FileUtils.readFileToByteArray(file);
    MyDataSource ds = new MyDataSource(data);
    ds.connect();
    try
        player = Manager.createPlayer(ds);
    catch (NoPlayerException e)
        e.printStackTrace();
    if (player != null)
         this.filename = filename;
         JMFrame jmframe = new JMFrame(player, filename);
        desktop.add(jmframe);
    import java.io.IOException;
    import javax.media.Time;
    import javax.media.protocol.PullBufferDataSource;
    import javax.media.protocol.PullBufferStream;
    public class MyDataSource extends PullBufferDataSource
        protected Object[] controls = new Object[0];
        protected boolean started = false;
        protected String contentType = "raw";
        protected boolean connected = false;
        protected Time duration = DURATION_UNKNOWN;
        protected PullBufferStream[] streams = null;
        protected PullBufferStream stream = null;
        protected final byte[] data;
        public MyDataSource(final byte[] data)
            this.data = data;
        public String getContentType()
            if (!connected)
                System.err.println("Error: DataSource not connected");
                return null;
            return contentType;
        public void connect() throws IOException
            if (connected)
                return;
            stream = new MyPullBufferStream(data);
            streams = new MyPullBufferStream[1];
            streams[0] = this.stream;
            connected = true;
        public void disconnect()
            try
                if (started)
                    stop();
            catch (IOException e)
            connected = false;
        public void start() throws IOException
            // we need to throw error if connect() has not been called
            if (!connected)
                throw new java.lang.Error(
                        "DataSource must be connected before it can be started");
            if (started)
                return;
            started = true;
        public void stop() throws IOException
            if (!connected || !started)
                return;
            started = false;
        public Object[] getControls()
            return controls;
        public Object getControl(String controlType)
            try
                Class cls = Class.forName(controlType);
                Object cs[] = getControls();
                for (int i = 0; i < cs.length; i++)
                    if (cls.isInstance(cs))
    return cs[i];
    return null;
    catch (Exception e)
    // no such controlType or such control
    return null;
    public Time getDuration()
    return duration;
    public PullBufferStream[] getStreams()
    if (streams == null)
    streams = new MyPullBufferStream[1];
    stream = streams[0] = new MyPullBufferStream(data);
    return streams;
    import java.io.ByteArrayInputStream;
    import java.io.IOException;
    import javax.media.Buffer;
    import javax.media.Control;
    import javax.media.Format;
    import javax.media.format.AudioFormat;
    import javax.media.protocol.ContentDescriptor;
    import javax.media.protocol.PullBufferStream;
    public class MyPullBufferStream implements PullBufferStream
    private static final int BLOCK_SIZE = 500;
    protected final ContentDescriptor cd = new ContentDescriptor(ContentDescriptor.RAW);
    protected AudioFormat audioFormat = new AudioFormat(AudioFormat.GSM_MS, 8000.0, 8, 1,
    Format.NOT_SPECIFIED, AudioFormat.SIGNED, 8, Format.NOT_SPECIFIED,
    Format.byteArray);
    private int seqNo = 0;
    private final byte[] data;
    private final ByteArrayInputStream bais;
    protected Control[] controls = new Control[0];
    public MyPullBufferStream(final byte[] data)
    this.data = data;
    bais = new ByteArrayInputStream(data);
    public Format getFormat()
    return audioFormat;
    public void read(Buffer buffer) throws IOException
    synchronized (this)
    Object outdata = buffer.getData();
    if (outdata == null || !(outdata.getClass() == Format.byteArray)
    || ((byte[]) outdata).length < BLOCK_SIZE)
    outdata = new byte[BLOCK_SIZE];
    buffer.setData(outdata);
    byte[] data = (byte[])buffer.getData();
    int bytes = bais.read(data);
    buffer.setData(data);
    buffer.setFormat(audioFormat);
    buffer.setTimeStamp(System.currentTimeMillis());
    buffer.setSequenceNumber(seqNo);
    buffer.setLength(BLOCK_SIZE);
    buffer.setFlags(0);
    buffer.setHeader(null);
    seqNo++;
    public boolean willReadBlock()
    return bais.available() > 0;
    public boolean endOfStream()
    return willReadBlock();
    public ContentDescriptor getContentDescriptor()
    return cd;
    public long getContentLength()
    return (long)data.length;
    public Object getControl(String controlType)
    try
    Class cls = Class.forName(controlType);
    Object cs[] = getControls();
    for (int i = 0; i < cs.length; i++)
    if (cls.isInstance(cs[i]))
    return cs[i];
    return null;
    catch (Exception e)
    // no such controlType or such control
    return null;
    public Object[] getControls()
    return controls;

    Here's some additional information. After making the following changes to MyPullBufferStream class, I can play a wav file with gsm-ms encoding with one issue: the wav file is played many times faster.
    protected AudioFormat audioFormat = new AudioFormat(AudioFormat.GSM, 8000.0, 8, 1,
                Format.NOT_SPECIFIED, AudioFormat.SIGNED, 8, Format.NOT_SPECIFIED,
                Format.byteArray);
    // put the entire byte array into the buffer in one shot instead of
    // giving a portion of it multiple times
    public void read(Buffer buffer) throws IOException
            synchronized (this)
                Object outdata = buffer.getData();
                if (outdata == null || !(outdata.getClass() == Format.byteArray)
                        || ((byte[]) outdata).length < BLOCK_SIZE)
                    outdata = new byte[BLOCK_SIZE];
                    buffer.setData(outdata);
                buffer.setLength(this.data.length);
                buffer.setOffset(0);
                buffer.setFormat(audioFormat);
                buffer.setData(this.data);
                seqNo++;
        }

  • Playing a .wav file from email attachment

    I am trying to play a .wav file that is attached to an email, and i get "The document conversion failed". Am I missing something? What do I need to do to be able to play .wav files that are sent to me via email?

    I have the same request.
    We have a new Panasonic phone system that sends out .wav voicemail files.
    Our company's Curve's play the wav fine.
    Our company's BOLDs ... DO NOT.

  • How to play a FLV file located in a second FMS?

    How to play a FLV file located in a second FMS not directly accessible by the flash client?
    - I am publishing an audio stream from the flash client to a FMS;
    - This FMS then publishes the stream to a second FMS, which records the stream to a FLV;
    How can I play in the client the FLV audio file that I recorded in the second FMS?
    - The first FMS is accessible by the flash client, but the second FMS is only accessible by the first FMS.
    thanks in advance
    fabio

    Answer in http://www.flashcomguru.com/forum/forum_posts.asp?TID=4276&PN=1&TPN=1

  • Why cant I play embeded wave files in firefox but I can in explorer?

    I just embedded a wave file (Godsmack Voodoo) for my website & saved it but when I goto run teh intro no sound, But explorer plays it no problems? What is wrong with Firefox 9.01 & playing the embedded sounds?

    Can you post a link to a public page?
    Which code are you using to play that WAV file?

  • Playing a WAVE file after making a phone call.

    Hi everyone..
    I'm trying to play a wav file after making a phone call. I was able to make the call. But I get an exception when i try to paly a wav file..
    Can any one tell me where I've gone wrong..
    This is the code which plays the audio file..(I downloaded it by the way.. and it's working fine when used as a seperate program)
    import java.io.File;
    import java.io.IOException;
    import javax.sound.sampled.AudioFormat;
    import javax.sound.sampled.AudioInputStream;
    import javax.sound.sampled.AudioSystem;
    import javax.sound.sampled.DataLine;
    import javax.sound.sampled.FloatControl;
    import javax.sound.sampled.LineUnavailableException;
    import javax.sound.sampled.SourceDataLine;
    import javax.sound.sampled.UnsupportedAudioFileException;
    public class PlayWave extends Thread {
         private String filename;
         private Position curPosition;
    //30000000(7324.21 kb)
         private final int EXTERNAL_BUFFER_SIZE = 524288; // 128Kb
         enum Position {
              LEFT, RIGHT, NORMAL
         public PlayWave(String wavfile) {
              filename = wavfile;
              curPosition = Position.NORMAL;
         public PlayWave(String wavfile, Position p) {
              filename = wavfile;
              curPosition = p;
         public void run() {
              File soundFile = new File(filename);
              if (!soundFile.exists()) {
                   System.err.println("Wave file not found: " + filename);
                   return;
              AudioInputStream audioInputStream = null;
              try {
                   audioInputStream = AudioSystem.getAudioInputStream(soundFile);
              } catch (UnsupportedAudioFileException e1) {
                   e1.printStackTrace();
                   return;
              } catch (IOException e1) {
                   e1.printStackTrace();
                   return;
              AudioFormat format = audioInputStream.getFormat();
              SourceDataLine auline = null;
              DataLine.Info info = new DataLine.Info(SourceDataLine.class, format);
              try {
                   auline = (SourceDataLine) AudioSystem.getLine(info);
                   auline.open(format);
              } catch (LineUnavailableException e) {
                   e.printStackTrace();
                   return;
              } catch (Exception e) {
                   e.printStackTrace();
                   return;
              if (auline.isControlSupported(FloatControl.Type.PAN)) {
         FloatControl pan = (FloatControl) auline.getControl(FloatControl.Type.PAN);
                   if (curPosition == Position.RIGHT)
                        pan.setValue(1.0f);
                   else if (curPosition == Position.LEFT)
                        pan.setValue(-1.0f);
              auline.start();
              int nBytesRead = 0;
              byte[] abData = new byte[EXTERNAL_BUFFER_SIZE];
              try {
                   while (nBytesRead != -1) {
              nBytesRead = audioInputStream.read(abData, 0, abData.length);
              if (nBytesRead >= 0)
                   auline.write(abData, 0, nBytesRead);
              } catch (IOException e) {
                   e.printStackTrace();
                   return;
              } finally {
                   auline.drain();
                   auline.close();
         }I inserted
    new PlayWave("greeting.wav").start();In to a method an called this method in the program where i send commands to the modem.
    These are my modem commands
    send("ATZ");
        expect("OK");
    //Enable voice mode
        send("AT+FCLASS=8");
        expect("OK");
    //Dial the number
        send("ATDT"+number);
        expect("OK");
    //Choose encoding method //This is the default
        send("AT+VSM=140,8000,0,0");
        expect("OK");
    // start sending audio data
        send("AT+VTX");
        expect("OK");
    PlayAudio();
    send("ATH");The size of my audio file is 100 kb.I'm using a 56 K intel externel voice modem connected to a serial port.I wonder if it's because the buffer is too big. If anyone tried this and succeded please correct me.
    Thankyou in advance
    goodnews

    Hi goodnews!
    Did I understand well? Can You record the speech? This is what I want!
    Can you help me and send me sample code?
    This would be a big help for me!
    Thank You!
    rflair

  • Play a .wav file fractional

    hi,
    i´m looking for a solution to play a .wav file.
    the special what i need is, that i want to jump to concrete points on the timeline.
    or can i seperate the timeline of a .wav file?
    martin

    Hi Martin
    this could help you starting. For the case you can't open LV 8.2- VIs, i attach the BD- picture.
    greets, Dave
    Message Edited by daveTW on 06-14-2007 10:26 AM
    Greets, Dave
    Attachments:
    play sound part_FP.png ‏10 KB
    play sound part.vi ‏50 KB

Maybe you are looking for

  • Unexplainable MEMORY FULL error in 8.2

    Alright, I finally got my client to take a look at LV 8.2 (we've been on LV 7.0 for 3 years). So I have it running in Evaluation mode (we haven't purchased it yet). I'm running in WinXP Pro/SP2 under Virtual PC 7.0 on a 2x2GHz G5 Power Mac. The progr

  • How to Create Business Partner with  fix number in t-code :BP

    Dear SIr, Normally I will set number range for auto  to create Business Partner. In case , If we would like to crea How to Create Business Partner with  fix number in t-code :BP , howe to do? Please kindly advise. THnak you and best regards, Vimol

  • RoboHelp 8  - All files are not transferring over

    When I upgrade a file to RoboHelp 8, the file does transfer over; however, the contents within that file does not come with it.  RoboHelp will show the Icon with the name of the file.  So, there is no table of contents. Is there a remedy to this?  Ho

  • JCA is not working in OSB 11gR1

    Hi all, I am in the process of evaluating Oracle OSB 11gR1 (11.1.5.0). I am using WLS 11gR1 (10.3.5). I don't see the JCA option in the transport protocols drop-down for proxy service or business service. I also created a database adapter using jdev

  • OBIEE Answers functionality questions

    Hi, I pretty new to OBIEE Answers orginally working with Business Objects XI Webi, I have read through the user guides for Answers but some functionality I would like thats in BO XI but doesnt seem to be avaliable in Answers, Im not sure if its not d