I am developing a game and playing audio sounds using SoundPool and MediaPlayer. Every time when any audio sound plays, it shows error in LogCat.
public class MusicSoundResources {
private static final String CLASS_TAG = "SoundResources";
private static MusicSoundResources _instance;
public static HashMap<String, MediaPlayer> mSoundPoolMap;
private static AudioManager mAudioManager;
private static Context mContext;
public MusicSoundResources() {
}
public static void initSounds(Context theContext) {
mContext = theContext;
mSoundPoolMap = new HashMap<String, MediaPlayer>();
mAudioManager = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE);
loadSounds();
}
private static void loadSounds() {
mSoundPoolMap.put("swallowed", MediaPlayer.create(mContext, R.raw.swallowed));
}
public static void playSound(String soundTrackIndex, boolean loop) {
MediaPlayer mediaPlayer = mSoundPoolMap.get(soundTrackIndex);
float streamVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
streamVolume = streamVolume / mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
mediaPlayer.setVolume(streamVolume, streamVolume);
mediaPlayer.setLooping(loop);
mediaPlayer.start();
}
}
These are two logs which display:
05-31 15:02:56.400: ERROR/AudioTrack(2384): getAudioMode[0]
05-31 15:02:56.400: ERROR/AudioR2VS(2384): The 11025 sample rate is not supported by R2VS solution.
Same problem occurs when I use SoundPool.
Tell me what is the supported sample rate.
Finally I got the answer for this. This error comes when we play sounds of bit rate higher than 11025 Hz. This is an an internal error of android media player.