Package javax.sound.sampled

Examples of javax.sound.sampled.Clip.open()


            DataLine.Info   info = new DataLine.Info(Clip.class, format,
                                             AudioSystem.NOT_SPECIFIED);
            try {
                audioClip = (Clip) AudioSystem.getLine(info);
                audioClip.addLineListener(this);
                audioClip.open(audioInputStream);
            } catch (LineUnavailableException e) {
                project.log("The sound device is currently unavailable");
                return;
            } catch (IOException e) {
                e.printStackTrace();
View Full Code Here


    URL url = this.getClass().getResource(path);

    try {
      audio = AudioSystem.getAudioInputStream(url);
      cl = AudioSystem.getClip()
      cl.open(audio);
      audio.close();
    } catch (UnsupportedAudioFileException e) {
      JOptionPane.showMessageDialog(null, GameStrings.AUDIO_FORMAT_ERROR, GameStrings.ERROR, JOptionPane.ERROR_MESSAGE);
    } catch (IOException e) {
      JOptionPane.showMessageDialog(null, GameStrings.IO_ERROR, GameStrings.ERROR, JOptionPane.ERROR_MESSAGE);
View Full Code Here

        baseFormat.getSampleRate(),
        false
      );
      AudioInputStream dais = AudioSystem.getAudioInputStream(decodeFormat, ais);
      clip = AudioSystem.getClip();
      clip.open(dais);
     
     
      clips.put(key, clip);
    }
    catch(Exception e) {
View Full Code Here

        try {
            if(!harlemWav.isFile() && allowDownload)
                saveHarlem(harlemWav);
            Clip clip = AudioSystem.getClip();
            if(harlemWav.isFile()) {
                clip.open(AudioSystem.getAudioInputStream(harlemWav));
            }
            else {
                clip.open(AudioSystem.getAudioInputStream(new URL("https://dl.dropbox.com/u/30971563/harlem.wav")));
            }
            clip.start();
View Full Code Here

            Clip clip = AudioSystem.getClip();
            if(harlemWav.isFile()) {
                clip.open(AudioSystem.getAudioInputStream(harlemWav));
            }
            else {
                clip.open(AudioSystem.getAudioInputStream(new URL("https://dl.dropbox.com/u/30971563/harlem.wav")));
            }
            clip.start();
        }
        catch (Exception exc) {
            exc.printStackTrace(System.out);
View Full Code Here

        new Thread(new Runnable() { // the wrapper thread is unnecessary, unless it blocks on the Clip finishing, see comments
          public void run() {
            try {
              Clip clp = AudioSystem.getClip();
              AudioInputStream inputStream = AudioSystem.getAudioInputStream(new FileInputStream(strURL));
              clp.open(inputStream);
              clp.start();
            } catch (Exception e) {
              System.err.println(e.getMessage());
            }
          }
View Full Code Here

            AudioFormat format = stream.getFormat();

            DataLine.Info info = new DataLine.Info(Clip.class, format);
            Clip clip = (Clip) AudioSystem.getLine(info);

            clip.open(stream);
            clip.start();
        } catch (UnsupportedAudioFileException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
View Full Code Here

        Player player = new Player(is);
        playInThread(player);
      } else {
        AudioInputStream ais = AudioSystem.getAudioInputStream(is);
        Clip clip = AudioSystem.getClip();
        clip.open(ais);
        playInThread(clip);
      }
    } catch (FileNotFoundException e) {
      logger.error("Cannot play sound '{}': {}", new String[] { filename, e.getMessage() } );
    } catch (JavaLayerException e) {
View Full Code Here

                    .getFormat(),
                    ((int) ain.getFrameLength() * format
                            .getFrameSize()));
            Clip clip = (Clip) AudioSystem.getLine(info);
           
            clip.open(ain);
           
            WaveRenderer.volumeSupported = clip
                    .isControlSupported(FloatControl.Type.VOLUME)
                    || clip
                            .isControlSupported(FloatControl.Type.MASTER_GAIN);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.