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


Java SoundStore类代码示例

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


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

示例1: Music

import org.newdawn.slick.openal.SoundStore; //导入依赖的package包/类
/**
 * Create and load a piece of music (either OGG or MOD/XM)
 * @param in The stream to read the music from 
 * @param ref  The symbolic name of this music 
 * @throws SlickException Indicates a failure to read the music from the stream
 */
public Music(InputStream in, String ref) throws SlickException {
	SoundStore.get().init();
	
	try {
		if (ref.toLowerCase().endsWith(".ogg")) {
			sound = SoundStore.get().getOgg(in);
		} else if (ref.toLowerCase().endsWith(".wav")) {
			sound = SoundStore.get().getWAV(in);
		} else if (ref.toLowerCase().endsWith(".xm") || ref.toLowerCase().endsWith(".mod")) {
			sound = SoundStore.get().getMOD(in);
		} else if (ref.toLowerCase().endsWith(".aif") || ref.toLowerCase().endsWith(".aiff")) {
			sound = SoundStore.get().getAIF(in);
		} else {
			throw new SlickException("Only .xm, .mod, .ogg, and .aif/f are currently supported.");
		}
	} catch (Exception e) {
		Log.error(e);
		throw new SlickException("Failed to load music: "+ref);
	}
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:27,代码来源:Music.java

示例2: Sound

import org.newdawn.slick.openal.SoundStore; //导入依赖的package包/类
/**
 * Create a new Sound 
 * 
 * @param in The location of the OGG or MOD/XM to load
 * @param ref The name to associate this stream
 * @throws SlickException Indicates a failure to load the sound effect
 */
public Sound(InputStream in, String ref) throws SlickException {
	SoundStore.get().init();
	
	try {
		if (ref.toLowerCase().endsWith(".ogg")) {
			sound = SoundStore.get().getOgg(in);
		} else if (ref.toLowerCase().endsWith(".wav")) {
			sound = SoundStore.get().getWAV(in);
		} else if (ref.toLowerCase().endsWith(".aif")) {
			sound = SoundStore.get().getAIF(in);
		} else if (ref.toLowerCase().endsWith(".xm") || ref.toLowerCase().endsWith(".mod")) {
			sound = SoundStore.get().getMOD(in);
		} else {
			throw new SlickException("Only .xm, .mod, .aif, .wav and .ogg are currently supported.");
		}
	} catch (Exception e) {
		Log.error(e);
		throw new SlickException("Failed to load sound: "+ref);
	}
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:28,代码来源:Sound.java

示例3: init

import org.newdawn.slick.openal.SoundStore; //导入依赖的package包/类
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
	SoundStore.get().setMaxSources(32);
	
	myContainer = container;
	sound = new Sound("testdata/restart.ogg");
	charlie = new Sound("testdata/cbrown01.wav");
	try {
		engine = AudioLoader.getAudio("WAV", ResourceLoader.getResourceAsStream("testdata/engine.wav"));
	} catch (IOException e) {
		throw new SlickException("Failed to load engine", e);
	}
	music = musica = new Music("testdata/SMB-X.XM");
	//music = musica = new Music("testdata/theme.ogg", true);
	musicb = new Music("testdata/kirby.ogg", true);
	burp = new Sound("testdata/burp.aif");
	
	music.play();
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:22,代码来源:SoundTest.java

示例4: poll

import org.newdawn.slick.openal.SoundStore; //导入依赖的package包/类
/**
 * Poll the state of the current music. This causes streaming music
 * to stream and checks listeners. Note that if you're using a game container
 * this will be auto-magically called for you.
 * 
 * @param delta The amount of time since last poll
 */
public static void poll(int delta) {
	synchronized (musicLock) {
		if (currentMusic != null) {
			SoundStore.get().poll(delta);
			if (!SoundStore.get().isMusicPlaying()) {
				if (!currentMusic.positioning) {
					Music oldMusic = currentMusic;
					currentMusic = null;
					oldMusic.fireMusicEnded();
				}
			} else {
				currentMusic.update(delta);
			}
		}
	}
}
 
开发者ID:yugecin,项目名称:opsu-dance,代码行数:24,代码来源:Music.java

示例5: Music

import org.newdawn.slick.openal.SoundStore; //导入依赖的package包/类
/**
 * Create and load a piece of music (either OGG or MOD/XM)
 * 
 * @param url The location of the music
 * @param streamingHint A hint to indicate whether streaming should be used if possible
 * @throws SlickException
 */
public Music(URL url, boolean streamingHint) throws SlickException {
	SoundStore.get().init();
	String ref = url.getFile();
	
	try {
		if (ref.toLowerCase().endsWith(".ogg")) {
			if (streamingHint) {
				sound = SoundStore.get().getOggStream(url);
			} else {
				sound = SoundStore.get().getOgg(url.openStream());
			}
		} else if (ref.toLowerCase().endsWith(".wav")) {
			sound = SoundStore.get().getWAV(url.openStream());
		} else if (ref.toLowerCase().endsWith(".xm") || ref.toLowerCase().endsWith(".mod")) {
			sound = SoundStore.get().getMOD(url.openStream());
		} else if (ref.toLowerCase().endsWith(".aif") || ref.toLowerCase().endsWith(".aiff")) {
			sound = SoundStore.get().getAIF(url.openStream());
		} else {
			throw new SlickException("Only .xm, .mod, .ogg, and .aif/f are currently supported.");
		}
	} catch (Exception e) {
		Log.error(e);
		throw new SlickException("Failed to load sound: "+url);
	}
}
 
开发者ID:CyboticCatfish,项目名称:code404,代码行数:33,代码来源:Music.java

示例6: Sound

import org.newdawn.slick.openal.SoundStore; //导入依赖的package包/类
/**
 * Create a new Sound 
 * 
 * @param url The location of the OGG or MOD/XM to load
 * @throws SlickException Indicates a failure to load the sound effect
 */
public Sound(URL url) throws SlickException {
	SoundStore.get().init();
	String ref = url.getFile();
	
	try {
		if (ref.toLowerCase().endsWith(".ogg")) {
			sound = SoundStore.get().getOgg(url.openStream());
		} else if (ref.toLowerCase().endsWith(".wav")) {
			sound = SoundStore.get().getWAV(url.openStream());
		} else if (ref.toLowerCase().endsWith(".aif")) {
			sound = SoundStore.get().getAIF(url.openStream());
		} else if (ref.toLowerCase().endsWith(".xm") || ref.toLowerCase().endsWith(".mod")) {
			sound = SoundStore.get().getMOD(url.openStream());
		} else {
			throw new SlickException("Only .xm, .mod, .aif, .wav and .ogg are currently supported.");
		}
	} catch (Exception e) {
		Log.error(e);
		throw new SlickException("Failed to load sound: "+ref);
	}
}
 
开发者ID:CyboticCatfish,项目名称:code404,代码行数:28,代码来源:Sound.java

示例7: loadSound

import org.newdawn.slick.openal.SoundStore; //导入依赖的package包/类
public static AudioData loadSound(URL url) throws SlickException {
SoundStore.get().init();
String ref = url.getFile();
Audio audio = null;
try {
    if (ref.toLowerCase().endsWith(".ogg")) {
	audio = SoundStore.get().getOgg(url.openStream());
    } else if (ref.toLowerCase().endsWith(".wav")) {
	audio = SoundStore.get().getWAV(url.openStream());
    } else if (ref.toLowerCase().endsWith(".aif")) {
	audio = SoundStore.get().getAIF(url.openStream());
    } else if (ref.toLowerCase().endsWith(".xm") || ref.toLowerCase().endsWith(".mod")) {
	throw new SlickException("Use XStream for streaming .xm and .mod sounds");
    } else {
	throw new SlickException("Only .xm, .mod, .aif, .wav and .ogg are currently supported.");
    }
} catch (Exception e) {
    Log.error(e);
    throw new SlickException("Failed to load sound: " + ref, e);
}
return new AudioData(audio.getBufferID());
   }
 
开发者ID:Cr0s,项目名称:JavaRA,代码行数:23,代码来源:Soundly.java

示例8: VisorOpenGl

import org.newdawn.slick.openal.SoundStore; //导入依赖的package包/类
/**
 * Inicia el Visor OpenGL indicando la instancia de partido, las dimensiones
 * de la pantalla (sx,sy), si Se ejecuta en pantalla completa(fullscreen), e
 * indicando la instancia del jframe Principal(dejar nulo)
 * 
 * @param partido
 * @param sx
 * @param sy
 * @param fullscreen
 * @param principal
 * @throws SlickException
 */
public VisorOpenGl(Partido partido, int sx, int sy, boolean fullscreen,
		PrincipalFrame principal) throws SlickException {
	this.partido = partido;
	this.sx = sx;
	this.sy = sy;
	this.dxsaque = (sx + 300 * 2) / 75;
	sx2 = sx / 2;
	sy2 = sy / 2;
	this.principal = principal;
	AppGameContainer container = new AppGameContainer(this);
	container.setForceExit(false);
	container.setDisplayMode(sx, sy, fullscreen);
	container.start();
	SoundStore.get().clear();
	InternalTextureLoader.get().clear();
}
 
开发者ID:alfonsodou,项目名称:javaleagueframework,代码行数:29,代码来源:VisorOpenGl.java

示例9: clear

import org.newdawn.slick.openal.SoundStore; //导入依赖的package包/类
/** 
    * Clears the sound engine (stopping all managed sounds, clearing all 
    * sources) and clears Slick's SoundStore. Both SoundManager and SoundStore
    * will expect an init() call after this.
    * 
    * 
    */
   public void clear() {
//stop the sources
for (int i=0; i<sources.length; i++) {
    if (sources[i]!=null) {
	sources[i].stop();
	sources[i].clearSource();
    }
}
//clear the sound store
SoundStore.get().clear();
//delete the sources array
queue = null;
sources = null;
inited = false;
   }
 
开发者ID:Cr0s,项目名称:JavaRA,代码行数:23,代码来源:Soundly.java

示例10: XStreamingSound

import org.newdawn.slick.openal.SoundStore; //导入依赖的package包/类
/** Only OGG streams and MOD sounds are currently accepted. */
public XStreamingSound(String ref, String description) throws SlickException {
    super(new AudioData(), description);
    SoundStore.get().init();
    this.ref = ref;
    try {
        if (ref.toLowerCase().endsWith(".ogg")) {
            streamPlayer = new XOpenALStreamPlayer(source, ref);
        } else if (ref.toLowerCase().endsWith(".xm") || ref.toLowerCase().endsWith(".mod")) {
            if (SoundStore.get().isDeferredLoading())
                Log.warn("Deferred loading for MOD is not supported; loading immediately");
            modPlayer = new OpenALMODPlayer();
            module = OpenALMODPlayer.loadModule(ResourceLoader.getResourceAsStream(ref));
        } else {
            throw new SlickException("not a valid stream format, must be: .xm, .mod or .ogg");
        }
    } catch (IOException e) {
        Log.error(e);
        throw new SlickException("Failed to load sound: " + ref, e);
    }
}
 
开发者ID:Cr0s,项目名称:JavaRA,代码行数:22,代码来源:XStreamingSound.java


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