A comprehensive Flutter plugin that provides customizable audio player components with support for both single audio playback and playlist management. Built with modern Flutter architecture and extensive customization options.
- 🎵 Full Audio Player - Complete audio player with progress slider, time display, and controls
- 🎧 Mini Player - Compact audio player for minimal UI footprint
- 📱 Playlist Support - Handle multiple audio tracks with next/previous navigation
- 🎨 Highly Customizable - Customize icons, colors, styles, and themes
- 🔄 Stream-based Architecture - Real-time position updates and status changes
- 📊 Progress Tracking - Visual progress slider with seek functionality
- 🎯 Event Callbacks - Comprehensive callback system for all player events
- 🖼️ Audio Artwork - Display audio artwork with customizable dimensions
- ⚡ Performance Optimized - Efficient state management and memory usage
Add this to your package's pubspec.yaml file:
dependencies:
flutter_audio_player_plugin: ^1.0.0import 'package:flutter_audio_player_plugin/flutter_audio_player_plugin.dart';
// Initialize the audio player
final audioPlayer = MethodChannelFlutterAudioPlayerPlugin();
// Create audio info
final audioInfo = AudioInfo(
title: 'Song Title',
artist: 'Artist Name',
audioUrl: 'https://example.com/audio.mp3',
picture: 'https://example.com/artwork.jpg',
);
// Use the player widget
Player(
audioPlayer: audioPlayer,
audioInfo: audioInfo,
)The data model for audio metadata:
class AudioInfo {
final String? audioUrl; // Audio file URL
final String? title; // Song title
final String? artist; // Artist name
final String? picture; // Artwork URL
}A full-featured audio player with progress slider and complete controls.
| Prop | Type | Required | Description |
|---|---|---|---|
audioPlayer |
MethodChannelFlutterAudioPlayerPlugin |
✅ | Audio player instance |
audioInfo |
AudioInfo? |
❌ | Single audio information |
audiosList |
List<AudioInfo>? |
❌ | List of audio tracks for playlist |
iconStyle |
Map<String, dynamic> |
❌ | Icon styling properties |
customizedIcons |
Map<PlayerIcons, IconData> |
❌ | Custom icons for controls |
sliderStyles |
SliderThemeData? |
❌ | Progress slider styling |
imageWidth |
double? |
❌ | Artwork width (default: 100.0) |
imageHeight |
double? |
❌ | Artwork height (default: 100.0) |
onPlay |
Function()? |
❌ | Play event callback |
onPause |
Function()? |
❌ | Pause event callback |
onResume |
Function()? |
❌ | Resume event callback |
onStop |
Function()? |
❌ | Stop event callback |
onPlayNext |
Function()? |
❌ | Next track event callback |
onPlayPrevious |
Function()? |
❌ | Previous track event callback |
onPositionChanged |
Function(int)? |
❌ | Position change callback |
onCompletion |
Function()? |
❌ | Audio completion callback |
Single Audio Player:
Player(
audioPlayer: audioPlayer,
audioInfo: AudioInfo(
title: 'My Song',
artist: 'Artist Name',
audioUrl: 'https://example.com/song.mp3',
picture: 'https://example.com/artwork.jpg',
),
onPlay: () => print('Audio started playing'),
onPause: () => print('Audio paused'),
onCompletion: () => print('Audio finished'),
)Playlist Player:
Player(
audioPlayer: audioPlayer,
audiosList: [
AudioInfo(title: 'Song 1', artist: 'Artist 1', audioUrl: 'url1'),
AudioInfo(title: 'Song 2', artist: 'Artist 2', audioUrl: 'url2'),
AudioInfo(title: 'Song 3', artist: 'Artist 3', audioUrl: 'url3'),
],
onPlayNext: () => print('Next track'),
onPlayPrevious: () => print('Previous track'),
)A compact audio player for minimal UI footprint.
| Prop | Type | Required | Description |
|---|---|---|---|
audioPlayer |
MethodChannelFlutterAudioPlayerPlugin |
✅ | Audio player instance |
audioInfo |
AudioInfo? |
❌ | Single audio information |
audiosList |
List<AudioInfo>? |
❌ | List of audio tracks |
iconStyle |
Map<String, dynamic> |
❌ | Icon styling properties |
customizedIcons |
Map<PlayerIcons, IconData> |
❌ | Custom icons |
backgroundColor |
Color |
❌ | Background color (default: Colors.black12) |
onPlay |
Function()? |
❌ | Play event callback |
onPause |
Function()? |
❌ | Pause event callback |
onResume |
Function()? |
❌ | Resume event callback |
onStop |
Function()? |
❌ | Stop event callback |
onPlayNext |
Function()? |
❌ | Next track callback |
onPlayPrevious |
Function()? |
❌ | Previous track callback |
onPositionChanged |
Function(int)? |
❌ | Position change callback |
onCompletion |
Function()? |
❌ | Completion callback |
MiniPlayer(
audioPlayer: audioPlayer,
audioInfo: audioInfo,
backgroundColor: Colors.grey[200],
onPlay: () => print('Mini player started'),
)Reusable audio control buttons component.
| Prop | Type | Required | Description |
|---|---|---|---|
handlePlayPauseAudio |
Function() |
✅ | Play/pause handler |
handleStopAudio |
Function() |
✅ | Stop handler |
handleSeekBackward |
Function() |
✅ | Seek backward handler |
handleSeekForward |
Function() |
✅ | Seek forward handler |
handlePlayNextAudio |
Function() |
✅ | Next track handler |
handlePlayPreviousAudio |
Function() |
✅ | Previous track handler |
isPlaying |
bool |
✅ | Current playing state |
iconStyle |
Map<String, dynamic> |
❌ | Icon styling |
customizedIcons |
Map<PlayerIcons, IconData> |
❌ | Custom icons |
isMinPlayer |
bool |
❌ | Mini player mode (default: false) |
Displays audio artwork with customizable properties.
| Prop | Type | Required | Description |
|---|---|---|---|
audioPicture |
String |
✅ | Image URL |
width |
double |
❌ | Image width (default: 700) |
height |
double |
❌ | Image height (default: 200) |
alignment |
Alignment |
❌ | Image alignment (default: center) |
fit |
BoxFit |
❌ | Image fit (default: contain) |
Customizable text widget with default styling.
| Prop | Type | Required | Description |
|---|---|---|---|
text |
String |
✅ | Text content |
style |
TextStyle |
❌ | Text styling (default: 18px bold) |
Map<PlayerIcons, IconData> customIcons = {
PlayerIcons.playIcon: Icons.play_arrow_outlined,
PlayerIcons.pauseIcon: Icons.pause_outlined,
PlayerIcons.skipPreviousIcon: Icons.skip_previous_outlined,
PlayerIcons.skipNextIcon: Icons.skip_next_outlined,
PlayerIcons.replay10Icon: Icons.replay_10_outlined,
PlayerIcons.forward10: Icons.forward_10_outlined,
};
Player(
audioPlayer: audioPlayer,
audioInfo: audioInfo,
customizedIcons: customIcons,
)Map<String, dynamic> iconStyle = {
'color': Colors.blue,
'iconSize': 45,
};
Player(
audioPlayer: audioPlayer,
audioInfo: audioInfo,
iconStyle: iconStyle,
)SliderThemeData sliderTheme = SliderThemeData(
trackHeight: 10.0,
thumbShape: RoundSliderThumbShape(enabledThumbRadius: 8.0),
overlayShape: RoundSliderOverlayShape(overlayRadius: 16.0),
activeTrackColor: Colors.tealAccent,
inactiveTrackColor: Colors.greenAccent,
thumbColor: Colors.limeAccent,
);
Player(
audioPlayer: audioPlayer,
audioInfo: audioInfo,
sliderStyles: sliderTheme,
)The plugin provides various player statuses through the PlayerStatus enum:
loading- Audio is loadingplaying- Audio is currently playingpaused- Audio is pausedstopped- Audio is stoppederror- An error occurredcompleted- Audio playback completedidle- Player is idleready- Player is ready to play
All player components support comprehensive event callbacks:
Player(
audioPlayer: audioPlayer,
audioInfo: audioInfo,
onPlay: () => print('Audio started'),
onPause: () => print('Audio paused'),
onResume: () => print('Audio resumed'),
onStop: () => print('Audio stopped'),
onPlayNext: () => print('Next track'),
onPlayPrevious: () => print('Previous track'),
onPositionChanged: (position) => print('Position: $position'),
onCompletion: () => print('Audio completed'),
)The example/ folder contains a complete demonstration app showcasing:
- Basic player usage
- Playlist functionality
- Custom icon implementation
- Style customization
- Mini player usage
- Event handling
To run the example:
cd example
flutter pub get
flutter run- ✅ Android
- ✅ iOS
- ✅ Web (with limitations)
- Flutter SDK:
>=3.3.0 - Dart SDK:
^3.5.4 - plugin_platform_interface:
^2.0.2
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues or have questions, please:
- Check the example app for usage patterns
- Review the documentation above
- Open an issue on GitHub with detailed information about your problem
Note: This plugin requires proper audio permissions on Android and iOS. Make sure to add the necessary permissions to your app's manifest files.