3 Aralık 2017 Pazar

MediaRecorder Sınıfı

constructor
Şöyle yaparız.
MediaRecorder recorder = new MediaRecorder();
setAudioEncoder metodu
Şöyle yaparız.
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
setAudioSource metodu
Şöyle yaparız.
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
setOutputFile metodu
Şöyle yaparız.
Socket s = new Socket("10.0.83.8", 8888);
ParcelFileDescriptor pfd = ParcelFileDescriptor.fromSocket(s);
...
recorder.setOutputFile(pfd.getFileDescriptor());
setOutputFormatmetodu
Şöyle yaparız.
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
Şöyle yaparız.
recorder.setOutputFormat(MediaRecorder.OutputFormat.RAW_AMR);
prepare metodu
Şöyle yaparız.
try {
  recorder.prepare();
} catch (IllegalStateException e) {
  e.printStackTrace();
} catch (IOException e) {
  e.printStackTrace();
}
start metodu
Şöyle yaparız.
recorder.start();
Diğer
Şöyle yaparız.
MediaRecorder recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.RAW_AMR);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setOutputFile(pfd.getFileDescriptor());

try {
  recorder.prepare();
} catch (IllegalStateException e) {
  e.printStackTrace();
} catch (IOException e) {
  e.printStackTrace();
}
recorder.start();


Hiç yorum yok:

Yorum Gönder