Search in sources :

Example 6 with JavaLayerException

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);
}
Also used : Line(javax.sound.sampled.Line) DataLine(javax.sound.sampled.DataLine) SourceDataLine(javax.sound.sampled.SourceDataLine) LineUnavailableException(javax.sound.sampled.LineUnavailableException) SourceDataLine(javax.sound.sampled.SourceDataLine) JavaLayerException(vazkii.symphony.lib.javazoom.jl.decoder.JavaLayerException)

Example 7 with JavaLayerException

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;
}
Also used : SampleBuffer(vazkii.symphony.lib.javazoom.jl.decoder.SampleBuffer) Header(vazkii.symphony.lib.javazoom.jl.decoder.Header) JavaLayerException(vazkii.symphony.lib.javazoom.jl.decoder.JavaLayerException)

Example 8 with JavaLayerException

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);
        }
    }
}
Also used : InputStream(java.io.InputStream) JavaLayerException(vazkii.symphony.lib.javazoom.jl.decoder.JavaLayerException)

Example 9 with JavaLayerException

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;
}
Also used : AudioDevice(vazkii.symphony.lib.javazoom.jl.player.AudioDevice) SampleBuffer(vazkii.symphony.lib.javazoom.jl.decoder.SampleBuffer) Header(vazkii.symphony.lib.javazoom.jl.decoder.Header) JavaLayerException(vazkii.symphony.lib.javazoom.jl.decoder.JavaLayerException)

Example 10 with JavaLayerException

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);
    }
}
Also used : BufferedInputStream(java.io.BufferedInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException) JavaLayerException(vazkii.symphony.lib.javazoom.jl.decoder.JavaLayerException) JavaLayerException(vazkii.symphony.lib.javazoom.jl.decoder.JavaLayerException) IOException(java.io.IOException)

Aggregations

JavaLayerException (vazkii.symphony.lib.javazoom.jl.decoder.JavaLayerException)11 BufferedInputStream (java.io.BufferedInputStream)3 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3 Header (vazkii.symphony.lib.javazoom.jl.decoder.Header)3 FileInputStream (java.io.FileInputStream)2 SampleBuffer (vazkii.symphony.lib.javazoom.jl.decoder.SampleBuffer)2 PrintWriter (java.io.PrintWriter)1 AudioFormat (javax.sound.sampled.AudioFormat)1 DataLine (javax.sound.sampled.DataLine)1 Line (javax.sound.sampled.Line)1 LineUnavailableException (javax.sound.sampled.LineUnavailableException)1 SourceDataLine (javax.sound.sampled.SourceDataLine)1 Bitstream (vazkii.symphony.lib.javazoom.jl.decoder.Bitstream)1 Decoder (vazkii.symphony.lib.javazoom.jl.decoder.Decoder)1 Obuffer (vazkii.symphony.lib.javazoom.jl.decoder.Obuffer)1 AudioDevice (vazkii.symphony.lib.javazoom.jl.player.AudioDevice)1