A powerful Flutter plugin for integrating your app with system-level media controls (lock screen, notification, media center) across Android, iOS, macOS, Windows, and Web.
This plugin allows your app to display media metadata (title, artist, artwork) in the system's media center and respond to system actions like Play, Pause, Skip, and Seek.
| Platform | Support | Underlying API |
|---|---|---|
| Android | ✅ | Media3 MediaSessionService |
| iOS | ✅ | MPNowPlayingInfoCenter / MPRemoteCommandCenter |
| macOS | ✅ | MPNowPlayingInfoCenter / MPRemoteCommandCenter |
| Windows | ✅ | SystemMediaTransportControls (SMTC) |
| Web | ✅ | Media Session API |
- 🎵 Metadata Synchronization: Display title, artist, album, and artwork in the lock screen or system media center.
- ⏯️ Playback State Control: Sync playing/paused status and current playback position.
- 📡 Native Media Actions: Receive events from system controls (Play, Pause, Skip, Seek, etc.) and handle them in your Dart code.
- 🎧 Android Background Support: Automatically handles foreground service requirements for media playback on Android.
Add flutter_media_session to your pubspec.yaml:
dependencies:
flutter_media_session: ^2.0.0-
Foreground Service Permission: Ensure your
android/app/src/main/AndroidManifest.xmlincludes the necessary permissions (usually added by the plugin automatically, but worth verifying):<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
-
Service Declaration: The plugin handles the service declaration internally via its manifest merger.
-
Background Audio: Add the
audiobackground mode to yourInfo.plist:<key>UIBackgroundModes</key> <array> <string>audio</string> </array>
This allows the Now Playing controls to work when the app is backgrounded.
-
Audio Session: Call
requestNotificationPermission()before activating the session. On iOS, this configures theAVAudioSessionwith the.playbackcategory.
No specific configuration is required. The plugin uses MPNowPlayingInfoCenter and MPRemoteCommandCenter directly.
For proper application identification (avoiding "Unknown Application" in the system media center), please refer to the:
No specific configuration is required. The plugin uses standard JS interop on Web.
For detailed instructions and examples on how to initialize the plugin, manage media metadata, respond to system media events, and customize available media controls layout dynamically, please refer to our full breakdown:
This project is licensed under the MIT License - see the LICENSE file for details.