I am trying to play an mp3 file using the SoundPool class:
SoundPool Doc
However, I ran into the above error. Mp3 plays great on my machine - Win7 64bit. The error message is verbatim:
09-11 20: 27: 55.256: E / AudioTrack (671): AudioFlinger could not create a track, status: -22
Edit
All code to perform the specified function:
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);
source share