一个耳机选择右侧或左侧。播放所选耳机(左/右)的声音

时间:2014-05-05 22:50:30

标签: android headphones

如何只选择左侧或右侧的盖子,然后将所选声音播放到耳机?

1 个答案:

答案 0 :(得分:1)

假设SoundPool没问题,您可以使用:

SoundPool pool = new SoundPool(1, AudioManager.STREAM_NOTIFICATION, 0);
pool.play(
        pool.load(this, R.raw.my_sound_effect, 1), // The sound effect to play
        0, // The volume for the left channel (0.0 - 1.0)
        1.0f, // The volume for the right channel (0.0 - 1.0)
        0, // Default priority 
        0, // Do not loop
        1.0f); // Playback rate (1.0f == normal)