use of vazkii.symphony.lib.javazoom.jl.decoder.JavaLayerException in project Symphony by Vazkii.
the class JavaSoundAudioDevice method createSource.
// createSource fix.
protected void createSource() throws JavaLayerException {
Throwable t = null;
try {
Line line = AudioSystem.getLine(getSourceLineInfo());
if (line instanceof SourceDataLine) {
source = (SourceDataLine) line;
// source.open(fmt, millisecondsToBytes(fmt, 2000));
source.open(fmt);
/*
if (source.isControlSupported(FloatControl.Type.MASTER_GAIN))
{
FloatControl c = (FloatControl)source.getControl(FloatControl.Type.MASTER_GAIN);
c.setValue(c.getMaximum());
}*/
source.start();
}
} catch (RuntimeException ex) {
t = ex;
} catch (LinkageError ex) {
t = ex;
} catch (LineUnavailableException ex) {
t = ex;
}
if (source == null)
throw new JavaLayerException("cannot obtain source audio line", t);
}
use of vazkii.symphony.lib.javazoom.jl.decoder.JavaLayerException in project Symphony by Vazkii.
the class Player method decodeFrame.
/**
* Decodes a single frame.
*
* @return true if there are no more frames to decode, false otherwise.
*/
protected boolean decodeFrame() throws JavaLayerException {
try {
AudioDevice out = audio;
if (out == null)
return false;
Header h = bitstream.readFrame();
if (h == null)
return false;
// sample buffer set when decoder constructed
SampleBuffer output = (SampleBuffer) decoder.decodeFrame(h, bitstream);
synchronized (this) {
out = audio;
if (out != null) {
out.write(output.getBuffer(), 0, output.getBufferLength());
}
}
bitstream.closeFrame();
} catch (RuntimeException ex) {
throw new JavaLayerException("Exception decoding audio frame", ex);
}
/*
catch (IOException ex)
{
System.out.println("exception decoding audio frame: "+ex);
return false;
}
catch (BitstreamException bitex)
{
System.out.println("exception decoding audio frame: "+bitex);
return false;
}
catch (DecoderException decex)
{
System.out.println("exception decoding audio frame: "+decex);
return false;
}
*/
return true;
}
use of vazkii.symphony.lib.javazoom.jl.decoder.JavaLayerException in project Symphony by Vazkii.
the class PlayerApplet method start.
/**
* Starts this applet. An input stream and audio device
* are created and passed to the play() method.
*/
public void start() {
String name = getAudioFileName();
try {
InputStream in = getAudioStream();
AudioDevice dev = getAudioDevice();
play(in, dev);
} catch (JavaLayerException ex) {
synchronized (System.err) {
System.err.println("Unable to play " + name);
ex.printStackTrace(System.err);
}
}
}
use of vazkii.symphony.lib.javazoom.jl.decoder.JavaLayerException in project Symphony by Vazkii.
the class AdvancedPlayer method decodeFrame.
/**
* Decodes a single frame.
*
* @return true if there are no more frames to decode, false otherwise.
*/
protected boolean decodeFrame() throws JavaLayerException {
try {
AudioDevice out = audio;
if (out == null)
return false;
Header h = bitstream.readFrame();
if (h == null)
return false;
// sample buffer set when decoder constructed
SampleBuffer output = (SampleBuffer) decoder.decodeFrame(h, bitstream);
synchronized (this) {
out = audio;
if (out != null) {
out.write(output.getBuffer(), 0, output.getBufferLength());
}
}
bitstream.closeFrame();
} catch (RuntimeException ex) {
throw new JavaLayerException("Exception decoding audio frame", ex);
}
return true;
}
use of vazkii.symphony.lib.javazoom.jl.decoder.JavaLayerException in project Symphony by Vazkii.
the class jlp method play.
public void play() throws JavaLayerException {
try {
System.out.println("playing " + fFilename + "...");
InputStream in = null;
if (remote == true)
in = getURLInputStream();
else
in = getInputStream();
AudioDevice dev = getAudioDevice();
Player player = new Player(in, dev);
player.play();
} catch (IOException ex) {
throw new JavaLayerException("Problem playing file " + fFilename, ex);
} catch (Exception ex) {
throw new JavaLayerException("Problem playing file " + fFilename, ex);
}
}
Aggregations