0

I want to play 2 sounds at same time and i want to play them at same time

Here is my code :

            if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){
                AudioAttributes audioAttributes = new AudioAttributes.Builder().setContentType(AudioAttributes.CONTENT_TYPE_MUSIC).setUsage(AudioAttributes.USAGE_GAME).build();
    
                soundPool=new SoundPool.Builder().setAudioAttributes(audioAttributes).build();
            }else{
                soundPool =new SoundPool(2, AudioManager.STREAM_MUSIC, 0);
    
            }



        shoot = soundPool.load(gameActivity,R.raw.shoot,1);
        getShot = soundPool.load(gameActivity, R.raw.get_shot,1);


soundPool.play(getShot,1,1,0,0,1);
soundPool.play(shoot,1,1,0,0,1);

Those play are located not in same method but it's irrelevant.

Red
  • 26,798
  • 7
  • 36
  • 58
  • Does this answer your question? [Playing two sounds Simutaneosly](https://stackoverflow.com/questions/4350212/playing-two-sounds-simutaneosly) – Ruli Nov 16 '20 at 15:25
  • i got it work with soundpool but i got error : access denied finding property "persist.kirin.media.lowlatency.enable" – kibat85049 Nov 16 '20 at 17:02
  • @Ruli i swaped soundpool to mediaplayer and it works but i want to play sound when player shot bullet. I dont know why its playing audio like 1/3 th shots. I should add prepare or something with sync? – kibat85049 Nov 16 '20 at 17:24

0 Answers0