我目前有代码使用AudioRecord类从设备mic读取录音,然后使用AudioTrack类播放.
我的问题是,当我播放它时,它通过扬声器电话播放.
我希望它通过设备上的耳机播出.
这是我的代码:
public class LoopProg extends Activity {
boolean isRecording; //currently not used
AudioManager am;
int count = 0;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
am.setMicrophoneMute(true);
while(count <= 1000000){
Record record = new Record();
record.run();
count ++;
Log.d("COUNT", "Count is : " + count);
}
}
public class Record extends Thread{
static final int bufferSize = 200000;
final short[] buffer = new short[bufferSize]; …Run Code Online (Sandbox Code Playgroud)