0
我想錄制不同的聲音,並使用手機上的「SoundPool」進行播放。 此刻我將聲音保存在「\ res \ raw」文件夾中,並用hashMap加載它。Android:SoundPool/record音頻
我希望你能幫助我。
this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
spool = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);
soundsMap = new HashMap<Integer, Integer>();
soundsMap.put(1, spool.load(context, R.raw.alan1, 1));
soundID = soundsMap.get(1);
AudioManager audioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
float volume = (float) audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
loopPool = spool.play(soundID, volume, volume, 5, 0, 1f);