title: Play Audio (mp3, ogg) from sd card with AudioTrack
body: <p>I want to play audio file from SD card with AudioTrack. I've tried with this code: </p>
  
  <pre><code>int minBufferSize = AudioTrack.getMinBufferSize(8000,
                  AudioFormat.CHANNEL_CONFIGURATION_MONO,
                  AudioFormat.ENCODING_PCM_16BIT);
          int bufferSize = 512;
          AudioTrack at = new AudioTrack(AudioManager.STREAM_MUSIC, 8000,
                  AudioFormat.CHANNEL_CONFIGURATION_MONO,
                  AudioFormat.ENCODING_PCM_16BIT, minBufferSize,
                  AudioTrack.MODE_STREAM);
  
          int i = 0;
          byte[] s = new byte[bufferSize];
  
          FileInputStream fin = new FileInputStream(path);
          DataInputStream dis = new DataInputStream(fin);
  
          at.play();
          while ((i = dis.read(s, 0, bufferSize)) &gt; -1)
          {
              at.write(s, 0, i);
  
          }
          at.stop();
          at.release();
          dis.close();
          fin.close();
  </code></pre>
  
  <p>But it doesn't play audio file properly. Instead of original audio it plays some kind noise sound.</p>