VideoView与soundPool一次

时间:2012-10-30 15:50:15

标签: android android-videoview soundpool

我怎么能意识到这一点? VideoView工作正常,但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();

1 个答案:

答案 0 :(得分:0)

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

试试这个代替上面的代码

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

我猜您使用地图存储所有音乐文件