How to loop a sound without gaps in Android?

前端 未结 4 559
既然无缘
既然无缘 2020-12-06 04:46

I want to loop a sound without gaps in android. I tried to use the code mediaplayer.setLooping(true) to loop the sound, but there is always a little pause when

相关标签:
4条回答
  • 2020-12-06 04:57

    Try using the .ogg file format for the sound files in your application. I had this same issue, and after a lot of research , i tried the .ogg format and it loops without any gaps in android.

    Info about .ogg format: http://en.wikipedia.org/wiki/.ogg

    You can easily convert your sound file from .mp3 or what have you, to .ogg using the popular open source app VLC Media Player.

    0 讨论(0)
  • 2020-12-06 05:09

    this is a bug in the android operating system :( http://code.google.com/p/android/issues/detail?id=18756

    0 讨论(0)
  • 2020-12-06 05:19

    It usually works just fine, unless you have a really slow phone.

    I would double check the sound file with an audio editor like Audacity, to verify that it doesn't have any silence at the beginning or end of the file.

    0 讨论(0)
  • 2020-12-06 05:20

    Also worth noting is that gapless playback was added with Jelly Bean (API level 16). It allows you to set a secondary mediaplayer that should be used for playing a next audio stream, as long as the primary player hasn't finished playing the current audio yet. This could potentially be used to create a gapless 'loop' too.

    public void setNextMediaPlayer (MediaPlayer next)

    Obviously this won't be of much help for most of the market (currently < 3% of the devices is running JB), but nevertheless worth mentioning.

    0 讨论(0)
提交回复
热议问题