soundPool用法:
<span style="white-space:pre"> </span>protected SoundPool soundPool=new SoundPool(1, AudioManager.STREAM_MUSIC, 0);
protected HashMap<String, Integer> soundMap = new HashMap<String, Integer>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
soundMap.put("f1", soundPool.load(this, R.raw.f1, 1));
try {
Thread.sleep(5000);//线程等待5秒,不能加载后立马播放
soundPool.play(soundMap.get("f1"), 1, 1, 0, 0, 1);
} catch (InterruptedException e) {
e.printStackTrace();
}
}