Last updated:
0 purchases
next audio recorder
Next Audio Recorder Package #
Next Audio Recorder is a Flutter package for recording audio with additional features like setting subscription duration.
Features #
Record audio in Flutter apps.
Set subscription duration for recording.
Getting Started #
To use this package, add next_audio_recorder as a dependency in your pubspec.yaml file.
Permissions #
Before starting recording, make sure to add audio permissions to your AndroidManifest.xml file and request permission using the PermissionHandler package.
Add the following permissions to your AndroidManifest.xml file:
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
copied to clipboard
Request audio permission using PermissionHandler package:
import 'package:permission_handler/permission_handler.dart';
Future<bool> _requestPermission() async {
var status = await Permission.microphone.request();
if (status != PermissionStatus.granted) {
return false;
}
return true;
}
copied to clipboard
Example Usage #
Start Recording
startRecording() async {
bool recordPermission = await _requestPermission();
if (recordPermission) {
await _nextAudioRecorder.startRecorder('output.mp4');
await _nextAudioRecorder.setSubscriptionDuration(_subscriptionDuration);
_nextAudioRecorder.startRecorderSubscriptions((e) async {
// You can use this to trigger function or listen for special tasks like detecting when the user stops talking.
});
} else {
if (kDebugMode) {
print('Audio permission is required.');
}
}
}
copied to clipboard
Auto stop recording when detect silent after user speaking
await _audioRecorder.startRecorderWithAutoStop(
silentDecibelThreshold: 42,
silentDurationSecond: 2,
targetFilePath: 'output.mp4',
onFinished: (outputFilePath) {
});
copied to clipboard
Stop Recording
stopRecorder() async {
if (kDebugMode) {
print('[StartRecordEvent] Stopping recorder');
}
_nextAudioRecorder.cancelRecorderSubscriptions();
String? outputFilePath = await _nextAudioRecorder.stopRecorder();
if (outputFilePath != null) {
if (kDebugMode) {
print('[StartRecordEvent] Output recorded FilePath: $outputFilePath');
}
} else {
if (kDebugMode) {
print('[StartRecordEvent] No output file path found.');
}
}
}
copied to clipboard
Feel free to explore more methods and functionalities provided by Next Audio Recorder in the official documentation.
Issues and Contributions #
If you encounter any issues or have suggestions for improvements, feel free to open an issue on the GitHub repository.
We welcome contributions from the community. If you'd like to contribute, please fork the repository, make your changes, and submit a pull request.
License #
This package is licensed under the MIT License. See the LICENSE file for details.
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.