Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sound pool not finish playing entire file

I have two issues I would like understand.

I am using soundPool for my sound effects and its working with no problem. However, when I try to play cetain file (25 sec , about 400K) it doesn't play the whole file only 3-4 seconds from it .

Why and how can I fix it ?

and the second question is, should I play each effect from thread ? many threads are 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);
        }
        });
like image 720
Jesus Dimrix Avatar asked Jun 13 '13 22:06

Jesus Dimrix


1 Answers

My understanding is that SoundPool cannot be used for sounds longer than several seconds or audio files >1MB. Use MediaPlayer in those cases.

Either use this for each play of a sound:

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

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

like image 135
Voicu Avatar answered Sep 28 '22 09:09

Voicu