Flutter Audio Playback & Recording in Mobile Apps
Aug 28, 2025



Summary
Summary
Summary
Summary
This tutorial guides Flutter developers through setting up just_audio and record packages, managing microphone and storage permissions, implementing audio playback and recording with code examples, and optimizing mobile performance. Learn to load assets or URLs, capture microphone input, handle resources properly, and ensure responsive UI for robust audio features in your Flutter mobile apps.
This tutorial guides Flutter developers through setting up just_audio and record packages, managing microphone and storage permissions, implementing audio playback and recording with code examples, and optimizing mobile performance. Learn to load assets or URLs, capture microphone input, handle resources properly, and ensure responsive UI for robust audio features in your Flutter mobile apps.
This tutorial guides Flutter developers through setting up just_audio and record packages, managing microphone and storage permissions, implementing audio playback and recording with code examples, and optimizing mobile performance. Learn to load assets or URLs, capture microphone input, handle resources properly, and ensure responsive UI for robust audio features in your Flutter mobile apps.
This tutorial guides Flutter developers through setting up just_audio and record packages, managing microphone and storage permissions, implementing audio playback and recording with code examples, and optimizing mobile performance. Learn to load assets or URLs, capture microphone input, handle resources properly, and ensure responsive UI for robust audio features in your Flutter mobile apps.
Key insights:
Key insights:
Key insights:
Key insights:
Setting Up Dependencies: Use just_audio for playback and record for microphone capture; add to pubspec.yaml.
Requesting Permissions: Verify and request RECORD_AUDIO and storage permissions before recording.
Implementing Audio Playback: Instantiate AudioPlayer, load URLs or assets, and control playback via play, pause, and streams.
Implementing Audio Recording: Start and stop recordings with Record, choose encoder and path, and monitor sound levels.
Optimizing Performance: Dispose resources, adjust bit rates, preload assets, and use isolates for audio processing.
Introduction
Flutter’s cross-platform capabilities extend seamlessly into audio features, letting developers integrate playback and recording into mobile apps. This tutorial explores how to set up dependencies, request permissions, play audio files or streams, record user input, and optimize performance. By the end, you’ll have a solid foundation for audio-centric Flutter mobile development.
Setting Up Dependencies
To work with audio in Flutter, two popular packages are just_audio for playback and record for recording. Add these to your pubspec.yaml under dependencies:
dependencies:
flutter:
sdk: flutter
just_audio: ^0.9.26
record
Run flutter pub get to fetch the packages. just_audio provides a high-level API to load and play audio from assets, files, or URLs. record offers an easy interface to capture microphone input and save it as WAV or AAC.
Requesting Permissions
Mobile platforms require runtime permissions for microphone and storage. Use permission_handler or the built-in record methods to prompt users.
For Android, add to AndroidManifest.xml:
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
In Dart, before recording, check and request:
import 'package:record/record.dart';
Future<bool> ensureMicPermission() async {
final record = Record();
if (await record.hasPermission()) return true;
return await record.requestPermission();
}
This snippet verifies or requests microphone access, returning true if granted.
Implementing Audio Playback
just_audio features a simple AudioPlayer class. Initialize, load, and control playback:
import 'package:just_audio/just_audio.dart';
final player = AudioPlayer();
Future<void> playUrl(String url) async {
await player.setUrl(url); // Load from network
player.play();
}
Use setAsset for bundled files or setFilePath for local storage. Control volume, seek, and loop via player.setVolume, player.seek, and player.setLoopMode. Listen to player.playerStateStream for UI updates:
player.playerStateStream.listen((state) {
// update play/pause button
});
Implementing Audio Recording
With permissions granted, start and stop recordings easily:
import 'package:record/record.dart';
final recorder = Record();
Future<String?> startRecording() async {
await recorder.start(
path: '/storage/emulated/0/Download/temp.wav',
encoder: AudioEncoder.wav,
bitRate: 128000,
);
return recorder.recordingPath;
}
Future<void> stopRecording() async {
await recorder.stop();
}
The recordingPath is available after start. You can then play the file with just_audio or upload it. Monitor sound levels via recorder.onStateChanged and recorder.getAmplitude for UI metering.
Optimizing Performance
Handling audio efficiently is crucial for mobile. Follow these best practices:
• Dispose of players and recorders: call player.dispose() and recorder.dispose() in dispose() to free native resources.
• Use lower bit rates or AAC encoder for smaller file sizes and faster uploads.
• Preload short sounds (UI feedback) with AudioPlayer.setAsset at app start to reduce latency.
• Offload heavy processing (e.g., audio analysis) to isolates to keep the UI thread responsive.
Vibe Studio

