I'm trying to make some music play which obviously means it has to be started only once then play for a while. However, the command I'm using seems to react differently from how I found it should work. Here's my code:
The part that doesn't work seems to be music.isPlaying(). Which should return true if the music is allready started. However it seems to be working differently seen i constantly get the 'no music' output. Please your oppinion on this guys.
1 2 3 4 5 6 7 8 9 10 | GreenfootSound music = new GreenfootSound( "music.wav" ); if (music.isPlaying()) {System.out.println( "music" );} //if music is allready playing then do nothing else if (!(music.isPlaying())) { music.play(); System.out.println( "no music" ); } |