如何同时播放多个声音池?

yuvru6vn  于 2021-07-08  发布在  Java
关注(0)|答案(0)|浏览(186)

我想在同一时间播放两个声音,我想在同一时间播放它们
这是我的密码:

  1. if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){
  2. AudioAttributes audioAttributes = new AudioAttributes.Builder().setContentType(AudioAttributes.CONTENT_TYPE_MUSIC).setUsage(AudioAttributes.USAGE_GAME).build();
  3. soundPool=new SoundPool.Builder().setAudioAttributes(audioAttributes).build();
  4. }else{
  5. soundPool =new SoundPool(2, AudioManager.STREAM_MUSIC, 0);
  6. }
  7. shoot = soundPool.load(gameActivity,R.raw.shoot,1);
  8. getShot = soundPool.load(gameActivity, R.raw.get_shot,1);
  9. soundPool.play(getShot,1,1,0,0,1);
  10. soundPool.play(shoot,1,1,0,0,1);

这些游戏的定位方法不同,但并不相关。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题