How can I handle audio files?
120
Here is a package you can use audio_recorder
-
For record and storing part here is sample examples (read the package documentation)
// Import package import 'package:audio_recorder/audio_recorder.dart'; // Check permissions before starting bool hasPermissions = await AudioRecorder.hasPermissions; // Get the state of the recorder bool isRecording = await AudioRecorder.isRecording; // Start recording await AudioRecorder.start(path: _controller.text, audioOutputFormat: AudioOutputFormat.AAC); // Stop recording Recording recording = await AudioRecorder.stop(); print("Path : ${recording.path}, Format : ${recording.audioOutputFormat}, Duration : ${recording.duration}, Extension : ${recording.extension},");
-
play audio you need another package i suggest audioplayers :
// To pause int result = await audioPlayer.pause(); //To Stop int result = await audioPlayer.stop(); // To Jump through int result = await audioPlayer.seek(Duration(milliseconds: 1200)); // To Resume int result = await audioPlayer.resume();
Author by
Admin
Updated on December 23, 2022Comments
-
Admin over 1 year
What is the best option to:
- Record audio from microphone,
- Store the audio as files in memory,
- Being able to play those files ?
Is there one package that is convenient to record and play? Does it works on all platforms (web compatible)? What is the best strategy to store them in memory?