dart 我得到了错误:未为类型“MicrophoneRecorder”定义方法“getCurrentRecording”

yks3o0rb  于 2023-03-27  发布在  其他
关注(0)|答案(1)|浏览(126)
Visibility(
            visible: isRecording == false,
            child: TextButton(
              onPressed: () async {
                final recording = await _recorder.getCurrentRecording();
                if (recording != null) {
                  await _audioPlayer.play(recording.path);
                }
              },

错误:未为类型“MicrophoneRecorder”定义方法“getCurrentRecording”。
我该怎么办?
我尝试升级麦克风包,并执行Flutter清洁命令

fnx2tebb

fnx2tebb1#

microphone library docs上似乎没有getCurrentRecording的方法定义,这很可能是你遇到这个问题的原因。你可以在MicrophoneRecorder Class Docs上找到MicrophoneRecorder支持的所有方法。
也就是说,为了检索记录,您可以使用以下内容:
1.录制一些东西,然后停止录制(这只是这里的一个例子,很可能你需要使用一些逻辑来实现这一点-iidoEe.,2个按钮来开始和停止录制等)。

_recorder.start();
// record something in between
_recorder.stop();

1.取回录音

_audioPlayer = AudioPlayer();
await _audioPlayer.setUrl(_recorder.value.recording.url);
await _audioPlayer.play();

有一个非常好的示例应用程序演示了GitHub: microphone example app上的麦克风库。它可以给予一些关于如何利用这个包的想法。
希望有帮助。
干杯
约阿尼斯

相关问题