Audio Crossfading in Android

怎甘沉沦 提交于 2019-12-21 16:51:22

问题


I am develping a media player for my learning purpose and I want to have crossfading feature in media player app. But I don't have clue where to start from. i tried searching on inernet but no luck. I am using Android MediaPlayer class for all media player related operation. Anyone know any workaround to achieve the same.

thanks for your support


回答1:


Try to use the AudioTrack instead of MediaPlayer. Generally, I'd suggest the following plan:

  • Learn some sources for an app that uses AudioTrack. A good player can be found here

This is an aac audio player that uses JNI for aac-audio decoding.

  • Find a MP3 decoding library. The library should be a Java one (look at this for example, or it is possible there are another libraries (I did not use such java libraries)) or a C/C++ library (in this case you also will use it through JNI).
  • When you will get simple working MP3 player, add manual crossfading (this should be easy, if you aware of basics of digital audio).



回答2:


Try to use two objects of MediaPlayer one after another with crossfade, like in this class https://github.com/psaravan/JamsMusicPlayer/blob/f165057dd664727ed06b9fac2c27557e5fb7e7ee/jamsMusicPlayer/src/main/java/com/jams/music/player/Services/AudioPlaybackService.java




回答3:


When second mediaPlayer stars first pauses for while (On some devices mostly on samsung )so transition is not smooth. MediaPlayer has this issue and its been reported to google since long ago but still not resolved(https://issuetracker.google.com/issues/36931073) so we can do nothing about it. So I used Exoplayer for playing audio and it works very smoothly without any pause.



来源:https://stackoverflow.com/questions/6661596/audio-crossfading-in-android

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