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


Java AudioClip.play方法代码示例

本文整理汇总了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();
}
 
开发者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: 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

示例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";
}
 
开发者ID:bvarner,项目名称:javashare,代码行数:25,代码来源:ApplicationSoundThreadManager.java

示例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";
}
 
开发者ID:bvarner,项目名称:javashare,代码行数:28,代码来源:AppletSoundThreadManager.java

示例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);
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:21,代码来源:SoundManager.java

示例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();
    }
}
 
开发者ID:adbenitez,项目名称:jNotifyOSD,代码行数:13,代码来源:DesktopNotify.java

示例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();
    }
}
 
开发者ID:shashanksingh28,项目名称:code-similarity,代码行数:15,代码来源:SoundAndCursorDemo.java

示例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();
   }
}
 
开发者ID:onikolajev,项目名称:Android-Ebook,代码行数:15,代码来源:SoundAndCursorDemo.java

示例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();
	}
}
 
开发者ID:tolo,项目名称:JServer,代码行数:16,代码来源:SwitchButton.java

示例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();
        }
    }
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:14,代码来源:AlertManager.java

示例12: play

import java.applet.AudioClip; //导入方法依赖的package包/类
public void play() {
  final AudioClip clip = (AudioClip) getValue();
  if (clip != null) {
    clip.play();
  }
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:7,代码来源:SoundConfigurer.java

示例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();
}
 
开发者ID:bdceo,项目名称:bd-codes,代码行数:6,代码来源:Player.java

示例14: AudioClipApp

import java.applet.AudioClip; //导入方法依赖的package包/类
public AudioClipApp(String filename) {
    setTitle("AudioClip�̍Đ�");

    AudioClip clip = Applet.newAudioClip(getClass().getResource(filename));
    clip.play();
}
 
开发者ID:aidiary,项目名称:javagame,代码行数:7,代码来源:AudioClipApp.java

示例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));
}
 
开发者ID:tolo,项目名称:JServer,代码行数:7,代码来源:AdminApp.java


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