本文整理汇总了Java中java.applet.AudioClip.play方法的典型用法代码示例。如果您正苦于以下问题:Java AudioClip.play方法的具体用法?Java AudioClip.play怎么用?Java AudioClip.play使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.applet.AudioClip
的用法示例。
在下文中一共展示了AudioClip.play方法的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();
}
示例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;
}
示例3: 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();
}
示例4: 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";
}
示例5: 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";
}
示例6: 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);
}
示例7: 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();
}
}
示例8: playAudioResource
import java.applet.AudioClip; //导入方法依赖的package包/类
/**
* Plays the sound from an audio resource file. If the resource can't
* be found, nothing is done. (If the sound is to replayed several
* times, it would be more efficient to save the AudioClip in an
* instance variable instead of loading it each time it is played.)
*/
private void playAudioResource(String audioResourceName) {
ClassLoader cl = getClass().getClassLoader();
URL resourceURL = cl.getResource(audioResourceName);
if (resourceURL != null) {
AudioClip sound = JApplet.newAudioClip(resourceURL);
sound.play();
}
}
示例9: playAudioResource
import java.applet.AudioClip; //导入方法依赖的package包/类
/**
* Plays the sound from an audio resource file. If the resource can't
* be found, nothing is done. (If the sound is to replayed several
* times, it would be more efficient to save the AudioClip in an
* instance variable instead of loading it each time it is played.)
*/
private void playAudioResource(String audioResourceName) {
ClassLoader cl = SoundAndCursorDemo.class.getClassLoader();
URL resourceURL = cl.getResource(audioResourceName);
if (resourceURL != null) {
AudioClip sound = JApplet.newAudioClip(resourceURL);
sound.play();
}
}
示例10: actionPerformed
import java.applet.AudioClip; //导入方法依赖的package包/类
/**
*/
public void actionPerformed(ActionEvent event)
{
if(event.getSource() == this)
{
updateToolTipText();
/*if(this.getClass().getResource("/sounds/button_push3.wav") != null)
(Applet.newAudioClip(this.getClass().getResource("/sounds/button_push3.wav"))).play();*/
AudioClip pushSound = ResourceHandler.getAudioClip("/sounds/button_push3.wav");
if(pushSound != null && AdminMainPanel.soundsEnabled)
pushSound.play();
}
}
示例11: startAlert
import java.applet.AudioClip; //导入方法依赖的package包/类
public void startAlert(String alertResourceName) {
AudioClip alertClip = getAlertClip(alertResourceName, true);
if (alertClip == null) {
return;
}
boolean loop = true;
if (!loop) {
alertClip.play();
} else {
alertClip.loop();
}
}
示例12: play
import java.applet.AudioClip; //导入方法依赖的package包/类
public void play() {
final AudioClip clip = (AudioClip) getValue();
if (clip != null) {
clip.play();
}
}
示例13: main
import java.applet.AudioClip; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
URL url=new URL("file:///d:\\bd.mp3");
AudioClip ac=Applet.newAudioClip(url);
ac.play();
}
示例14: AudioClipApp
import java.applet.AudioClip; //导入方法依赖的package包/类
public AudioClipApp(String filename) {
setTitle("AudioClip�̍Đ�");
AudioClip clip = Applet.newAudioClip(getClass().getResource(filename));
clip.play();
}
示例15: run
import java.applet.AudioClip; //导入方法依赖的package包/类
public void run()
{
AudioClip sound = ResourceHandler.getAudioClip("/sounds/misc.wav");
if( sound != null ) sound.play();
miscSoundTimer.schedule(new MiscSoundTask(), (long)(Math.random() * 30 * 60 * 1000));
}