Android AudioTrack playing .wav file, getting only white noise

前端 未结 3 1649
渐次进展
渐次进展 2020-11-30 07:08

When I play a file with the following code:

private void PlayAudioFileViaAudioTrack(int ResId) throws IOException {

    int intSize = android.media.AudioT         


        
3条回答
  •  难免孤独
    2020-11-30 07:42

    That looks WAY more complicated than what I did. I played sounds using this. I think .wav files would work just as well.

    MediaPlayer mpPlayProgram = new MediaPlayer();
    mpPlayProgram.setDataSource("/sdcard/file.mp3");
    mpPlayProgram.prepare();
    mpPlayProgram.start();
    mpPlayProgram.release();
    

    For static resources, it's even easier:

    MediaPlayer mpStart = MediaPlayer.create(this, resID);
    mpStart.start();
    mpStart.release();
    

提交回复
热议问题