Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4226299

AudioClip does not play audio files as expected

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P3 P3
    • None
    • 2.0, 1.1.7
    • client-libs
    • other, x86
    • solaris_2.6, windows_nt



      Name: keC81026 Date: 04/02/99



              AudioClip doesn't play audio file as expected with jdk1.1.7.

      to reproduce
              1. compile SoundApplet.java
              2. execute "appletviewer example1.html"
              3. Note, that if sound.wav may be au-stereo, wav-mono, wav-stereo, you will get an error :
              ]=================================================
                      NativeAudioStream: invalid file type.
                      NativeAudioStream: invalid file type.
              ]=================================================



      ====================== SoundApplet.java =============================
      import java.awt.Graphics;
      import java.applet.*;
      import java.net.URL;
      import java.net.MalformedURLException;


      public class SoundApplet extends Applet {
          /** The URL of the sound to be played. */

          URL sound;
          AudioClip soundData = null;
          boolean isReady;

          public void getMedia() {
              try {
              sound = new URL(getDocumentBase(), "sound.wav");
              if (sound != null && soundData == null) {
                  soundData = getAudioClip(sound);
              }
              if (soundData == null) {
                  System.out.println("SoundArea: Unable to load data "+sound);
              }
              isReady = true;
              } catch (Exception e) {
              };

          }

          public void enter() {
              if (! isReady) {
                  showStatus("Loading media file...");
                  return;
              }
              long now = System.currentTimeMillis();
              soundData.play();

          }

          public void init( ) {
                      getMedia();
              enter();
          }
          public SoundApplet() {
              super();
          };

      }
      =========== example1.html =================================================


      <html>
        <body>
            <applet code=SoundApplet.class width=10 height=10>
            </applet>
        </body>
      </html>

      ===========================================================================
      ======================================================================

            kkytlesunw Kara Kytle (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: