'Flutter: Is the sound really recorded in the designated file?

Recently I am using a package named flutter_sound v9.1.7. Here are some of the codes.

String _mPath = 'tau_file.mp4';
Codec _codec = Codec.aacMP4;
File? file;
FlutterSoundPlayer? _mPlayer = FlutterSoundPlayer();
FlutterSoundRecorder? _mRecorder = FlutterSoundRecorder();
void record() async {
    _mRecorder!
        .startRecorder(
      toFile: _mPath,
      codec: _codec,
      audioSource: AudioSource.microphone,
    )
        .then((value) {});

    setState(() {
      recording = true;
    });
  }

I have succeeded in recording and playing audio, but when I finish recording and try to analyze the seeming audio file tau_file.mp4, such like get the length of the file, an error occurred: Cannot retrieve length of file, path = 'tau_file.mp4' (OS Error: No such file or directory, errno = 2). The analysis code is here:

file = File(_mPath);
print(file?.path);
print(file?.absolute);
print(file?.length.toString());

I tried to seek answer in source codes, but only found an interface... So is the audio really be written to the file tau_file.mp4? Or maybe the process of analysis is wrong?

This is the first time that I use flutter_sound. Thanks for your help.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source