Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. public SoundPlayer(Context context) {
  2. this.context = context;
  3. AudioManager audioManager = (AudioManager) context.getSystemService(Service.AUDIO_SERVICE);
  4. soundPool = new SoundPool(3, AudioManager.STREAM_MUSIC, 0);
  5. clickId = soundPool.load(context, R.raw.bubbleclick, -1);
  6. errId = soundPool.load(context, R.raw.bubbleclickerror, 1);
  7. countId = soundPool.load(context, R.raw.countdowntick, 1);
  8.  
  9. float actualVolume = (float) audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
  10. float maxVolume = (float) audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
  11. volume = actualVolume / maxVolume;
  12. }
  13.  
  14. public void playBubbleClick() {
  15. if (!isMuted()) {
  16. soundPool.play(clickId, volume, volume, 1, 0, 1);
  17. }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement