Hello there. I'm having a strange problem with Nokia's Sound class (I'm using Series 60 MIDP Concept SDK Beta 0.3.1). I'm working on the title screen for a game, and what I'm trying to do is manually loop the 15 second title song with a short delay by using a frame counter and checking the state of the playing sound. I've inherited most of this code, but the sound is loaded as such:
static Hashtable m_sounds = new Hashtable();
static public void load_sound( String name, String path ) {
byte[] data = load_resource( path );
Sound sound = new Sound( data, 1 );
m_sounds.put( name, sound );
}
At this point only the title music is ever loaded. When the title screen appears, the sound is played:
...
Sound sound = (Sound)m_sounds.get( name );
sound.play(1);
...
Then during the main menu loop, I check each frame for the status of this sound using similar code and the
sound.getState() == Sound.SOUND_PLAYING
code.
During the first loop of the menu all seems fine. However, once the song stops playing the issues pop up. The song stops, the counter goes into effect to put a 20 frame delay or so, then starts the song up again. However, from this point on every time the state of the sound is checked it says it's SOUND_STOPPED, thus causing the title song to be started after every 20 frame delay. It sounds like it’s hiccupping, and if I take the delay away it goes quiet after a couple seconds of static type noise. It's like after the tune stops playing the first time the sound class fails to update the state of the sound properly. I've tried debugging but can't get seem to figure out where exactly it's failing. I actually tried putting breakpoints in the soundStateChanged() interface but that only seems to make things more confusing. Once it hits a break point another thread has been generated and keeps running. In fact, if I ever put a conditional breakpoint around the state returned it'll just start creating thread after thread after thread. I'm not sure how much the thread factor is involved but it does seem to act strange. Has anyone else had any issues with the state not being properly setup by the class code? Any help would be great. I know I can just play the song in a loop instead of once, but I might need to do this trick somewhere else and want to figure out what's going on. Thank you. I hope this all made sense.
Mike

Reply With Quote

