-
Notifications
You must be signed in to change notification settings - Fork 282
Open
Description
Record version: ^6.1.2
IOS: 17.6.1
I simply try to record for both Android and IOS
Future<void> _startRecording() async {
try {
if (await _audioRecorder.hasPermission() &&
_recordState != RecordState.record) {
const encoder = AudioEncoder.aacLc;
if (!await _isEncoderSupported(encoder)) {
return;
}
final devs = await _audioRecorder.listInputDevices();
debugPrint(devs.toString());
const config = RecordConfig(
encoder: AudioEncoder.aacLc,
sampleRate: 44100,
bitRate: 128000,
);
var dir = await Helpers.getRecordingDirectoryPath(
widget.dmid,
widget.gid,
widget.cid,
);
await _audioRecorder.start(config, path: dir);
}
} catch (e) {
if (kDebugMode) {
print(e);
}
}
}
Then i try to load the recording
var hash = await calculateFileMD5(_recordingPath);
String _dirPath = _recordingPath.substring(
0, _recordingPath.lastIndexOf('/'));
String _newRecordingPath = "$_dirPath/${hash}.m4a";
File(_recordingPath).renameSync(_newRecordingPath);
print("file renamed successfully to: $_newRecordingPath");
_chatInputMessageProvider
.setRecordingMessageLongPress(false);
_chatInputMessageProvider.setRecordingMessage(false);
print("stop long press");
AudioPlayer _audioPlayer = AudioPlayer();
await _audioPlayer.setSourceUrl(_newRecordingPath,
mimeType: "audio/m4a");
var _finalRecordDuration = await _audioPlayer.getDuration();
print("record duration: $_finalRecordDuration");
Everything works on Android but on IOS it fails to load that file.
flutter: \^[[31mAudioPlayers Exception: AudioPlayerException(
UrlSource(url: /var/mobile/Containers/Data/Application/AE40BB76-4B44-4233-AC81-081790D10611/Documents/personal/directMessages/594250296222324999/20f0eb0ea82d4e2bee97f2d2914b0eb2.m4a, mimeType: audio/m4a),
PlatformException(DarwinAudioError, Failed to set source. For troubleshooting, see https://github.com/bluefireteam/audioplayers/blob/main/troubleshooting.md, AVPlayerItem.Status.failed on setSourceUrl: Unknown error, null)\^[[0m
[ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: PlatformException(DarwinAudioError, Failed to set source. For troubleshooting, see https://github.com/bluefireteam/audioplayers/blob/main/troubleshooting.md, AVPlayerItem.Status.failed on setSourceUrl: Unknown error, null)
I tried changing the extension, the encoder, the bitrate, sample rate same problem. I tried switching to just audio same issues. The record from IOS is somehow messed up
Metadata
Metadata
Assignees
Labels
No labels