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:
@@ -50,7 +50,7 @@ public class ListenActivity extends Activity
|
|||||||
int audioEncoding = AudioFormat.ENCODING_PCM_16BIT;
|
int audioEncoding = AudioFormat.ENCODING_PCM_16BIT;
|
||||||
int bufferSize = AudioTrack.getMinBufferSize(frequency, channelConfiguration, audioEncoding);
|
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,
|
frequency,
|
||||||
channelConfiguration,
|
channelConfiguration,
|
||||||
audioEncoding,
|
audioEncoding,
|
||||||
@@ -63,6 +63,8 @@ public class ListenActivity extends Activity
|
|||||||
Thread playThread = new Thread(audioPlayer);
|
Thread playThread = new Thread(audioPlayer);
|
||||||
playThread.start();
|
playThread.start();
|
||||||
|
|
||||||
|
setVolumeControlStream(AudioManager.STREAM_MUSIC);
|
||||||
|
|
||||||
InputStream is = socket.getInputStream();
|
InputStream is = socket.getInputStream();
|
||||||
int read = 0;
|
int read = 0;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user