Added is playing method

This commit is contained in:
Ziver Koc 2007-04-23 14:12:36 +00:00
parent 938c098161
commit 4f2ed0cb0d
2 changed files with 21 additions and 0 deletions

View file

@ -2,6 +2,8 @@ package ei.engine.sound;
import java.awt.Rectangle; import java.awt.Rectangle;
import org.lwjgl.openal.AL10;
import ei.engine.math.Vector3f; import ei.engine.math.Vector3f;
import ei.engine.scene.Entity; import ei.engine.scene.Entity;
import ei.engine.texture.Texture; import ei.engine.texture.Texture;
@ -108,5 +110,12 @@ public class Sound extends Entity{
public Texture getTexture() { public Texture getTexture() {
return null; return null;
} }
public boolean isPlaying(){
if(SoundManager.getInstnace().getSoundState(this) == AL10.AL_PLAYING){
return true;
}
return false;
}
} }

View file

@ -154,6 +154,18 @@ public class SoundManager {
return source; return source;
} }
/**
* Returns the state of the sound class
* @param sound The sound to get state of
* @return The state of the sound
*/
public int getSoundState(Sound sound){
if(sound.getSourceId() >= 0 && sources.get(sound.getSourceId()).soundId == sound.getSoundId()){
AL10.alGetSourcei(sources.get(sound.getSourceId()).source, AL10.AL_SOURCE_STATE);
}
return -1;
}
/** /**
* Stops playing a sound * Stops playing a sound
* *