AudioTrack: play() called on uninitialized AudioTrack

后端 未结 2 483
鱼传尺愫
鱼传尺愫 2020-12-19 03:03

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.

相关标签:
2条回答
  • 2020-12-19 03:42

    Why you have commented out your stopPlaying() method?

    You can only create 32 AudioTracks. If you want more you should call release() method.

    0 讨论(0)
  • 2020-12-19 03:46

    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.

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