android AudioTrack不能播放awr(3)
this.isRecording = false;
System.out.println(isRecording);
break;
case R.id.btn_play:
player = new PlayTask();
player.execute();
break;
case R.id.btn_finish:
this.isPlaying = false;
break;
}
}
class RecordTask extends AsyncTask<Void, Integer, Void>{
@Override
protected Void doInBackground(Void... arg0) {
//isRecording = true;
try {
//开通输出流到指定的文件
DataOutputStream dos = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(audioFile)));
//FileOutputStream fos = new FileOutputStream(audioFile);
//根据定义好的几个配置,来获取合适的缓冲大小
int bufferSize = AudioRecord.getMinBufferSize(frequence, channelConfig, audioEncoding);
//实例化AudioRecord
AudioRecord record = new AudioRecord(MediaRecorder.AudioSource.MIC, frequence, channelConfig, audioEncoding, bufferSize);
//定义缓冲
short[] buffer = new short[bufferSize];
相关新闻>>
- 发表评论
-
- 最新评论 更多>>