audio_service_win 0.0.2
audio_service_win: ^0.0.2 copied to clipboard
Platform interface allows you to use `audio_service` on Windows.
Bring rich media notifications, lock screen controls, and hardware media key support to your Flutter Windows apps..
audio_service_win
brings System Media Transport Controls (SMTC) support to Windows for the popular audio_service plugin. This enables rich media notifications, lock screen controls, and hardware media key support for your Flutter apps on Windows.
✨ Features #
- Windows System Media Transport Controls (SMTC) integration
- Media metadata (title, artist, album, artwork) display
- Media button events (play, pause, next, previous, etc.)
- Works with audio_service platform interface
- Easy setup and configuration
📦 Installation #
Add to your pubspec.yaml
:
dependencies:
audio_service_win: ^0.0.1
Then run:
flutter pub get
🛠️ Usage #
This package is a platform implementation for the audio_service
plugin on Windows. You should use the audio_service
API in your app, and this package will be used automatically on Windows if added as a dependency.
Quick Example #
Define your audio handler:
class MyAudioHandler extends BaseAudioHandler with QueueHandler, SeekHandler {
final _player = AudioPlayer();
Future<void> play() => _player.play();
Future<void> pause() => _player.pause();
Future<void> stop() => _player.stop();
// ...other callbacks...
}
Register your handler at app startup:
Future<void> main() async {
final _audioHandler = await AudioService.init(
builder: () => MyAudioHandler(),
config: AudioServiceConfig(
androidNotificationChannelId: 'com.mycompany.myapp.channel.audio', // required for Windows
androidNotificationChannelName: 'Music playback',
),
);
runApp(MyApp());
}
Send requests to your handler:
_audioHandler.play();
_audioHandler.pause();
_audioHandler.seek(Duration(seconds: 10));
_audioHandler.addQueueItem(MediaItem(
id: 'https://example.com/audio.mp3',
album: 'Album name',
title: 'Track title',
artist: 'Artist name',
artUri: Uri.parse('https://example.com/album.jpg'),
));
For more advanced usage, queue management, state broadcasting, and listening to state changes, see the full documentation at audio_service
.
💻 Platform Support #
Platform | Supported |
---|---|
Windows | ✅ |
Android | Already Supported |
iOS | Already Supported |
macOS | Already Supported |
Linux | via audio_service_mpris |
📸 Screenshot #
📬 Contact #
For questions, suggestions, or feedback, feel free to reach out:
📄 License #
This project is licensed under the MIT License.