Open davecoffin opened 3 years ago
@jibon57 any thoughts on this?
I sort of figured this out, I'm not good enough at Android to know whats going on...but heres what I found:
this block:
case Constant.REQUEST_CODE_TAKE_AUDIO:
if (resultCode === androidAcivity.RESULT_OK) {
let rawData = Uri.parse(data.getData().toString());
let cursor = context.getContentResolver().query(rawData, null, null, null, null);
let column_index = cursor.getColumnIndex(MediaStore.Audio.Media.DATA);
cursor.moveToFirst();
let file = {
type: 'capturedAudio',
file: cursor.getString(column_index),
rawData: rawData
};
output.push(file);
cursor.close();
}
break;
column_index ends up being -1 for some reason. That crashes the app. First I tried this:
file: cursor.getString(column_index > -1 ? column_index : 0),
but that would simply return the filename, not the path to the file. I did notice though, that
data.getData().toString()
returns the full path to the file, in my case it was
content://com.google.android.apps.recorder.fileprovider/recording/634999c5-1dd1-4053-a2e6-fdd550ecc78a.m4a
So, i just pass that back as the file instead of using the cursor thing at all. The block above became
case Constant.REQUEST_CODE_TAKE_AUDIO:
if (resultCode === androidAcivity.RESULT_OK) {
let rawData = Uri.parse(data.getData().toString());
let cursor = context.getContentResolver().query(rawData, null, null, null, null);
let column_index = cursor.getColumnIndex(MediaStore.Audio.Media.DATA);
cursor.moveToFirst();
let file = {
type: 'capturedAudio',
file: data.getData().toString(),
rawData: rawData
};
output.push(file);
cursor.close();
}
break;
I have no idea how this will work with android phones that have other recording apps or whatever. Any thoughts on this would be appreciated.
On Android, when recording audio, then saving, the app crashes with the following stack:
Open the audio picker: