🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #429

Sound

#429
From: LMario
Date: Fri, 26 Aug 2005 03:30
40 lines
1802 bytes
I am playing a sound. How can I know when the sound terninates of playing. I
am using the next class on my program:

--------------------------------------
import java.io.*;
import javax.sound.sampled.*;

public class Sound {
  File sf=new File("mySound.wav");
  AudioFileFormat aff;
  AudioInputStream ais;

  public Sound() {
    try {
      aff = AudioSystem.getAudioFileFormat(sf);
      //System.out.println(aff);

      ais = AudioSystem.getAudioInputStream(sf);

      AudioFormat af = aff.getFormat();

      DataLine.Info info = new DataLine.Info(
          Clip.class,
          ais.getFormat(),
          ( (int) ais.getFrameLength() *
           af.getFrameSize()));

      Clip ol = (Clip) AudioSystem.getLine(info);

      ol.open(ais);

      ol.loop(3);
    }
    catch (UnsupportedAudioFileException ee) {}
    catch (IOException ea) {}
    catch (LineUnavailableException LUE) {}
      System.out.println("Error")    ;

  }
}
Technical Details
Message-ID: <430e8cb8@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: f74b3,7f218c62d55ad91b,start
X-Google-Attributes: gidf74b3,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "LMario" <lefalme@prodigy.net.com>
Newsgroups: borland.public.jbuilder.java.language
Subject: Sound
Date: Thu, 25 Aug 2005 21:30:34 -0600
Lines: 42
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.3790.0
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
NNTP-Posting-Host: 201.138.162.59
Message-ID: <430e8cb8@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1125027000 201.138.162.59 (25 Aug 2005 20:30:00 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail