У меня вопрос, как я могу отправить свой аудиофайл на сервер, я пытался конвертировать в base64, но ничего не работает. Это мой код
объявление переменных:
private MediaRecorder grabacion;
private String archivoSalida = null;
аудио, полученное с медиа-записи:
archivoSalida = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Myrecord.mp3";
grabacion = new MediaRecorder();
grabacion.setAudioSource(MediaRecorder.AudioSource.MIC);
grabacion.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
grabacion.setAudioEncoder(MediaRecorder.OutputFormat.AMR_NB);
grabacion.setOutputFile(archivoSalida);
Преобразование в base64, здесь появляется ошибка:
private String convertirAudString(MediaRecorder audio){
ByteArrayOutputStream array=new ByteArrayOutputStream();
byte[] audioByte = new byte[(int)audio.length()];//error in this line
String audioString = Base64.encodeToString(audioByte,Base64.DEFAULT);
return audioString;
}