0

How can I realize it? VideoView is working fine, but there is no sound from soundPool.

  soundPool = new SoundPool(4, AudioManager.STREAM_MUSIC, 100);
            soundsMap = new HashMap<Integer, Integer>();
                soundsMap.put(SOUND1, soundPool.load(this, R.raw.water1, 1));
                soundsMap.put(SOUND2, soundPool.load(this, R.raw.water2, 1));


            AudioManager mgr = (AudioManager)getSystemService(Context.AUDIO_SERVICE);

                float streamVolumeCurrent = mgr.getStreamVolume(AudioManager.STREAM_MUSIC);
                float streamVolumeMax = mgr.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
                float volume = streamVolumeCurrent / streamVolumeMax;  

            soundPool.play(SOUND1, volume, volume, 1, 0, 1);
            .
            .
            .
            VideoView.start();
dnlcrl
  • 5,022
  • 3
  • 32
  • 40
Eves
  • 1

1 Answers1

0
soundPool.play(SOUND1, volume, volume, 1, 0, 1);

try this instead of above code

soundPool.play(soundsMap.get(SOUND1), volume, volume, 1, 0, 1);

I guess your using a map to store all your music files

Just Variable
  • 892
  • 10
  • 19