AudioFlinger无法创建曲目,状态:-22

时间:2012-09-11 20:48:45

标签: android audio playback

我正在尝试使用SoundPool类播放mp3文件:


SoundPool Doc


然而,我遇到了上述错误。 mp3在我的机器上运行正常 - Win7 64bit。错误消息:

09-11 20:27:55.256:E / AudioTrack(671):AudioFlinger无法创建曲目,状态:-22

修改

执行所述功能的所有代码:

private SoundPool soundPool = new SoundPool(4, AudioManager.STREAM_MUSIC, 100);;
private HashMap<Integer, Integer> soundsMap = new HashMap<Integer, Integer>();
private int CLICK_SOUND = 1;



int sp = soundPool.load(this, R.raw.click, 1);
soundsMap.clear();
soundsMap.put(CLICK_SOUND, sp);


AudioManager mgr = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
float streamVolumeCurrent = mgr.getStreamVolume(AudioManager.STREAM_MUSIC);
float streamVolumeMax = mgr.getStreamMaxVolume(AudioManager.STREAM_MUSIC);          
float volume = streamVolumeCurrent / streamVolumeMax;           
soundPool.play(soundsMap.get(sound), volume, volume, 1, 0, fSpeed);

0 个答案:

没有答案