ussrback
ussrback

Reputation: 621

Flutter record Package: Recorded Audio Contains Silence After 1 Minute

I'm using the record package in Flutter to record audio. The recording process seems to work without any errors, but the resulting file contains only the first minute of audio, followed by complete silence.

Here is my recording code:

Future<void> _startRecording() async {
  try {
    // Get the app-specific external storage directory for music
    final directory = await getExternalStorageDirectory();
    if (directory == null) {
      debugPrint('Directory is null');
      return;
    }

    // Create the directory if it doesn't exist
    final voiceDirectory = Directory('${directory.path}/VoiceNotes');
    if (!voiceDirectory.existsSync()) {
      voiceDirectory.createSync(recursive: true);
    }

    // Generate the file path using the app-specific directory
    String filePath = '${voiceDirectory.path}/VoiceNote_${_generateTimestamp()}.3gp';

    // Start recording using the generated file path
    await _audioRecorder.start(
      const RecordConfig(encoder: AudioEncoder.amrNb),
      path: filePath,
    );

  } catch (e, stackTrace) {
    debugPrint('Error while recording: $e');
    debugPrint('Stack trace: $stackTrace');
  }
}

Steps I Have Taken:

Observations:

Questions:

Any suggestions or solutions would be greatly appreciated! Thank you.

Upvotes: 1

Views: 34

Answers (0)

Related Questions