audio_recorder_service_flutter 1.0.0+1
audio_recorder_service_flutter: ^1.0.0+1 copied to clipboard
SDK Updated to 3.8.0
Audio Recorder Service #
A Flutter package that provides functionality for recording audio with the ability to pause, resume, and stop the recording. It also includes background notifications to manage the recording state.
Features #
- Start, pause, resume, and stop audio recording.
- Background notifications during recording.
- Supports AAC audio encoding.
- Works across Android platforms.
- Handles recording permissions automatically.
Getting Started #
UI Example #
[Audio Recorder UI]
[Audio Recorder UI 2]
Usage #
- Initialize the Recorder
final audioRecorderService = AudioRecorderService(); await audioRecorderService.initializeNotifications();
- Start Recording
await audioRecorderService.startRecording();
- Pause Recording
await audioRecorderService.pauseRecording();
- Resume Recording
await audioRecorderService.resumeRecording();
- Stop Recording
await audioRecorderService.stopRecording();
Android Setup #
To enable background recording, you need to update AndroidManifest.xml
and build.gradle.
- Modify
AndroidManifest.xml
Location:android/app/src/main/AndroidManifest.xml
Add Permissions #
Inside <manifest>
:
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.INTERNET"/>
Add Receivers #
Inside <application>
:
<receiver android:exported="false" android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationReceiver" />
<receiver android:exported="false" android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
</intent-filter>
</receiver>
<receiver android:exported="false" android:name="com.dexterous.flutterlocalnotifications.ActionBroadcastReceiver" />`
Add Service #
Add this after <activity>
:
<service
android:name="com.ryanheise.audioservice.AudioService"
android:foregroundServiceType="mediaPlayback"
android:exported="true"
tools:ignore="Instantiatable">
<intent-filter>
<action android:name="android.media.browse.MediaBrowserService"/>
</intent-filter>
</service>`
- Modify
android/app/build.gradle
Location:android/app/build.gradle
Ensure the following settings:
`compileSdk = 34`
`minSdk = 23`
`defaultConfig {
multiDexEnabled true // Add this line
}`
To use this package, add it to your pubspec.yaml
:
dependencies:
audio_recorder_service:
path: ../audio_recorder_service