0

So, I know that this has been done with a few Android apps before, but I cannot for the life of me figure out how, since it's not currently possible through the API.

How does one adjust the playback rate of a sound played through MediaPlayer; either with or without adjusting the pitch is fine for now, though the latter is definitely preferred. If someone can point me in the direction of an open source app that I can use as guidance, that would also be fine.

Thanks in advance.

Marquis
  • 31
  • 2
  • 5

2 Answers2

0

ExoPlayer from version 2.4 has support playback speed adjustment back to Android Jelly Bean (API level 16). I am using it in my app with another very useful feature - seamlessly loop audio.

Wrobel
  • 1,042
  • 12
  • 21
0

Looks like AudioTrack.setPlaybackRate should do the trick.

Setting it to half the sample rate of the content will cause the playback to last twice as long, but will also result in a negative pitch shift.

Not sure if you can get a AudioTrack from MediaPlayer...

idbrii
  • 10,975
  • 5
  • 66
  • 107