1

I have an audio player, I have found how to add a single file to the audio inputstream, but I have an arraylist of files I want to add. How should I do that?

public class AudioPlayer {
    Long currentFrame;
    Clip clip;

    // current status of clip
    String status;

    AudioInputStream musicInputStream;


    // constructor to initialize streams and clip
    public AudioPlayer(Schedule schedule,List<File> files)
            throws UnsupportedAudioFileException,
            IOException, LineUnavailableException
    {
        // create AudioInputStream object

        musicInputStream =
                AudioSystem.getAudioInputStream(files.get(0).getAbsoluteFile());

        // create clip reference
        clip = AudioSystem.getClip();

        // open audioInputStream to the clip
        clip.open(musicInputStream);

        clip.loop(Clip.LOOP_CONTINUOUSLY);
    }
}
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Daniel Haughton
  • 1,085
  • 5
  • 20
  • 45

1 Answers1

0

I'm sure this answer comes too late to be helpful to you, but I am searching for the answer to a similar question. The solution provided here suggests that you could create a loop to join two AudioInputStream objects together until you have a single final AudioInputStream: Join two WAV files from Java?

Derek
  • 126
  • 1
  • 7