當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。