long  getDuration() {
         // TODO: how should this really be done??
         if (debugFlag)
             debugPrintln("JSChannel:getDuration");

         if (ais == null || audioFormat == null ) {
             if (debugFlag)
                 debugPrintln("JSChannel: Internal Error getDuration");
             return (long)Sample.DURATION_UNKNOWN;
         }
         // Otherwise we'll assume that we can calculate this duration

         // get "duration" of audio stream (wave file)
         // TODO: For True STREAMing audio the size is unknown...
         long numFrames = ais.getFrameLength();
         if (debugFlag)
             debugPrintln("           frame length = " + numFrames);
         if (numFrames <= 0)
             return (long)Sample.DURATION_UNKNOWN;

         float rateInFrames = audioFormat.getFrameRate();
         rateInHz = audioFormat.getSampleRate();
         if (debugFlag)
             debugPrintln("           rate in Frames = " + rateInFrames);
         if (numFrames <= 0)
             return (long)Sample.DURATION_UNKNOWN;
         long duration = (long)((float)numFrames/rateInFrames);
         if (debugFlag)
             debugPrintln("           duration(based on ais) = " + duration);
         return duration;
     }