×

Discussion Board

Results 1 to 2 of 2

Hybrid View

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    47

    sound freezes the program

    HI

    i have a game program working on... just add the sounds but the program freezes after some time..... here is the code i am using to initialize the sound and calling it



    tune = this.getClass().getResourceAsStream("/Dragon1/res/scn/punch2.wav"
    buffer2 = new byte[8000];
    tune.read(buffer2, 0, buffer2.length);
    sound2 = new Sound(buffer2, Sound.FORMAT_WAV);
    sound2.init(buffer2, Sound.FORMAT_WAV);



    later when i call it i use the code


    if(sound2.getState() == Sound.SOUND_STOPPED)
    {
    sound2.play(1);
    }


    some time it freezes the program in the first call and other times it freezes the program after some time playing sounds OKey.


    Also as you can see that i have just loaded the sound once in the program and calling it againa again in the program. do i have to initialze or load sound again and again every time i want to play it

    pls help

    Shahzad

  2. #2
    Regular Contributor
    Join Date
    Mar 2003
    Location
    Tampere / Finland
    Posts
    201

    RE: sound freezes the program

    Hello,

    It's not necessary to initialize and play again and again. Would you try to set the buffer biger, it will help play the sound smoothly.

    Regards,
    Kui

Posting Permissions

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