Vibe Studio, powered by Steve’s advanced AI agents, is a revolutionary no-code, conversational platform that empowers users to quickly and efficiently create full-stack Flutter applications integrated seamlessly with Firebase backend services. Ideal for solo founders, startups, and agile engineering teams, Vibe Studio allows users to visually manage and deploy Flutter apps, greatly accelerating the development process. The intuitive conversational interface simplifies complex development tasks, making app creation accessible even for non-coders.
Conclusion
Integrating audio playback and recording in Flutter involves selecting robust packages, requesting platform permissions, and implementing clear APIs for play and record. By following best practices—disposing resources, optimizing bit rates, and managing threads—your mobile app can deliver high-quality audio experiences. Experiment with advanced features like background playback, audio focus, and waveform visualization to take your app to the next level.
Introduction
Flutter’s cross-platform capabilities extend seamlessly into audio features, letting developers integrate playback and recording into mobile apps. This tutorial explores how to set up dependencies, request permissions, play audio files or streams, record user input, and optimize performance. By the end, you’ll have a solid foundation for audio-centric Flutter mobile development.
Setting Up Dependencies
To work with audio in Flutter, two popular packages are just_audio for playback and record for recording. Add these to your pubspec.yaml under dependencies:
dependencies:
flutter:
sdk: flutter
just_audio: ^0.9.26
record
Run flutter pub get to fetch the packages. just_audio provides a high-level API to load and play audio from assets, files, or URLs. record offers an easy interface to capture microphone input and save it as WAV or AAC.
Requesting Permissions
Mobile platforms require runtime permissions for microphone and storage. Use permission_handler or the built-in record methods to prompt users.
For Android, add to AndroidManifest.xml:
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
In Dart, before recording, check and request:
import 'package:record/record.dart';
Future<bool> ensureMicPermission() async {
final record = Record();
if (await record.hasPermission()) return true;
return await record.requestPermission();
}
This snippet verifies or requests microphone access, returning true if granted.
Implementing Audio Playback
just_audio features a simple AudioPlayer class. Initialize, load, and control playback:
import 'package:just_audio/just_audio.dart';
final player = AudioPlayer();
Future<void> playUrl(String url) async {
await player.setUrl(url); // Load from network
player.play();
}
Use setAsset for bundled files or setFilePath for local storage. Control volume, seek, and loop via player.setVolume, player.seek, and player.setLoopMode. Listen to player.playerStateStream for UI updates:
player.playerStateStream.listen((state) {
// update play/pause button
});
Implementing Audio Recording
With permissions granted, start and stop recordings easily:
import 'package:record/record.dart';
final recorder = Record();
Future<String?> startRecording() async {
await recorder.start(
path: '/storage/emulated/0/Download/temp.wav',
encoder: AudioEncoder.wav,
bitRate: 128000,
);
return recorder.recordingPath;
}
Future<void> stopRecording() async {
await recorder.stop();
}
The recordingPath is available after start. You can then play the file with just_audio or upload it. Monitor sound levels via recorder.onStateChanged and recorder.getAmplitude for UI metering.
Optimizing Performance
Handling audio efficiently is crucial for mobile. Follow these best practices:
• Dispose of players and recorders: call player.dispose() and recorder.dispose() in dispose() to free native resources.
• Use lower bit rates or AAC encoder for smaller file sizes and faster uploads.
• Preload short sounds (UI feedback) with AudioPlayer.setAsset at app start to reduce latency.
• Offload heavy processing (e.g., audio analysis) to isolates to keep the UI thread responsive.
Vibe Studio

Vibe Studio, powered by Steve’s advanced AI agents, is a revolutionary no-code, conversational platform that empowers users to quickly and efficiently create full-stack Flutter applications integrated seamlessly with Firebase backend services. Ideal for solo founders, startups, and agile engineering teams, Vibe Studio allows users to visually manage and deploy Flutter apps, greatly accelerating the development process. The intuitive conversational interface simplifies complex development tasks, making app creation accessible even for non-coders.
Conclusion
Integrating audio playback and recording in Flutter involves selecting robust packages, requesting platform permissions, and implementing clear APIs for play and record. By following best practices—disposing resources, optimizing bit rates, and managing threads—your mobile app can deliver high-quality audio experiences. Experiment with advanced features like background playback, audio focus, and waveform visualization to take your app to the next level.
Build Flutter Apps Faster with Vibe Studio
Build Flutter Apps Faster with Vibe Studio
Build Flutter Apps Faster with Vibe Studio
Build Flutter Apps Faster with Vibe Studio
Vibe Studio is your AI-powered Flutter development companion. Skip boilerplate, build in real-time, and deploy without hassle. Start creating apps at lightning speed with zero setup.
Vibe Studio is your AI-powered Flutter development companion. Skip boilerplate, build in real-time, and deploy without hassle. Start creating apps at lightning speed with zero setup.
Vibe Studio is your AI-powered Flutter development companion. Skip boilerplate, build in real-time, and deploy without hassle. Start creating apps at lightning speed with zero setup.
Vibe Studio is your AI-powered Flutter development companion. Skip boilerplate, build in real-time, and deploy without hassle. Start creating apps at lightning speed with zero setup.











