Audio Playback Rate in Android

核能气质少年 提交于 2019-12-23 05:59:39

问题


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.


回答1:


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...




回答2:


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.



来源:https://stackoverflow.com/questions/3057728/audio-playback-rate-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!