The sound pool does not finish playing the entire file

I have two problems that I would like to understand.

I use soundPool for my sound effects and it works without problems. However, when I try to play the cetain file (25 seconds, about 400K), it does not play the whole file for only 3-4 seconds.

Why and how can I fix it?

and second question: should I play every effect from the stream? are many topics good?

this is the current code:

 static void play(final int soundID ){ if(loaded){ handler.post(new Runnable() { public void run() { soundpool.play(soundID, 1, 1, 1, 0, 1); } }); 
+4
source share
1 answer

I understand that SoundPool cannot be used for sounds longer than a few seconds or audio files> 1 MB. Use MediaPlayer in these cases.

Use either for each sound reproduction:

 MediaPlayer.create(YourActivity.this, R.raw.your_sound).start(); 

or create a MediaPlayer object, play the same sound as many times as necessary, and then release() object.

+5
source

Source: https://habr.com/ru/post/1486125/


All Articles