Methods Summary |
---|
public void | addLineListener(javax.sound.sampled.LineListener listener)
throw new UnsupportedOperationException();
|
public int | available()
throw new UnsupportedOperationException();
|
public void | close()
if (isOpen()) {
stop();
player = null;
}
|
public void | drain()
|
public void | flush()
|
public int | getBufferSize()
throw new UnsupportedOperationException();
|
public javax.sound.sampled.Control | getControl(javax.sound.sampled.Control.Type control)
throw new IllegalArgumentException("No controls available");
|
public javax.sound.sampled.Control[] | getControls()
return new Control[0];
|
public javax.sound.sampled.AudioFormat | getFormat()
throw new UnsupportedOperationException();
|
public int | getFrameLength()
throw new UnsupportedOperationException();
|
public int | getFramePosition()
throw new UnsupportedOperationException();
|
public float | getLevel()
throw new UnsupportedOperationException();
|
public javax.sound.sampled.Line$Info | getLineInfo()
return new Line.Info(this.getClass());
|
public long | getLongFramePosition()
throw new UnsupportedOperationException();
|
public long | getMicrosecondLength()
throw new UnsupportedOperationException();
|
public long | getMicrosecondPosition()
if (isOpen()) {
return player.getCurrentPosition() * 1000;
} else {
return 0;
}
|
public boolean | isActive()
return false;
|
public boolean | isControlSupported(javax.sound.sampled.Control.Type control)
return false;
|
public boolean | isOpen()
return player != null;
|
public boolean | isRunning()
return player != null && player.isPlaying();
|
public void | loop(int count)
throw new UnsupportedOperationException();
|
public void | open()
try {
player = new MediaPlayer();
} catch (Exception ex) {
throw new LineUnavailableException(ex.toString());
}
|
public void | open(javax.sound.sampled.AudioFormat format, byte[] data, int offset, int bufferSize)
InputStream stream = new ByteArrayInputStream(data, offset, bufferSize);
open();
try {
this.stream = (AndroidAudioInputStream)(new AndroidAudioFileReader().getAudioInputStream(stream));
} catch (Exception ex) {
throw new LineUnavailableException(ex.toString());
}
|
public void | open(javax.sound.sampled.AudioInputStream stream)
open();
if (!(stream instanceof AndroidAudioInputStream)) {
try {
stream = new AndroidAudioFileReader().getAudioInputStream(stream);
} catch (Exception ex) {
throw new LineUnavailableException(ex.toString());
}
}
this.stream = (AndroidAudioInputStream)stream;
|
public void | removeLineListener(javax.sound.sampled.LineListener listener)
throw new UnsupportedOperationException();
|
public void | setFramePosition(int frames)
throw new UnsupportedOperationException();
|
public void | setLoopPoints(int start, int end)
throw new UnsupportedOperationException();
|
public void | setMicrosecondPosition(long microseconds)
if (!isOpen()) {
throw new IllegalStateException("Clip must be open");
}
player.seekTo((int)(microseconds / 1000));
|
public void | start()
if (!isOpen()) {
throw new IllegalStateException("Clip must be open");
}
if (stream == null) {
throw new IllegalStateException("Need an AudioInputStream to play");
}
if (!isRunning()) {
/*
* This is ugly, but there is no way around it: The javax.sound API
* doesn't expect to throw an exception at this point for illegal
* MIDI sequences. Since we don't really construct the MIDI sequence
* from the original binary data, but only refer to its URL, the
* MediaPlayer can actually bail out at this point. We wrap the
* exception into a RuntimeException, to at least keep the API
* contract.
*/
try {
String s = this.stream.getURL().toExternalForm();
/*
* TODO Workaround for 1107794: MediaPlayer doesn't handle
* "file:" URLs. Get rid of this.
*/
if (s.startsWith("file:")) {
s = s.substring(5);
}
player.setDataSource(s);
player.setAudioStreamType(AudioManager.STREAM_MUSIC);
player.prepare();
} catch (IOException ex) {
throw new RuntimeException(ex.toString());
}
player.start();
}
|
public void | stop()
if (!isOpen()) {
throw new IllegalStateException("Clip must be open");
}
if (isRunning()) {
player.stop();
}
|