1 Reply Latest reply: Nov 10, 2011 8:27 PM by philfrei RSS

    Detect when a USB mic is plugged in or unplugged

      It seems like JavaSound doesn't detect when a USB Microphone is plugged in or removed.

      If plugged in while my java application is running, its not detected. Worse, if unplugged it still thinks its a valid mixer.

      I have to relaunch the VM. Is there any way around this? I'm running Java 1.6.0_24 on Windows 7.

      Here is the code I'm using to get the list of microphones:
          public LinkedList<Mixer.Info> getTargetMixers()
              Line.Info targetDLInfo = new Line.Info(TargetDataLine.class);
              LinkedList<Mixer.Info> targetMixers = new LinkedList<Mixer.Info>();
              // Get all the mixers
              Mixer.Info[] mixerInfoArray = AudioSystem.getMixerInfo();
              for(int i=0; i<mixerInfoArray.length; i++)
                  Mixer.Info mixerInfo = mixerInfoArray;
      Mixer mixer = AudioSystem.getMixer(mixerInfo);
      catch(Exception ex)
      logger_.error("Error getting mixer: " + mixerInfo.getName(), ex);

      return targetMixers;
      Thanks Much...