Audio Manager 是一個專為 Android、iOS 和 Web 平台設計的 Flutter 插件,旨在實現無縫的音樂播放。它提供強大的音訊處理功能,並內建媒體通知支援,讓使用者可直接從系統的通知欄控制播放。此套件簡化了背景音訊、歌曲元資料顯示及音樂應用中的播放控制整合。著重於跨平台的一致性,確保無論裝置為何,皆能提供順暢的使用者體驗。非常適合開發以音訊為核心的應用程式,例如音樂播放器或播客聆聽器。
適用情境
音樂播放器開發
播客應用整合
背景音頻播放
媒體通知管理
跨平台音訊控制
主要特色
內建媒體通知
跨平台支援(Android、iOS、Web)
背景音頻播放
追蹤元資料處理
用於播放控制的簡單 API
適合對象
開發音樂應用的開發者
需要背景音頻的應用
需要系統通知的項目
跨平台音訊解決方案
播客或音頻串流應用
使用建議
需要平台特定的設定
通知設計的自訂選項有限
依賴外部音頻來源
某些平台可能需要額外的權限
Web 支援的功能可能比行動裝置上的功能有限
原始 README
以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。
audio_manager
A Flutter plugin for music playback, notification handling, lock-screen controls, and desktop system media controls.
Screenshots
Android
iOS
macOS
Supported platforms
Platform
Playback / integration
iOS
AVPlayer + lock screen / Control Center
Android
MediaPlayer + MediaSession notification
macOS
AVPlayer + Now Playing / Control Center
Windows
Windows.Media.Playback + SMTC
Linux
GStreamer + MPRIS
Web
HTMLAudioElement
Installation
Add the dependency to pubspec.yaml:
dependencies:audio_manager:^1.0.0
iOS
The plugin supports both CocoaPods and Swift Package Manager (SPM) on iOS. Flutter 3.24+ integrates it via SPM automatically; otherwise it falls back to CocoaPods.
Add the following permissions in the info.plist file
⚠️ Some methods are invalid in the simulator, please use the real machine
⚠️ Only add UIBackgroundModes -> audio when your app really keeps playing audio in the background. If the app does not provide background audio, App Store review may reject it with guideline 2.5.4.
Android
Since Android9.0 (API 28), the application disables HTTP plaintext requests by default. To allow requests, add android:usesCleartextTraffic="true" in AndroidManifest.xml
⚠️ Android minimum supported version 23 (app/build.gradle -> minSdkVersion: 23)
⚠️ Compile against Android SDK 34 or newer when targeting Android 12+ apps. The plugin now requires explicit PendingIntent flags, a media playback foreground service type, and Android 13+ receiver export flags.
⚠️ Android notification and lock-screen controls use MediaSession / MediaStyle. Custom notification icons and full custom layouts are not exposed by the public API.
Desktop (macOS / Windows / Linux)
Desktop playback integrates with the system media controls: macOS Now Playing / Control Center, Windows SMTC (taskbar media flyout), and Linux MPRIS.
macOS: to stream network audio, add the com.apple.security.network.client entitlement to the app's entitlements files (DebugProfile.entitlements / Release.entitlements):