How to automatically pause an audio in java netbeans?


Good day, I know very little about programming, I'm doing a project in netbeans in java with a Jframe, where through a list box you select a concept and hear an audio there Everything is fine until I select another audio and the sounds come together distorting completely Is there any way to pause an audio when changing options? I would thank you a lot This is my code

   String ruta2 = "G://Proyecto//src//Sonidos e imagenes//Sonidos//Digestivo";

This is the route where the audios are located

   private void lstProcesosMousePressed(java.awt.event.MouseEvent evt) {                                         

    String Archivo = ruta2 + "//" + lstProcesos.getSelectedValue() + ".wav";

        Clip sonido=AudioSystem.getClip(); File(Archivo)));
    } catch (Exception e){


asked by Hana Mtz 15.11.2018 в 03:39

1 answer


You must use the method stop ( )


You must stop the audio and play again by start()

answered by 15.11.2018 в 03:59