[英]getting Unhandled Exception: Instance of '_CodecNotSupportedException'"while using flutter_sound package
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.我在调用“await _myRecorder.startRecorder”function 时遇到上述错误。请帮忙。 thank you.谢谢你。
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:我最近遇到了同样的问题,看来你不应该 append 在声明你的路径时最后的文件类型应该改变:
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 https://pub.dev/documentation/flutter_sound/latest/recorder/FlutterSoundRecorder/codec.md#actually-the-following-codecs-are-supported-by-flutter_sound
I was facing this error and solved this by removing codec parameter.我遇到了这个错误并通过删除编解码器参数解决了这个问题。 Use following code to record使用以下代码记录
await mRecorder!.setSubscriptionDuration(const Duration(seconds: 1));
var tempDir = await getTemporaryDirectory();
mPath = '${tempDir.path}/audio';
// String tempPath = "";
// log("tempPath : $tempPath");
mRecorder!
.startRecorder(
toFile: mPath,
// codec: codec,
audioSource: AudioSource.microphone,
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.