Allow volume control to adjust playback volume

The AudioTrack for playing audio from the child device
was sending audio to the voice call stream. It is more
appropriate to use the music stream. In addition, suggest
that the activity control the music stream's volume with
the hardware controls.
This commit is contained in:
Branden Archer
2015-12-27 20:34:02 -05:00
parent 9eaf90fcda
commit 516ba5a225

View File

@@ -50,7 +50,7 @@ public class ListenActivity extends Activity
int audioEncoding = AudioFormat.ENCODING_PCM_16BIT;
int bufferSize = AudioTrack.getMinBufferSize(frequency, channelConfiguration, audioEncoding);
final AudioTrack audioTrack = new AudioTrack(AudioManager.STREAM_VOICE_CALL,
final AudioTrack audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC,
frequency,
channelConfiguration,
audioEncoding,
@@ -63,6 +63,8 @@ public class ListenActivity extends Activity
Thread playThread = new Thread(audioPlayer);
playThread.start();
setVolumeControlStream(AudioManager.STREAM_MUSIC);
InputStream is = socket.getInputStream();
int read = 0;