I had the same problem. All my sounds were in .mp3 and they didn't play in
2.0.
I had to reencode them in .ogg and everything started working again. But
then I had a
problem with one of the longer sounds (7 secs). Only 6 seconds were loaded,
because
there was some stack overflow at the end of the loading. I had to remove the
stereo and encode it as a mono. It worked well.


On Tue, Nov 10, 2009 at 6:17 PM, ayanir <[email protected]> wrote:

> Hello,
>
> I'm using a SoundPool for playing my game sound effects.
> It all worked fine until I checked it on the new SDK 2.0.
> the sounds are not played and I'm getting in my log:
> "SoundPool Sample channel count (0) out of range"
> right after the playerPool.load (see the code).
>
> does any one encountered with this problem?
> here is my code:
>
> package j2ab.android.rpcapp.utils;
>
> import android.content.Context;
> import android.media.AudioManager;
> import android.media.SoundPool;
>
> import j2ab.android.rpcapp.R;
>
> public class SoundManager
> {
>        private static boolean isSoundEnabled = true;
>
>        private static final int[] PLAYERS_RES_IDS = {R.raw.snd1,
> R.raw.snd2,R.raw.snd3};
>
>        /**
>         * Player priority in case of ONE_PLAYER. the highest priority is 0.
>         */
>        private static final int[] PLAYERS_PRIORITY = {1, 1, 1};
>
>        private int[] idToStream;
>
>        private SoundPool playerPool;
>
>        public SoundManager(Context context, int maxStreams) {
>
>                playerPool = new SoundPool(maxStreams,
> AudioManager.STREAM_MUSIC,
> 0);
>                idToStream = new int[PLAYERS_RES_IDS.length];
>
>                for (int i = 0; i < idToStream.length; i++){
>                        idToStream[i] = playerPool.load(context,
> PLAYERS_RES_IDS[i],
> PLAYERS_PRIORITY[i]);
>                }
>        }
>
>        public int play(int playerId, boolean interrupt) {
>                if(isSoundEnabled){
>                        int status = playerPool.play(idToStream[playerId],
> 0.99f, 0.99f, 0,
> 0, 1);
>                        if(status == 0)
>                                MyLog.printLog("", "cant play a sound
> !!!!!!!! " + playerId);
>                        return status;
>                }
>                return 0;
>        }
>
>        public void stopPlayer(int playerId, boolean resetMediaTime) {
>                if(resetMediaTime){
>                        playerPool.stop(idToStream[playerId]);
>                }
>                else{
>                        playerPool.pause(idToStream[playerId]);
>                }
>        }
>
>        public void onDispose() {
>                playerPool.release();
>        }
> }
>
> BTW
> the emulator managed to play sound using MediaPlayer, but I don't want
> to use a low level sound management.
>
>
> Tanks
> Yanir
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to