Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - metapod

Pages: [1]
Other Support / SoundSystem playbackgroundmusic null pointer
« on: January 31, 2014, 11:05:13 AM »
I'm having a hard time getting started with soundsystem playing an ogg background music file...

Any idea why calling playBGM gives me a null pointer? The file DOES exist. Thanks!

Code: [Select]
public class SoundPlayer {
  private SoundSystem soundSystem;
  public static final String BGM = "BGM";
  public SoundPlayer() {
    try {
      SoundSystemConfig.setCodec("ogg", CodecJOrbis.class);
      SoundSystemConfig.setCodec("wav", CodecWav.class);
    catch(SoundSystemException e)
      System.err.println("error linking with the plug-ins" );
    SoundSystem soundSystem = new SoundSystem();
    soundSystem.setVolume(BGM, 1.0f);
  public void playBGM(String name) {
    File f = new File("res/music/" + name);
    if (!f.exists()) return;

    try {
      URL path = f.toURI().toURL();
      soundSystem.backgroundMusic(BGM, path, name, true);
      soundSystem.setVolume(BGM, 1.0f);
    } catch (MalformedURLException e) {


Pages: [1]