×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    5

    Unhappy strange result with Nokia UI API (sound)

    Dear all,

    I am a new to J2ME programming. I am working on a midp 1.0 + Nokia UI API (sound) to play a few notes on my 7210 phone. When a key is pressed, it will generate a short sound clip. However, if a same key is pressed twice and the first sound clip is not finish playing. That particular sound clip will no be able to play again, even if a key is press again.

    Can someone help me?

    Elton

  2. #2
    Registered User
    Join Date
    Nov 2003
    Location
    Switzerland
    Posts
    34
    do you use tones, and if so do you use sound.init() before you play sound? this might solve 50% of your problem

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    5
    thanks for you reply. Do you mean I should run sound.init() everytime i play a sound? I think I did that, but I didn't know if I have did it in a correct way.

    Sound SoundObj;

    for(int i = 0 ; i < sound.length ; i+=2){
    SoundObj.init(sound[i] , sound[i + 1]);
    SoundObj.play(1);
    Thread.sleep(sound[i + 1]);
    }

    Here is what I used. Can you tell me if I do it correctly?

    Thanks again.

  4. #4
    Registered User
    Join Date
    Nov 2003
    Location
    Switzerland
    Posts
    34
    you shouldnt be doing that in a loop, you should do it on events, like it is now it will give IndexOutOfBoundsException.

    besides your sound buffer, where do you load it?

    look in sample of SDK, theres code there that works

  5. #5
    Registered User
    Join Date
    Jan 2005
    Posts
    5
    The reason I use the for loop is , the SoundObj has more than one music note. I put each note's frequency and its length in an array in SoundObj. And the for loop play the note one after one.

    Is it the right way to do it? mind to show me some sample code? Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×