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

Applet.newAudio().play() lacks error handling

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 1.2.0
    • client-libs



      Name: ccC48265 Date: 01/25/98


      Applet.newAudioClip() is neat! However if you give a bogus URL, you get no error
      indication.
      Perhaps it should throw an IOException, or at least return null and make you
      check it.

      The following example will demonstrate this problem.

      See the comment at the end about the System.exit(0) statement.

      import java.applet.*;
      import java.net.*;

      public class P {
      static String defSounds[] = {
      "file:///windows/media/chord.wav",
      "file:///windows/media/Beethoven's Fur Elise.rmi",
      };
      public static void main(String av[]) {
      if (av.length == 0)
      main(defSounds);
      else for (int i=0;i<av.length; i++) {
      System.out.println("Starting " + av[i]);
      try {
      URL snd = new URL(av[i]);
      // open to see if works or throws exception,
      close to free fd's
      snd.openConnection().getInputStream().close();
      Applet.newAudioClip(snd).play();
      } catch (Exception e) {
      System.err.println(e);
      }
      }
      // With this call, program exits before/during play.
      // Without it, program hangs forever after play.
      // System.exit(0);
      }
      }
      (Review ID: 23851)
      ======================================================================
      kara.kytle@Eng 1998-01-26

            kkytlesunw Kara Kytle (Inactive)
            ccresswesunw Claudette Cresswell (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: