当前位置: 首页>>代码示例>>Java>>正文


Java AudioClip类代码示例

本文整理汇总了Java中java.applet.AudioClip的典型用法代码示例。如果您正苦于以下问题:Java AudioClip类的具体用法?Java AudioClip怎么用?Java AudioClip使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AudioClip类属于java.applet包,在下文中一共展示了AudioClip类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: playApplet

import java.applet.AudioClip; //导入依赖的package包/类
private static void playApplet(String filename) {
	URL url = null;
	try {
		File file = new File(filename);
		if (file.canRead())
			url = file.toURI().toURL();
	} catch (MalformedURLException e) {
		throw new IllegalArgumentException("could not play '" + filename + "'", e);
	}

	// URL url = StdAudio.class.getResource(filename);
	if (url == null) {
		throw new IllegalArgumentException("could not play '" + filename + "'");
	}

	AudioClip clip = Applet.newAudioClip(url);
	clip.play();
}
 
开发者ID:Scoutdrago3,项目名称:MusicToGraph,代码行数:19,代码来源:StdAudio.java

示例2: myKeyEvent

import java.applet.AudioClip; //导入依赖的package包/类
public Command myKeyEvent(KeyStroke stroke) {
  myGetKeyCommands();
  Command c = null;
  if (command.matches(stroke)) {
    final String clipName = format.getText(Decorator.getOutermost(this));
    c = new PlayAudioClipCommand(clipName);
    try {
      final AudioClip clip = GameModule.getGameModule()
                                       .getDataArchive()
                                       .getCachedAudioClip(clipName);
      if (clip != null) {
        clip.play();
      }
    }
    catch (IOException e) {
      reportDataError(this, Resources.getString("Error.not_found", "Audio Clip"), "Clip="+clipName, e);
    }
  }
  return c;
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:21,代码来源:PlaySound.java

示例3: TravoltageAudio

import java.applet.AudioClip; //导入依赖的package包/类
public TravoltageAudio( TravoltageModel travoltageModel ) {
    travoltageModel.addListener( new TravoltageModel.Listener() {
        public void sparkStarted() {
        }

        public void sparkFinished() {
            sparkFinished = true;
        }

        public void electronExitedFinger() {
            if( sparkFinished ) {
                play();
                sparkFinished = false;
            }
        }
    } );
    AudioClip ouch = Applet.newAudioClip( findResource( "travoltage/audio/OuchSmallest.wav" ) );
    AudioClip zzt = Applet.newAudioClip( findResource( "travoltage/audio/ShockSmallest.wav" ) );
    this.clips = new AudioClip[]{ouch, zzt};
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:21,代码来源:TravoltageAudio.java

示例4: playApplet

import java.applet.AudioClip; //导入依赖的package包/类
private static void playApplet(String filename) {
    URL url = null;
    try {
        File file = new File(filename);
        if(file.canRead()) url = file.toURI().toURL();
    }
    catch (MalformedURLException e) {
        throw new IllegalArgumentException("could not play '" + filename + "'", e);
    }

    // URL url = StdAudio.class.getResource(filename);
    if (url == null) {
        throw new IllegalArgumentException("could not play '" + filename + "'");
    }

    AudioClip clip = Applet.newAudioClip(url);
    clip.play();
}
 
开发者ID:yimng,项目名称:personal-stuff,代码行数:19,代码来源:StdAudio.java

示例5: getJButton

import java.applet.AudioClip; //导入依赖的package包/类
/**
 * This method initializes jButton
 * 
 * @return javax.swing.JButton
 */
private JButton getJButton() {
    if (jButton == null) {
        jButton = new JButton();
        jButton.setText("Add");
        jButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent e) {
                File sound = new File("bddbddb.wav");
                try {
                    AudioClip audioClip = Applet.newAudioClip(sound.toURL());
                    audioClip.play();
                } catch (MalformedURLException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }
            }
        });
    }
    return jButton;
}
 
开发者ID:petablox-project,项目名称:petablox,代码行数:25,代码来源:SolverGUI.java

示例6: getFunDialog

import java.applet.AudioClip; //导入依赖的package包/类
public static Dialog getFunDialog()   {
    FileObject img = FileUtil.getConfigFile("BartGIfImage/BartSaturdayNightFever.gif");
    FileObject audio = FileUtil.getConfigFile("BartAudio/STheme.wav");
    final AudioClip clip = Applet.newAudioClip(audio.toURL());
    Icon icon = new ImageIcon(img.toURL());   
    JLabel label = new JLabel(icon);
    final Dialog dialog = new BartThemeDialog(WindowManager.getDefault().getMainWindow(), label);
    label.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if(e.getClickCount() == 1)   {
                clip.stop();
                dialog.dispose();
            }
        }
        
    });
    clip.loop();
    return dialog;
}
 
开发者ID:dbunibas,项目名称:BART,代码行数:22,代码来源:BartThemeDialog.java

示例7: playSound

import java.applet.AudioClip; //导入依赖的package包/类
/**
 * Work method to play the sound.
 */
protected Object playSound(String soundToPlay) {
	// Load it from the cache.
	AudioClip clip = (AudioClip)soundCache.get(soundToPlay);
	
	// Construct a new AudioClip and cache it.
	if (clip == null) {
		try{
			clip = Applet.newAudioClip(ClassLoader.getSystemResource(soundToPlay));
			soundCache.put(soundToPlay, clip);
		} catch (NullPointerException npe){
		} catch (NoSuchMethodError nsme){
		}
	}
	
	// If the clip was somehow properly constructed or retrieved from the cache, play it.
	if (clip != null) {
		clip.play();
	}
	
	return "done";
}
 
