Android getAudioMode[0]错误

Android getAudioMode[0]错误,android,audio,soundpool,Android,Audio,Soundpool,我正在开发一个游戏,并使用SoundPool和MediaPlayer播放音频。每次播放任何音频声音时,它都会在LogCat中显示错误 public class MusicSoundResources { private static final String CLASS_TAG = "SoundResources"; private static MusicSoundResources _instance; public static HashMap<Strin

我正在开发一个游戏,并使用SoundPool和
MediaPlayer
播放音频。每次播放任何音频声音时,它都会在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();
    }
}
使用SoundPool时也会出现同样的问题


告诉我支持的采样率是多少。
play()
-方法的最后一个参数是
float
,而不是
int

公开最终整场演出(整场配乐, 浮动左音量,浮动右音量, 整数优先级,整数循环,浮动率

这应该起作用:

mSoundPool.play(mSoundPoolMap.get("fire"), streamVolume, streamVolume, 1, 0, 1.0);

我终于找到了答案。当我们播放比特率高于11025 Hz的声音时,会出现此错误。这是android media player的内部错误。

@Lukas Knuth:SoundPool mSoundPool=new SoundPool(50,AudioManager.STREAM_MUSIC,0);HashMap mSoundPoolMap=新HashMap();mSoundPoolMap.put(“fire”,mSoundPool.load(mContext,R.raw.fire,1));play(mSoundPoolMap.get(“fire”)、streamVolume、streamVolume、1、0、1);你应该编辑你的帖子。。。我是为你做的。但是这个错误仍然会出现:05-31 17:02:09.091:错误/音频跟踪(20897):getAudioMode[0]我在你的代码中看不到任何
getAudioMode
-数组。请发布所有必要的代码(编辑您的帖子)。@Lukas Knuth:我已经编辑了我的帖子。这是我用来播放音频的完整课程。我没有使用getAudioMode,当任何音频播放时,它会出现在logcat中。希望你现在有问题。
mSoundPool.play(mSoundPoolMap.get("fire"), streamVolume, streamVolume, 1, 0, 1.0);