本文整理汇总了Java中org.newdawn.slick.openal.Audio.playAsMusic方法的典型用法代码示例。如果您正苦于以下问题:Java Audio.playAsMusic方法的具体用法?Java Audio.playAsMusic怎么用?Java Audio.playAsMusic使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.newdawn.slick.openal.Audio
的用法示例。
在下文中一共展示了Audio.playAsMusic方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loop
import org.newdawn.slick.openal.Audio; //导入方法依赖的package包/类
/**
* Loops the given audio according to settings.
*
* @param name the music category
*/
public static void loop(String name){
if (FEResources.getAudioVolume() <= 0) return;
if (name.equals(currentName) && current.isPlaying()) return;
current.stop();
currentName = name;
Map<String, ArrayList<String>> songs = loadAudioNames();
try{
String setting = FEResources.getAudioSetting(name.toUpperCase());
if(setting.equals("random")){
Random r = new Random();
setting = name + "_" + songs.get(name).get(r.nextInt(songs.get(name).size()));
if(setting.split("_").length<2)
setting = name;
}
current = AudioLoader.getAudio("WAV",
ResourceLoader.getResourceAsStream("res/music/"+setting+".wav"));
current.playAsMusic(1.0f, FEResources.getAudioVolume(), true);
} catch (Exception e){
e.printStackTrace();
System.err.println("Warn: Bad sound configuration: "+name);
try{
Audio b = AudioLoader.getAudio("WAV",
ResourceLoader.getResourceAsStream("res/music/"+name+".wav"));
b.playAsMusic(1.0f, FEResources.getAudioVolume(), true);
}catch(Exception f){}
}
}
示例2: loop
import org.newdawn.slick.openal.Audio; //导入方法依赖的package包/类
public static void loop(String name){
if(!enabled) return;
if(name.equals(current)) return;
try {
current = name;
Audio a = AudioLoader.getStreamingAudio("OGG",
ResourceLoader.getResource("res/music/"+name+".ogg"));
a.playAsMusic(1, 1, true);
} catch (IOException e) {
e.printStackTrace();
}
}
示例3: restart
import org.newdawn.slick.openal.Audio; //导入方法依赖的package包/类
public static void restart(){
if(!enabled) return;
try {
Audio a = AudioLoader.getStreamingAudio("OGG",
ResourceLoader.getResource("res/music/"+current+".ogg"));
a.playAsMusic(1, 1, true);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}