// Path: src/uk/ac/open/audio/mp3/MP3Decoder.java
// public class MP3Decoder implements StreamableDecoder
// {
// 	private Decoder d;
// 	private Bitstream b;
// 	private Header h;
// 
// 	/**
// 	 * Initialises the decoder.
// 	 * @param input InputStream used for input data
// 	 * @throws AudioException If there is a problem reading the MP3
// 	 */
// 	public void init(InputStream input) throws AudioException
// 	{
// 		try
// 		{
// 			d = new Decoder();
// 			if (!input.markSupported())
// 			{
// 				input = new MarkResetStream(input);
// 			}
// 	  	b=new Bitstream(input,false);
// 	  	h=b.readFrame();
// 	  	if(h==null) throw new AudioException("Cannot play empty MP3");
// 	  	SampleBuffer buffer=new SampleBuffer(
// 	  		h.frequency(),
// 	  		h.mode()==Header.SINGLE_CHANNEL ? 1 : 2);
// 	  	d.setOutputBuffer(buffer);
// 		}
// 		catch(JavaLayerException e)
// 		{
// 			throw new AudioException(e);
// 		}
// 	}
// 
// 	/**
// 	 * Decodes the next frame of the MP3 and returns audio data. This may cause
// 	 * the thread to block while waiting for data from the InputStream.
// 	 * @return Decoded data in 44.1kHz stereo 16-bit little-endian format;
// 	 *   or null if MP3 has ended
// 	 * @throws AudioException
// 	 */
// 	public byte[] decode() throws AudioException
// 	{
// 		if(h==null) return null;
// 
// 		try
// 		{
// 			SampleBuffer output=(SampleBuffer)d.decodeFrame(h, b);
// 			short[] data=output.getBuffer();
// 			int length=output.getBufferLength();
// 
// 			// Upsample if required
// 			boolean stereo=output.getChannelCount()==2;
// 			int frequency=output.getSampleFrequency();
// 			if(frequency!=44100)
// 			{
// 				data=AudioUtil.resample(data,length,stereo,frequency,44100);
// 				length=data.length;
// 			}
// 
// 			// Convert to bytes for audio output
// 			byte[] byteData=AudioUtil.shortToByte(data, length, !stereo);
// 
// 			b.closeFrame();
// 	  	h=b.readFrame();
// 
// 			return byteData;
// 		}
// 		catch(JavaLayerException e)
// 		{
// 			throw new AudioException(e);
// 		}
// 	}
// 
// }
// 
// Path: src/uk/ac/open/audio/streaming/StreamPlayer.java
// public enum State
// {
// 	/** Downloading but not yet ready to play */
// 	WAITBEFOREPLAY,
// 	/** Downloaded enough that you should be able to start playing */
// 	READYTOPLAY,
// 	/** Completely downloaded */
// 	FULLYLOADED,
// 	/** Fully loaded, but audio buffer is empty */
// 	BUFFEREMPTY,
// 	/** Closed (no more playback possible) */
//   CLOSED
// }


import uk.ac.open.audio.mp3.MP3Decoder;
import uk.ac.open.audio.streaming.StreamPlayer.State;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
import java.util.LinkedList;
import javax.swing.*;
import uk.ac.open.audio.*;
import uk.ac.open.audio.adpcm.*;
					playbackError(e);
				}
			}
			if(stream != null)
			{
				stream.rewind();
			}
			if(connector != null)
			{
				connector = null;
			}
			progress.setBlank();
			playback.close();
			playback=null;
			started=false;
		}
		if(recording!=null)
		{
			recording.stop();
			recording=null;
		}

		if(changeButton)
		{
			setButtonState(ButtonState.START);
		}
	}

	public void streamChangedState(State s)
	{
// Path: src/uk/ac/open/audio/mp3/MP3Decoder.java
// public class MP3Decoder implements StreamableDecoder
// {
// 	private Decoder d;
// 	private Bitstream b;
// 	private Header h;
// 
// 	/**
// 	 * Initialises the decoder.
// 	 * @param input InputStream used for input data
// 	 * @throws AudioException If there is a problem reading the MP3
// 	 */
// 	public void init(InputStream input) throws AudioException
// 	{
// 		try
// 		{
// 			d = new Decoder();
// 			if (!input.markSupported())
// 			{
// 				input = new MarkResetStream(input);
// 			}
// 	  	b=new Bitstream(input,false);
// 	  	h=b.readFrame();
// 	  	if(h==null) throw new AudioException("Cannot play empty MP3");
// 	  	SampleBuffer buffer=new SampleBuffer(
// 	  		h.frequency(),
// 	  		h.mode()==Header.SINGLE_CHANNEL ? 1 : 2);
// 	  	d.setOutputBuffer(buffer);
// 		}
// 		catch(JavaLayerException e)
// 		{
// 			throw new AudioException(e);
// 		}
// 	}
// 
// 	/**
// 	 * Decodes the next frame of the MP3 and returns audio data. This may cause
// 	 * the thread to block while waiting for data from the InputStream.
// 	 * @return Decoded data in 44.1kHz stereo 16-bit little-endian format;
// 	 *   or null if MP3 has ended
// 	 * @throws AudioException
// 	 */
// 	public byte[] decode() throws AudioException
// 	{
// 		if(h==null) return null;
// 
// 		try
// 		{
// 			SampleBuffer output=(SampleBuffer)d.decodeFrame(h, b);
// 			short[] data=output.getBuffer();
// 			int length=output.getBufferLength();
// 
// 			// Upsample if required
// 			boolean stereo=output.getChannelCount()==2;
// 			int frequency=output.getSampleFrequency();
// 			if(frequency!=44100)
// 			{
// 				data=AudioUtil.resample(data,length,stereo,frequency,44100);
// 				length=data.length;
// 			}
// 
// 			// Convert to bytes for audio output
// 			byte[] byteData=AudioUtil.shortToByte(data, length, !stereo);
// 
// 			b.closeFrame();
// 	  	h=b.readFrame();
// 
// 			return byteData;
// 		}
// 		catch(JavaLayerException e)
// 		{
// 			throw new AudioException(e);
// 		}
// 	}
// 
// }
// 
// Path: src/uk/ac/open/audio/streaming/StreamPlayer.java
// public enum State
// {
// 	/** Downloading but not yet ready to play */
// 	WAITBEFOREPLAY,
// 	/** Downloaded enough that you should be able to start playing */
// 	READYTOPLAY,
// 	/** Completely downloaded */
// 	FULLYLOADED,
// 	/** Fully loaded, but audio buffer is empty */
// 	BUFFEREMPTY,
// 	/** Closed (no more playback possible) */
//   CLOSED
// }


// Path: src/uk/ac/open/audio/streaming/StreamPlayerUI.java
import uk.ac.open.audio.mp3.MP3Decoder;
import uk.ac.open.audio.streaming.StreamPlayer.State;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
import java.util.LinkedList;
import javax.swing.*;
import uk.ac.open.audio.*;
import uk.ac.open.audio.adpcm.*;

					playbackError(e);
				}
			}
			if(stream != null)
			{
				stream.rewind();
			}
			if(connector != null)
			{
				connector = null;
			}
			progress.setBlank();
			playback.close();
			playback=null;
			started=false;
		}
		if(recording!=null)
		{
			recording.stop();
			recording=null;
		}

		if(changeButton)
		{
			setButtonState(ButtonState.START);
		}
	}

	public void streamChangedState(State s)
	{
		if(s==StreamPlayer.State.READYTOPLAY || s==StreamPlayer.State.FULLYLOADED)