getting Unhandled Exception: Instance of '_CodecNotSupportedException'"while using flutter_sound package

Viewed 250

I want to record audio while pressing a button. here is my code.

 var tempDir = await getTemporaryDirectory();
 String path = '${tempDir.path}/audio.acc';

await _myRecorder.openRecorder();
await _myRecorder.startRecorder(
                        toFile: path,
                        codec: Codec.aacMP4,
                      );

// after recording another button to stop the recording. to stop this recording i used the code:

await _myRecorder.stopRecorder();
_myRecorder.closeRecorder();
_myRecorder = null;

i get my above mentioned error while i call "await _myRecorder.startRecorder" function. please help. thank you.

1 Answers

I recently had the same problem, it seems you should not append the file type at the end when declaring your path and should change:

String path = '${tempDir.path}/audio.acc';

To:

String path = '${tempDir.path}/audio';

Secondly some codecs currently are not supported but I am struggling to find which ones as their codec compatibility page is down:

https://pub.dev/documentation/flutter_sound/latest/recorder/FlutterSoundRecorder/codec.md#actually-the-following-codecs-are-supported-by-flutter_sound

Related