1

I read that Android MediaPlayer supports audio chaining.

I am playing back a sequential midi files and I want there to be no delay between them (continuous playback).

I currently use: setOnCompletionListener

The eclipse emulator does not really have a noticeable lag. But I tried my app on an asus transformer (which is quite fast), but it had a bigger delay. I tried with Android 4.0.3.

Should I use another method to play the next song?

dorien
  • 5,265
  • 10
  • 57
  • 116

2 Answers2

4

The Jelly Bean release notes mention that MediaPlayer now supports an 'Audio Chaining' feature, but don't specify the actual API implementation. That said, if you look at the developer reference on MediaPlayer, you'll notice that there is a new method available as of Android 16 (Jelly Bean) called 'setNextMediaPlayer':

Read About setNextMediaPlayer() Here

I don't know for sure, but I believe this is what the release notes are referring to.

CORRECTION: setNextMediaPlayer is mentioned in the release notes here http://developer.android.com/about/versions/android-4.1.html under the heading 'Gapless Playback'.

newbyca
  • 1,523
  • 2
  • 13
  • 25
3

I think you should try to use the SoundPool class instead of MediaPlayer. Because SoundPool is a light weight object when compared to MediaPlayer Object.

Here is a example of SoundPool,

http://blog.nelsondev.net/?p=207

And it is said that SoundPool are most preferred for small sound files and for faster playing capabilities.

And here is a Article which explains things about MediaPlayer and SoundPool.

http://www.vogella.com/articles/AndroidMedia/article.html

Here is another link for a question based on it,

Soundpool or media player?

Community
  • 1
  • 1
Andro Selva
  • 53,910
  • 52
  • 193
  • 240
  • 1
    Thanks, but I seem to read there is no way to know when the sound finishes playing (as to start the next one): http://stackoverflow.com/questions/4436055/android-soundpool-get-notified-when-end-of-played that's kind of a disadvantage in continuously trying to play sounds – dorien Jul 31 '12 at 14:24