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]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en