Using AudioTrack in Android to play a WAV file

后端 未结 7 968
别跟我提以往
别跟我提以往 2020-12-01 05:50

I\'m working with Android, trying to make my AudioTrack application play a Windows .wav file (Tada.wav). Frankly, it shouldn\'t be this hard, but I\'m hearing a lot of stra

7条回答
  •  温柔的废话
    2020-12-01 06:03

    Just confirm if you have AudioTrack.MODE_STREAM and not AudioTrack.MODE_STATIC in the AudioTrack constructor:

    AudioTrack at = new AudioTrack(
      AudioManager.STREAM_MUSIC,
      sampleRate,
      AudioFormat.CHANNEL_IN_STEREO,
      AudioFormat.ENCODING_PCM_16BIT,
      // buffer length in bytes
      outputBufferSize,
      AudioTrack.MODE_STREAM
    );
    

提交回复
热议问题