⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sound.java

📁 试用JAVA通过COMM口发送短信的代码.
💻 JAVA
字号:
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   Sound.java

package org.cross.sms.gui;

import java.net.URLClassLoader;
import javax.sound.sampled.*;

public class Sound
    implements Runnable
{

    public Sound(int sound)
    {
        if(sound < 0 || sound > 4)
            return;
        URLClassLoader urlLoader = (URLClassLoader)getClass().getClassLoader();
        java.net.URL url = urlLoader.findResource(filename[sound]);
        try
        {
            currentSound = AudioSystem.getAudioInputStream(url);
        }
        catch(Exception ex1)
        {
            currentSound = null;
            return;
        }
        if(currentSound instanceof AudioInputStream)
            try
            {
                AudioInputStream stream = (AudioInputStream)currentSound;
                AudioFormat format = stream.getFormat();
                javax.sound.sampled.DataLine.Info info = new javax.sound.sampled.DataLine.Info(javax.sound.sampled.Clip.class, stream.getFormat(), (int)stream.getFrameLength() * format.getFrameSize());
                Clip clip = (Clip)AudioSystem.getLine(info);
                clip.open(stream);
                currentSound = clip;
            }
            catch(Exception ex)
            {
                currentSound = null;
                return;
            }
        if(currentSound != null)
            start();
    }

    public void playSound()
    {
        Clip clip;
//        Exception e;
        if(!(currentSound instanceof Clip));
        
//            break MISSING_BLOCK_LABEL_85;
        clip = (Clip)currentSound;
        clip.start();
        try
        {
//            thread;
        	thread.sleep(999L);
//            Thread.sleep(999L);
        }
        // Misplaced declaration of an exception variable
        catch(Exception e) { 
        	
        }

        if(true){
//        	_L2:
                if(!clip.isActive() || thread == null){
                	
                }else{
                	try {
						thread.sleep(99L);
					} catch (InterruptedException e) {
						// TODO 自动生成 catch 块
						e.printStackTrace();
					}
                }
//                    break MISSING_BLOCK_LABEL_73;
//                thread;
                
        }else{
//        	_L1:
//                e;
                clip.stop();
                clip.close();
                currentSound = null;
                return;        	
        }

    }

    public void start()
    {
        thread = new Thread(this);
        thread.start();
    }

    public void run()
    {
        playSound();
        stop();
    }

    public void stop()
    {
        if(thread != null)
            thread.interrupt();
        thread = null;
    }

    String currentName;
    Object currentSound;
    Thread thread;
    String filename[] = {
        "msg.wav", "send.wav"
    };
    public static int MSG = 0;
    public static int SEND = 1;

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -