Stop a sound using the same button that plays it

前端 未结 1 1106
不知归路
不知归路 2020-12-18 08:44

Pretty simple, I\'m using one button that generates a random number and then with a switch/case, it animates an image and plays a sound. My problem is that when you press th

相关标签:
1条回答
  • 2020-12-18 09:05

    I just dicovered the answer to my own question.

    What I did was

    1. Declare SoundSystemID soundID; in the header.
    2. Add this line before the random number gets generated: AudioServicesDisposeSystemSoundID(soundID);

    Remember that if you are going to play the sound again, you will need to load the resource again after disposing of it.

    Thank you guys, anyway.

    0 讨论(0)
提交回复
热议问题