just_audio_background
0.0.1-beta.17, released 2 years ago by ryanheise.com
Adds background playback and media controls to a just_audio player
What it does
It plugs into just_audio to enable background playback, media notifications, lock‑screen controls and remote button handling across Android, iOS, web and macOS. The package handles the platform‑specific setup and exposes a simple API for initializing the background service.
AI-written summary of version 0.0.1-beta.17, based on the package's README and metadata. Report an inaccuracy
Use it when
- You have a single AudioPlayer instance and want background playback with standard media controls
- You need quick integration without writing custom audio_service code
Skip it when
- Your app requires multiple simultaneous audio players
- You need fine‑grained control over notification buttons or custom media actions
Strengths
- Easy to add to existing just_audio projects
- Cross‑platform support (Android, iOS, web, macOS)
- Handles notification and remote control plumbing automatically
Weaknesses
- Limited to one AudioPlayer instance
- Requires manual Android/iOS manifest changes
- Not suitable for complex audio service features
Setup
- Kind
- Flutter widgets
- Effort
- Medium
- Code generation
- No
- Direct dependencies
- 6
Android: add WAKE_LOCK, FOREGROUND_SERVICE, optionally FOREGROUND_SERVICE_MEDIA_PLAYBACK permissions; add AudioServiceActivity, AudioService, MediaButtonReceiver to AndroidManifest. iOS: add UIBackgroundModes audio to Info.plist. No build_runner needed.
```dart
Future<void> main() async {
await JustAudioBackground.init(
androidNotificationChannelId: 'com.example.channel.audio',
androidNotificationChannelName: 'Audio playback',
androidNotificationOngoing: true,
);
runApp(MyApp());
}
```Alternatives
Packages that do the same job and could replace just_audio_background.
- kplayer
A cross-platform audio player wrapper supporting assets, network, files, and bytes.
47Compare - video_player_android
Android implementation of the video_player plugin
88Compare - video_player_avfoundation
iOS and macOS implementation of the video_player plugin
86Compare - media_kit_video
Native implementation for video playback in package:media_kit.
73Compare
Works with
Packages commonly used together with just_audio_background: ones it builds on, ones built on it, and its own family.
- rxdartjust_audio_background depends on itImplementation of the ReactiveX API for asynchronous programming leveraging native Dart Streams.
- synchronizedjust_audio_background depends on itLock mechanism to prevent concurrent access to asynchronous code.
- audio_sessionjust_audio_background depends on itManages iOS audio session categories, Android audio attributes, and audio focus/ducking.
- just_audio_platform_interfacejust_audio_background depends on itA platform interface for the just_audio plugin, defining the contract for platform-specific implementations.
- audio_servicejust_audio_background depends on itFlutter plugin for background audio playback with media controls.
- just_audioSame familyFeature‑rich audio player for Flutter supporting gapless playlists and multiple sources
- just_audio_webSame familyWeb platform implementation of just_audio for audio playback.
- just_waveformSame familyExtracts waveform data from audio files for visual rendering.