안드로이드 개발 질문/답변
(글 수 45,052)
01.
public class SoundManager {
02. 03. private SoundPool mSoundPool; 04. private HashMap<Integer, Integer> mSoundPoolMap; 05. private AudioManager mAudioManager; 06. private Context mContext; 07. 08. 09. public SoundManager() 10. { 11. 12. } 13. 14. public void initSounds(Context theContext) { 15. mContext = theContext; 16. mSoundPool = new SoundPool(4, AudioManager.STREAM_MUSIC, 0); 17. mSoundPoolMap = new HashMap<Integer, Integer>(); 18. mAudioManager = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE); 19. } 20. 21. public void addSound(int Index,int SoundID) 22. { 23. mSoundPoolMap.put(1, mSoundPool.load(mContext, SoundID, 1)); 24. } 25. 26. public void playSound(int index) { 27. 28. int streamVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC); 29. mSoundPool.play(mSoundPoolMap.get(index), streamVolume, streamVolume, 1, 0, 1f); 30. } 31. 32. public void playLoopedSound(int index) { 33. 34. int streamVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC); 35. mSoundPool.play(mSoundPoolMap.get(index), streamVolume, streamVolume, 1, -1, 1f); 36. } 37. 38.}
여기에 playLoopedSound 라는 메서드는 무슨 역할을 하나요? playSound 만 적어도 소리가 나오지 않을까요 ?



