Not able to achieve Gapless audio looping so far on Android

后端 未结 9 1896
走了就别回头了
走了就别回头了 2020-11-28 06:05

I have tried almost every method but I\'ve failed to achieve gapless audio playback between looping a single track with a duration of 10-15 seconds.

Steps I\'ve trie

9条回答
  •  暖寄归人
    2020-11-28 06:33

    I suggest you to use SoundPool API instead of MediaPlayer.

    From the official documentation:

    The SoundPool class manages and plays audio resources for applications.

    ...

    Sounds can be looped by setting a non-zero loop value. A value of -1 causes the sound to loop forever. In this case, the application must explicitly call the stop() function to stop the sound. Any other non-zero value will cause the sound to repeat the specified number of times, e.g. a value of 3 causes the sound to play a total of 4 times.

    ...

    Take a look here for a practical example of how to use SoundPool.

提交回复
热议问题