public class

ContinuousAudioDataStream

extends AudioDataStream
java.lang.Object
   ↳ java.io.InputStream
     ↳ java.io.ByteArrayInputStream
       ↳ sun.audio.AudioDataStream
         ↳ sun.audio.ContinuousAudioDataStream

Class Overview

Create a continuous audio stream. This wraps a stream around an AudioData object, the stream is restarted at the beginning everytime the end is reached, thus creating continuous sound.

For example:

   AudioData data = AudioData.getAudioData(url);
   ContinuousAudioDataStream audiostream = new ContinuousAudioDataStream(data);
   AudioPlayer.player.start(audiostream);
 

Summary

[Expand]
Inherited Fields
From class java.io.ByteArrayInputStream
Public Constructors
ContinuousAudioDataStream(AudioData data)
Create a continuous stream of audio.
Public Methods
int read()
Reads the next byte of data from this input stream.
int read(byte[] ab, int i1, int j)
Reads up to len bytes of data into an array of bytes from this input stream.
[Expand]
Inherited Methods
From class java.io.ByteArrayInputStream
From class java.io.InputStream
From class java.lang.Object
From interface java.io.Closeable

Public Constructors

public ContinuousAudioDataStream (AudioData data)

Create a continuous stream of audio.

Public Methods

public int read ()

Reads the next byte of data from this input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned.

This read method cannot block.

Returns
  • the next byte of data, or -1 if the end of the stream has been reached.

public int read (byte[] ab, int i1, int j)

Reads up to len bytes of data into an array of bytes from this input stream. If pos equals count, then -1 is returned to indicate end of file. Otherwise, the number k of bytes read is equal to the smaller of len and count-pos. If k is positive, then bytes buf[pos] through buf[pos+k-1] are copied into b[off] through b[off+k-1] in the manner performed by System.arraycopy. The value k is added into pos and k is returned.

This read method cannot block.

Parameters
ab the buffer into which the data is read.
i1 the start offset in the destination array b
j the maximum number of bytes read.
Returns
  • the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.