android: Android MediaRecorder.AudioSource = undefined
From @bradmartin on February 24, 2016 4:29
Android Sample:
private void startRecording() {
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setOutputFile(mFileName);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
try {
mRecorder.prepare();
} catch (IOException e) {
Log.e(LOG_TAG, "prepare() failed");
}
mRecorder.start();
}
`
NativeScript JS code:
var MediaRecorder = android.media.MediaRecorder;
var AudioSource = android.media.MediaRecorder.AudioSource;
var OutputFormat = android.media.MediaRecorder.OutputFormat;
var AudioEncoder = android.media.MediaRecorder.AudioEncoder;
var recorder;
function startAudio(args) {
try {
console.log('START AUDIO');
recorder = new MediaRecorder();
console.log('RECORDER: ' + recorder);
// *** FAILS with AudioSource being undefined. **
recorder.setAudioSource(AudioSource.MIC);
recorder.setOutputFormat(OutputFormat.THREE_GPP);
recorder.setOutputFile("bradTest");
recorder.setAudioEncoder(AudioEncoder.AMR_NB);
recorder.prepare();
recorder.start();
} catch (ex) {
console.log(ex);
}
}
exports.startAudio = startAudio;
`
Copied from original issue: NativeScript/NativeScript#1622
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 24 (17 by maintainers)
Ping @tjvantoll , @EddyVerbruggen , @sitefinitysteve, @bradmartin, @AntonioCuevaUrraco, @hdeshev , @vakrilov , @PeterStaev, @alexziskind1, @emiloberg, @PanayotCankov , @TobiasHennig, @NathanaelA, @ginev Hi all, we need you opinion on this matter, because this will affect you, as well as all other nativescript users. I’m trying to start a dialog, where everyone will be satisfied with the final result.
Can’t we make the com.example.A.B a constructor function that gets instance of A as first arg, but also preserve the current syntax, where instances of A have property B that can be used to instantiate B?