I\'m experimenting with AudioTrack class. Basically, my app has to generate a sound when the user touches a specific object on screen. I\'ve used this example as a guide.
Why you have commented out your stopPlaying() method?
You can only create 32 AudioTracks. If you want more you should call release() method.
I would think that you need to call play()
before you call write()
.
But I've also noticed that when you create lots of AudioTrack
instances even if you think you're cleaning everything up write, sometimes a play()
fails to work, and the track is uninitialized.
You will want to try...catch this IllegalStateException
, and avoiding calling write()
until play()
works without throwing an exception.