Linux guys!

Does this work for JDK1.2. I have got a glibc linux yet so I can't test this 
code personally.

Cheers
Peter

______________________________ Forward Header __________________________________
Subject: sun.audio.* in Java 2 Platform
Author:  Peter Pilgrim at London
Date:    27/04/99 16:52



I have an application that uses the sun.audio.* sound classes in JDK1.1 
but does not work on JDK1.2. I think the `AudioStreamSequence' does not 
work in JDK1.2 at all. I know that sun.audio.* is deprecated but there 
another way to play audio sounds in sequence (__without the Java Media 
Framework;-).

I am using JDK1.2.1 on Windows NT 4

This my test case java class.

The Sun audio files actually make a song using a set of riffs. 
Replace them with something else to test or I can supply a big zip.

// AudioTest.java

import java.io.*;
import java.util.*;
import sun.audio.*;

public class AudioTest {

   public static void main( String [] args ) 
   {
        String audioClip1 = "appres\\audio\\rock-fill.au"; 
        String audioClip2 = "appres\\audio\\rock-verse.au"; 
        String audioClip3 = "appres\\audio\\rock-frettap7.au";

        try { 
            // This is dumb ass code, basically we maintaining a list of 
            // audio file pointers in the stream to each audio clip.
            // Trust me, it makes sense that JavaSoft wrote it this way! 
            AudioStream [] audioStream = new AudioStream[16];
            int n=0;
            audioStream[n++] = new AudioStream( new FileInputStream( 
audioClip1 ));
            audioStream[n++] = new AudioStream( new FileInputStream( 
audioClip2 ));
            audioStream[n++] = new AudioStream( new FileInputStream( 
audioClip2 ));
            audioStream[n++] = new AudioStream( new FileInputStream( 
audioClip3 ));
            audioStream[n++] = new AudioStream( new FileInputStream( 
audioClip1 ));
            audioStream[n++] = new AudioStream( new FileInputStream( 
audioClip2 ));
            audioStream[n++] = new AudioStream( new FileInputStream( 
audioClip2 ));
            audioStream[n++] = new AudioStream( new FileInputStream( 
audioClip2 ));
            audioStream[n++] = new AudioStream( new FileInputStream( 
audioClip1 ));
            audioStream[n++] = new AudioStream( new FileInputStream( 
audioClip1 ));
            audioStream[n++] = new AudioStream( new FileInputStream( 
audioClip2 ));
            audioStream[n++] = new AudioStream( new FileInputStream( 
audioClip3 ));


            // Create the audio stream sequence object 
            Vector v = new Vector();
            for (int q=0; q<audioStream.length; ++q )
                if ( audioStream[q] != null )
                    v.addElement(audioStream[q]);

            AudioStreamSequence audiostream = new 
AudioStreamSequence(v.elements());


                // Audio player should play the audio stream sequence 
                //  but doesn't. Why????
            AudioPlayer.player.start( audiostream );

            System.out.println( "Press any key to end"); 
            System.in.read();

        }
        catch (IOException ioe) { 
            System.out.println(ioe);
        }

        // Force garbage collection now if possible 
        System.gc();
        try { Thread.sleep(1000); } catch (InterruptedException ie) { ; }
    }
}

// fini

application/openmail-1166

Reply via email to