Is it better to choose SoundPool or MediaPlayer in Android?

I am currently trying to create an application that has buttons that launch audio files, but those audio files are selected by the user through a file browser activity. I've heard that MediaPlayer has latency issues etc, but SoundPool has memory limits?

Also, can I let the user install the audio file by returning the string from the file browser (the selected item) and use that for the audio API path that ever was?

+3


source to share


2 answers


SoundPool

runs faster if you are trying to play already downloaded files. as it takes longer to download files and the file should be smaller for better performance.



But in your case, the user selects the files to play from FileBrowser

and the file size will be different, so the download times. Use instead MediaPlayer

.

+2


source


SoundPool

faster than MediaPlayer

, but has its own limitations.

SoundPool

used for small sounds like the ones you can use in your method onClick()

so that it can create a click sound every time the user clicks on it because these files are preloaded into memory, t let the processor suffer for its actions, and therefore SoundPool

faster than MediaPlayer

. In addition, it can control the number of audio streams displayed at once.



MediaPlayer

used for cases where the user has access to playback options such as play, pause, search, start, etc. It is also usually MediaPlayer

good for long audio lengths, since you cannot load long audio lengths into memory in advance. You can also use MediaPlayer

to play audio over the Internet (would be helpful if you plan on doing this for a future release).

And in your case, the user is allowed to play audio from the file browser activity, I suggest you go to MediaPlayer

.

+1


source







All Articles