Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User creepymo's Avatar
    Join Date
    Jun 2005
    Posts
    38
    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

  2. #2
    Registered User creepymo's Avatar
    Join Date
    Jun 2005
    Posts
    38
    Ok, i've done some reading up and more debugging and I'm pretty sure that the Sound.play() is not updating the state of the sound. I've put breakpoints in the soundStateChanged() interface method and caught it when the event is both 0 and 1 (0 is playing, 1 is stopped). The two threads were the one game thread telling the sound to play, then you get the system thread which calls the function after the sound plays with 1 for off. The thing is, even after the sound.play() is called and this method is called with the 0 event, the state is always 1. It's like once it gets changed after stopping the first time it never gets its state set back to 0. Anyone else have any problems like this?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved