Error waited 5000ms



  • edited May 2017

    Hey there again :)

    I just (finally) just tried to load sound files before I need them but there are some problems. Well, one actually ^^

    I have to create my variables like this at the beginning SamplePlayer music1

    and when I need them I do

          music1 = new SamplePlayer(ac, new Sample(sketchPath("")));
        catch(Exception e)

    It works but the problem is to stop them, because in my program check when I am in the menu (for example) the music I need and thus the one I need to pause.

     if (/*condition*/)

    So i get a NullPointerException, wich is normal because the music is load after :/

  • Maybe that's because you're using exit(). Perhaps System.exit(-1) may work? (-1 to indicate error)

  • No, there are no issues with the try/catch, only with the ìf()`wich have to occur before the try/catch but gives me a NullPointerException

  • Of course it will. You're putting it before the try/catch, which probably means that the music file never got loaded. You should load all files in setup if possible (I'm missing something here, right?)

  • edited May 2017

    Loading the files in my setup will cause my first problem, which was the time to load all my files :/

    And yes I know it was stupid to use them before loading them, but I actually don't have the choice ^^

  • edited May 2017

    Please format the code by editing your original post:


    it was stupid to use them before loading them, but I actually don't have the choice

    You definitely always have a choice. For example, you could:

    1. set boolean musicLoaded -- initially false, and true once you load your sample -- and only execute your control code (e.g. in your menu) if musicLoaded==true -- otherwise, disable those controls.
    2. create a dummy SamplePlayer that you assign during setup music1 = new SamplePlayer(ac, new Sample(sketchPath("zero-second-recording.mp3"))); When you are ready to load something, replace it.

    There are more options -- those are just two of them.

  • Thanks :)

    I knew there was possibilities but I couldn't figure them out, the first one won't work for reasons but the second seems pretty interesting. I'm trying it right now

Sign In or Register to comment.