Reputation: 599
I'm new to flutter and making a desktop application with flutter. Now I need to load and play audio files but found that the audio player packages don't support desktop software in windows. So if there is any way to play audio file for windows desktop software using flutter, then please give me an example.
Note: After searching a bit I found this (flutter_audio_desktop) but unfortunately it's status is "DISCONTINUED".
Upvotes: 2
Views: 3284
Reputation: 109
Working solution for 2025 is to use the dart package media_kit.
Player audioPlayer = Player();
Future<void> playAuctionsPosted() async {
try {
Media media = await Media.memory((await loadAsset(path: 'audio/auctions_created.mp3')).buffer.asUint8List());
audioPlayer.open(media);
} catch (e) {
log(e.toString());
}
}
Then in main.dart
MediaKit.ensureInitialized();
Required imports for just audio, if playing video and audio you import only the video package.
media_kit: ^1.1.11
media_kit_libs_audio: ^1.0.5
Upvotes: 0
Reputation: 599
Dart VLC is also a good option to play audio files for flutter desktop application. This package can play both audio and video files.
Upvotes: 1
Reputation: 877
just_audio plugin has a support for windows as well. You can use that plugin to play audio file. There is another plugin named audioplayers which also has windows support in the prelease version 1.0.0-rc.1.
Upvotes: 0