--- /dev/null
+// dummy audio device
+/**
+ * The <code>JavaSoundAudioDevice</code> implements an audio device by using the
+ * JavaSound API.
+ *
+ * @since 0.0.8
+ * @author Mat McGowan
+ */
+public class AudioDevice {
+
+ /**
+ * Prepares the AudioDevice for playback of audio samples.
+ *
+ * @param decoder
+ * The decoder that will be providing the audio samples.
+ *
+ * If the audio device is already open, this method returns silently.
+ *
+ */
+ public void open(Decoder decoder) throws JavaLayerException {
+
+ }
+
+ /**
+ * Retrieves the open state of this audio device.
+ *
+ * @return <code>true</code> if this audio device is open and playing audio
+ * samples, or <code>false</code> otherwise.
+ */
+ public boolean isOpen() {
+ return true;
+ }
+
+ /**
+ * Writes a number of samples to this <code>AudioDevice</code>.
+ *
+ * @param samples
+ * The array of signed 16-bit samples to write to the audio device.
+ * @param offs
+ * The offset of the first sample.
+ * @param len
+ * The number of samples to write.
+ *
+ * This method may return prior to the samples actually being played
+ * by the audio device.
+ */
+ public void write(short[] samples, int offs, int len) throws JavaLayerException {
+
+ }
+
+ /**
+ * 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 <code>write</code> or <code>flush</code> operation
+ * should be unblocked by this method.
+ */
+ public void close() {
+
+ }
+
+ /**
+ * Blocks until all audio samples previously written to this audio device have
+ * been heard.
+ */
+ public void flush() {
+
+ }
+
+ /**
+ * Retrieves the current playback position in milliseconds.
+ */
+ public int getPosition() {
+ return 0;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+// command line player for MPEG audio file
+public class MP3Player {
+
+ private String filename = null;
+
+ public static void main(String args[]) {
+
+ MP3Player player = new MP3Player();
+ player.init(args);
+
+ }
+
+ private void init(String[] args) {
+ if (args.length == 1) {
+ filename = args[0];
+ }
+ }
+
+ /**
+ * Playing file from FileInputStream.
+ */
+ protected InputStream getInputStream() throws IOException {
+ FileInputStream fin = new FileInputStream(filename);
+ BufferedInputStream bin = new BufferedInputStream(fin);
+ return bin;
+ }
+
+ public void play() throws JavaLayerException {
+ try {
+ System.out.println("playing " + filename + "...");
+ InputStream in = getInputStream();
+ AudioDevice dev = new AudioDevice();
+ Player player = new Player(in, dev);
+ player.play();
+ } catch (IOException ex) {
+ throw new JavaLayerException("Problem playing file " + filename, ex);
+ } catch (Exception ex) {
+ throw new JavaLayerException("Problem playing file " + filename, ex);
+ }
+ }
+
+}
\ No newline at end of file
*/\r
public Player(InputStream stream) throws JavaLayerException\r
{\r
- //this(stream, null); \r
+ this(stream, null); \r
}\r
\r
- /* temporarily disabled by eom\r
+\r
public Player(InputStream stream, AudioDevice device) throws JavaLayerException\r
{\r
bitstream = new Bitstream(stream); \r
decoder = new Decoder();\r
\r
- if (device!=null)\r
- { \r
- audio = device;\r
- }\r
- else\r
- { \r
- FactoryRegistry r = FactoryRegistry.systemRegistry();\r
- audio = r.createAudioDevice();\r
- }\r
- audio.open(decoder);\r
+// if (device!=null)\r
+// { \r
+// audio = device;\r
+// }\r
+// else\r
+// { \r
+// FactoryRegistry r = FactoryRegistry.systemRegistry();\r
+// audio = r.createAudioDevice();\r
+// }\r
+ \r
+ device.open(decoder);\r
}\r
- */\r
+ \r
\r
public void play() throws JavaLayerException\r
{\r
return true;\r
}\r
\r
- public static void main(String args[]){\r
- //dummy \r
- }\r
-\r
- \r
}\r
BUILDSCRIPT=../../../buildscript
-PROGRAM=Player
-SOURCE_FILES=Player.java
+PROGRAM=MP3Player
+SOURCE_FILES=MP3Player.java
BSFLAGS= -32bit -ssjava -ssjavadebug -printlinenum -mainclass $(PROGRAM) -heapsize-mb 1000 -garbagestats -joptimize -noloop -optimize -debug