-
Notifications
You must be signed in to change notification settings - Fork 23
How to play sounds
Samuel Gélineau edited this page Aug 22, 2015
·
1 revision
Place your sound files in the src/main/resources/resources/sounds
folder.
import org.newdawn.slick.util.ResourceLoader
import org.newdawn.slick.openal.{SoundStore, AudioLoader}
import com.github.dunnololda.scage.ScageLib.ScageScreenApp
object Main extends ScageScreenApp("Music demo", 640, 480)
{
val oggStream = AudioLoader.getStreamingAudio("OGG", ResourceLoader.getResource("resources/sounds/badapple.ogg"))
init {
// there is also playAsSoundEffect(float pitch, float gain, boolean loop)
oggStream.playAsMusic(1.0f, 1.0f, true)
}
action {
// otherwise the music stops after one second
SoundStore.get().poll(0)
}
}