开发者ID:bvarner,项目名称:javashare,代码行数:25,代码来源:ApplicationSoundThreadManager.java

示例8: playSound

import java.applet.AudioClip; //导入依赖的package包/类
/**
 * Plays the Sound, constructing the clip from the Applet passed to the constructor.
 * @overrides ApplicationSoundThreadManager.playSound
 */
protected Object playSound(String soundToPlay) {
	// Load it from the cache.
	AudioClip clip = (AudioClip)soundCache.get(soundToPlay);
	
	// Construct a new AudioClip and cache it.
	if (clip == null) {
		try{
			clip = soundSource.getAudioClip(new URL(soundSource.getParameter("SoundDirURL") + "/" + soundToPlay));
			soundCache.put(soundToPlay, clip);
		} catch (NullPointerException npe){
		} catch (NoSuchMethodError nsme){
		} catch (MalformedURLException mue){
			System.out.println(mue.toString());
		}
	}
	
	// If the clip was somehow properly constructed or retrieved from the cache, play it.
	if (clip != null) {
		clip.play();
	}
	
	return "done";
}
 
开发者ID:bvarner,项目名称:javashare,代码行数:28,代码来源:AppletSoundThreadManager.java

示例9: BarriersSelector

import java.applet.AudioClip; //导入依赖的package包/类
/**
 * construct method . <br />
 * 
 * @param	default
 * @param	max
 * @param	offset
 * @param	w
 * @param	h
 * @param	icons
 */
public BarriersSelector( Battlefield bf, int defualt,
		int max, int offset, int w, int h, ImageIcon[] icons, AudioClip buttonClip ) 
{
	this.BF = bf;
	this.barriers = defualt;
	this.max = max;
	this.offset = offset;
	this.w = w;
	this.h = h;
	this.tImages = icons[0].getImage();
	this.pImages = icons[1].getImage();
	this.grass = icons[2];
	this.buttonClip = buttonClip;
	i_width = icons[0].getIconWidth();
	i_height = icons[0].getIconHeight();
	
	str_width = max * this.offset;
}
 
开发者ID:niluzhang,项目名称:TankWar,代码行数:29,代码来源:BarriersSelector.java

示例10: playClip

import java.applet.AudioClip; //导入依赖的package包/类
/**
 * Plays an AudioClip.
 *
 * @param clip the audioclip to play.
 */
public void playClip(final AudioClip clip) {

    final Runnable playThread = new Runnable() {
        public void run() {
            try {
                clip.play();
            }
            catch (Exception ex) {
                System.err.println("Unable to load sound file");
            }
        }
    };

    TaskEngine.getInstance().submit(playThread);
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:21,代码来源:SoundManager.java

示例11: getAudio

import java.applet.AudioClip; //导入依赖的package包/类
public static AudioClip getAudio(int index) {
	if (audios[index] == null) {
		URL url = null;
		ClassLoader classLoader = FileHelper.class.getClassLoader();
		url = classLoader.getResource("music/" + index + ".wav");
		audios[index] = Applet.newAudioClip(url);
	}
	return audios[index];
}
 
开发者ID:zhangjikai,项目名称:LinkGame,代码行数:10,代码来源:EffectSound.java

示例12: createAudioClipFactory

import java.applet.AudioClip; //导入依赖的package包/类
protected AudioClipFactory createAudioClipFactory() {
  return new AudioClipFactory() {
    public AudioClip getAudioClip(URL url) {
      return Applet.newAudioClip(url);
    }
  };
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:8,代码来源:SoundConfigurer.java

示例13: playSound

import java.applet.AudioClip; //导入依赖的package包/类
/**
 * Plays a sound based on
 * the type parameter.
 * @param type the sound type defined in
 * Notification class.
 */
public void playSound(SoundType type) {
    final AudioClip aClip = config.getSound(type);
    if (aClip != null) {
        aClip.play();
    }
}
 
开发者ID:adbenitez,项目名称:jNotifyOSD,代码行数:13,代码来源:DesktopNotify.java

示例14: getSound

import java.applet.AudioClip; //导入依赖的package包/类
public AudioClip getSound(SoundType sound) {
    if (sounds == null) {
        SoundType[] soundsT = SoundType.values();
        sounds = new HashMap<SoundType, AudioClip>();
        String urlSound;
        URL url;
        for (SoundType st : soundsT) {
            urlSound = sounds_path + st.name() + ".wav";
            url = getClass().getResource(urlSound);
            if (url == null) {
                switch (st) {
                case ERROR:
                    urlSound = sounds_path + SoundType.WARNING.name() + ".wav";
                    url = getClass().getResource(urlSound);
                    break;
                case WARNING:
                    urlSound = sounds_path + SoundType.ERROR.name() + ".wav";
                    url = getClass().getResource(urlSound);
                    break;
                default: // do nothing
                }
                if (url == null) {
                    urlSound = sounds_path + SoundType.MESSAGE.name() + ".wav";
                    url = getClass().getResource(urlSound);
                }
            }
            if (url != null) {
                sounds.put(st, Applet.newAudioClip(url));
            }
        }
    }
    return sounds.get(sound);
}
 
开发者ID:adbenitez,项目名称:jNotifyOSD,代码行数:34,代码来源:NotifyConfig.java

示例15: getAudioClip

import java.applet.AudioClip; //导入依赖的package包/类
public AudioClip getAudioClip(URL url) {
    // We don't currently support audio clips in the Beans.instantiate
    // applet context, unless by some luck there exists a URL content
    // class that can generate an AudioClip from the audio URL.
    try {
        return (AudioClip) url.getContent();
    } catch (Exception ex) {
        return null;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:Beans.java


注:本文中的java.applet.AudioClip类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。