简体   繁体   English

获取未处理的异常:“_CodecNotSupportedException”的实例”,同时使用 flutter_sound package

[英]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.

相关问题 通过flutter DIO包调用Post请求时抛出未处理的异常错误 - While calling Post request via flutter DIO package It throws unhandled Exception Error 未处理的异常:未处理的错误 Null 检查运算符用于 flutter 中的“AuthBloc”实例中的 null 值 - Unhandled Exception: Unhandled error Null check operator used on a null value occurred in Instance of 'AuthBloc' in flutter 获取sqlite单例实例时发生NullPointer异常 - NullPointer Exception while getting an instance of sqlite singleton 为什么我得到:未处理的异常:'package:flutter/src/material/scaffold.dart - Why I got : Unhandled Exception: 'package:flutter/src/material/scaffold.dart 未处理的异常:'package:flutter/src/widgets/framework.dart':断言失败:'_debugCurrentBuildTarget == context':不是真的 - Unhandled Exception: 'package:flutter/src/widgets/framework.dart': Failed assertion: '_debugCurrentBuildTarget == context': is not true 使用“ market:// details?id = my_package_name”时出现“找不到活动异常” - Getting “Activity not found exception” while using “market://details?id=my_package_name” 使用 Flutter 提供程序 package 时出现问题 - Problems while using Flutter Provider package [Flutter] 未处理的异常:NoSuchMethodError:方法 '[]' 在 null 上被调用 - [Flutter ]Unhandled Exception: NoSuchMethodError: The method '[]' was called on null Flutter 应用程序在使用 flutter_pdfview package 时崩溃 - Flutter app crashing while using flutter_pdfview package 未处理的异常:未找到 MediaQuery 小部件 - 颤动 ShowModalButtonSheet - Unhandled Exception: No MediaQuery widget found - flutter ShowModalButtonSheet
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM