AudioTrack Android playing sounds from raw folder

前端 未结 2 1784
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-18 04:23

Is it possible to play wav files with AudioTrack from the resources folder raw? It tried many ways to reference the raw files in my Android project, but I got a

相关标签:
2条回答
  • 2020-12-18 04:48

    Everything is fine with your code, You just need to change

    while((i = inputStream.read()) != -1) 
    

    to

    while((i = inputStream.read(buffer)) != -1)
    
    0 讨论(0)
  • 2020-12-18 05:08

    ... and you should place the audioTrack-play-call after writing PCM content into buffer ;)

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