From owner-freebsd-java Thu Jan 16 1:53: 2 2003 Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DD80F37B401 for ; Thu, 16 Jan 2003 01:52:58 -0800 (PST) Received: from gddsn.org.cn (mail.gddsn.org.cn [210.21.6.33]) by mx1.FreeBSD.org (Postfix) with ESMTP id 19B7943F65 for ; Thu, 16 Jan 2003 01:52:58 -0800 (PST) (envelope-from wsk@ns.gddsn.org.cn) Received: from mail.gddsn.org.cn (unknown [192.168.168.4]) by gddsn.org.cn (Postfix) with ESMTP id 53EF038CBCE for ; Thu, 16 Jan 2003 17:52:50 +0800 (CST) Message-ID: <3E268198.2010401@mail.gddsn.org.cn> Date: Thu, 16 Jan 2003 17:55:36 +0800 From: Suken Woo User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; zh-CN; rv:1.0.0) Gecko/20020912 X-Accept-Language: zh MIME-Version: 1.0 To: java@freebsd.org Subject: jdk1.3.1 bug? Content-Type: text/plain; charset=gb2312 Content-Transfer-Encoding: 7bit Sender: owner-freebsd-java@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org hi,hacks: when running the following java prog, jdk1.3.1's EventListener seams just listened the reverse responsed event.if u move the mouse and press any keys , the program will play sounds normally,until u stopped the mouse or keyboad input event.but things would not occur under jdk1.4. in faintting --the src import java.net.URL; import java.net.MalformedURLException; import java.util.Date; import javax.sound.sampled.*; import javax.swing.JOptionPane; import cn.gd.seismology.rts.event.*; class RtsAlarmThread extends Thread implements AlarmEventListener, LineListener{ public static final String cvsid = "$Id: RtsAlarmThread.java,v 1.1 2002/12/31 10:41:32 hwh Exp $"; Clip clip = null; AudioClip audioClip; URL completeURL; boolean looping = false; long alarmTime; String event_id = ""; public RtsAlarmThread( URL baseURL, boolean looping) { this.completeURL = baseURL; this.looping = looping; this.setName("RtsAlarmThread"); setPriority(MIN_PRIORITY); start(); } public RtsAlarmThread( URL baseURL ) { this( baseURL,false ); } public void alarmEventHandler(AlarmEvent e) { } public void run() { try { AudioInputStream ais = AudioSystem.getAudioInputStream(completeURL); AudioFormat format = ais.getFormat(); /** * we can't yet open the device for ALAW/ULAW playback, * convert ALAW/ULAW to PCM */ if ((format.getEncoding() == AudioFormat.Encoding.ULAW) || (format.getEncoding() == AudioFormat.Encoding.ALAW)) { AudioFormat tmp = new AudioFormat( AudioFormat.Encoding.PCM_SIGNED, format.getSampleRate(), format.getSampleSizeInBits() * 2, format.getChannels(), format.getFrameSize() * 2, format.getFrameRate(), true); ais = AudioSystem.getAudioInputStream(tmp, ais); format = tmp; } DataLine.Info info = new DataLine.Info( Clip.class, format, (int)(ais.getFrameLength()* format.getFrameSize())); clip = (Clip)AudioSystem.getLine(info); Thread.sleep(1000); clip.open(ais); clip.addLineListener(this); if (looping) { clip.loop(Clip.LOOP_CONTINUOUSLY); } else { clip.start();//Clip.LOOP_CONTINUOUSLY); } JOptionPane.showMessageDialog(null,event_id +" alarm at "+ new Date(alarmTime),"Event Alarm", JOptionPane.OK_OPTION); clip.stop(); clip.close(); } catch(Exception ex) { ex.printStackTrace(); } System.exit(0); } public void update(LineEvent event) { if (event.getType() != LineEvent.Type.STOP ) { System.err.println("Hello"); } } public static void main(String[] args) { URL codeBase = null; try { codeBase = new URL("file:/usr/local/jdk1.3.1/demo/sound/media/spacemusic.au"); } catch (MalformedURLException e) { System.err.println(e.getMessage()); } RtsAlarmThread t = new RtsAlarmThread(codeBase, true); } } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-java" in the body of the message