Sound in sun.audio.*;

Discussion in 'Java' started by Pak_indo, Oct 10, 2004.

  1. Pak_indo

    Pak_indo Guest

    Hi folks,

    ok, I have 5 or so files which need to be played one after another, pretty
    much immediately after another such that it sounds like theyre kinda linked
    so to speak(I cant make one big file as the order they come in differs on
    runtime)
    What i would like to know is, is this possible with this package? The
    current code I am using to play is
    try{
    InputStream in = new FileInputStream(fileName);
    // Create an AudioStream object from the input stream.
    AudioStream as = new AudioStream(in);
    // Use the static class member "player" from class AudioPlayer to play
    // clip.
    AudioPlayer.player.start(as);
    // Similarly, to stop the audio.
    //AudioPlayer.player.stop(as);
    }
    catch(Exception e){System.out.println(e);}

    and would like to know how I can manipulate this to play them one after
    another, ie is there a specific method which would help me etc.

    Thanks for any time which anyone could give me

    cheers

    pak
    Pak_indo, Oct 10, 2004
    #1
    1. Advertising

  2. Pak_indo wrote:
    > Hi folks,
    >
    > ok, I have 5 or so files which need to be played one after another, pretty
    > much immediately after another such that it sounds like theyre kinda linked
    > so to speak(I cant make one big file as the order they come in differs on
    > runtime)
    > What i would like to know is, is this possible with this package? The
    > current code I am using to play is
    > try{
    > InputStream in = new FileInputStream(fileName);
    > // Create an AudioStream object from the input stream.
    > AudioStream as = new AudioStream(in);
    > // Use the static class member "player" from class AudioPlayer to play
    > // clip.
    > AudioPlayer.player.start(as);
    > // Similarly, to stop the audio.
    > //AudioPlayer.player.stop(as);
    > }
    > catch(Exception e){System.out.println(e);}
    >
    > and would like to know how I can manipulate this to play them one after
    > another, ie is there a specific method which would help me etc.
    >
    > Thanks for any time which anyone could give me
    >
    > cheers
    >
    > pak
    >
    >


    You can use JavaSound to play your files. I would use a LineListener to
    check for the end of the audio stream and then open the next stream. If
    the files are not too long you could also use the Clip interface to load
    the entire file and play them in any order.

    --

    Knute Johnson
    email s/nospam/knute/
    Knute Johnson, Oct 10, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Luc The Perverse

    Sound Quality In Sound API

    Luc The Perverse, Oct 30, 2005, in forum: Java
    Replies:
    4
    Views:
    1,474
    Andrew Thompson
    Oct 31, 2005
  2. Replies:
    0
    Views:
    496
  3. Replies:
    0
    Views:
    2,855
  4. aeonsun
    Replies:
    2
    Views:
    417
    Luc The Perverse
    Mar 11, 2007
  5. News123
    Replies:
    1
    Views:
    940
    Tim Harig
    Sep 11, 2010
Loading...

Share This Page