mediaframe.mpeg1.audio.player
Interface AudioDevice

All Known Implementing Classes:
EightBitAudioDevice, JavaSoundAudioDevice

public interface AudioDevice

The AudioDevice interface provides an abstraction for a device capable of sounding audio samples. Samples are written to the device via the write() method. The device assumes that these samples are signed 16-bit samples taken at the output frequency of the decoder. If the decoder outputs more than one channel, the samples for each channel are assumed to appear consecutively, with the lower numbered channels preceeding higher-numbered channels. E.g. if there are two channels, the samples will appear in this order:


 
		l0, r0, l1, r1, l2, r2...
 
 where
lx indicates the xth sample on channel 0 rx indicates the xth sample on channel 1

Since:
0.0.8
Author:
Mat McGowan

Method Summary
 void close()
          Closes this audio device.
 void endOfFile()
          Is called if the end of file has been reached.
 void flush()
          Blocks until all audio samples previously written to this audio device have been heard.
 boolean isEightBitEightKhzMuLaw()
          Returns true, if the audio device is a crappy eight-bit eight khz ulaw decoder (browser).
 void open(mediaframe.mpeg1.audio.decoder.Decoder decoder)
          Prepares the AudioDevice for playback of audio samples.
 void pause()
          Pause the Player.
 void play()
          Start player playing.
 void setMute(boolean mute)
          Set the mute state of the audio playback.
 void setVolume(float volume)
          Sets the volume (in the range 0..1) of the audio playback.
 void stop()
          Stop player playing.
 void write(short[] samples, int offs, int len)
          Writes audio data to this audio device.
 

Method Detail

open

public void open(mediaframe.mpeg1.audio.decoder.Decoder decoder)
          throws mediaframe.mpeg1.audio.decoder.JavaLayerException
Prepares the AudioDevice for playback of audio samples.

If the audio device is already open, this method returns silently.

Parameters:
decoder - the decoder that will be providing the audio samples.
mediaframe.mpeg1.audio.decoder.JavaLayerException

write

public void write(short[] samples,
                  int offs,
                  int len)
           throws mediaframe.mpeg1.audio.decoder.JavaLayerException
Writes audio data to this audio device. Audio data is assumed to be in the output format of the decoder. This method may return before the data has actually been sounded by the device if the device buffers audio samples.

This method may return prior to the samples actually being played by the audio device.

Parameters:
samples - the array of signed 16-bit samples to write to the audio device.
offs - the offset of the first sample.
len - the number of samples to write.
mediaframe.mpeg1.audio.decoder.JavaLayerException

close

public void close()
Closes this audio device. Any currently playing audio is stopped as soon as possible. Any previously written audio data that has not been heard is discarded.

The implementation should ensure that any threads currently blocking on the device (e.g. during a write or flush operation should be unblocked by this method.


flush

public void flush()
Blocks until all audio samples previously written to this audio device have been heard.


play

public void play()
Start player playing.


stop

public void stop()
Stop player playing.


isEightBitEightKhzMuLaw

public boolean isEightBitEightKhzMuLaw()
Returns true, if the audio device is a crappy eight-bit eight khz ulaw decoder (browser).


setVolume

public void setVolume(float volume)
Sets the volume (in the range 0..1) of the audio playback.

Parameters:
volume - the volume to set.

setMute

public void setMute(boolean mute)
Set the mute state of the audio playback.

Parameters:
mute - the mute state (true if the mute on and the player doesn't play the audio).

pause

public void pause()
Pause the Player.


endOfFile

public void endOfFile()
Is called if the end of file has been reached.