Checklist
Current bug behaviour
Bug Description
The application crashes on Windows when there is no audio output device available (e.g., no speakers, disabled audio device, or remote environment without sound output).
Instead of handling the missing audio device gracefully, the plugin throws an exception and crashes the app.
- OS: Windows (tested on Windows 10/11)
- Flutter version: [your version]
- audioplayers version: [your version]
📌 Additional Context
This issue makes it difficult to run apps in:
- Virtual machines
- Remote desktops
- Systems without audio hardware
A fallback mechanism or safe exception handling would be helpful.
💡 Suggested Fix
- Check for available audio devices before playback
- Return a controlled error instead of crashing
- Provide a callback or error stream for handling this scenario
📎 Minimal Code Example
final player = AudioPlayer();
await player.play(AssetSource('audio.mp3'));
### Expected behaviour
The plugin should:
- Fail gracefully OR
- Return an error without crashing the app
### Steps to reproduce
1. Run a Flutter Windows app using `audioplayers`
2. Ensure no audio output device is available:
- Use a system without audio hardware (VM / remote desktop)
3. Try to play any audio using `AudioPlayer.play()`
### Code sample
Future<void> playAudioSafely(String assetPath, {double volume = 1.0}) async {
try {
if (await hasAudioOutput() == false) {
print('No audio output found. Skipping playback.');
return;
}
if (!Get.find<StoreController>().isOrderSoundEnabled) {
print('Audio playback is disabled in settings. Skipping playback.');
return;
}
final player = AudioPlayer();
await player.play(
AssetSource(assetPath),
volume: volume,
);
} catch (e) {
print('Failed to play audio: $e');
}
}
### Affected platforms
Windows
### Platform details
_No response_
### AudioPlayers Version
6.5.1
### Build mode
_No response_
### Audio Files/URLs/Sources
_No response_
### Screenshots
_No response_
### Logs
<!-- Code block with 2-3 relevant log lines -->
my relevant logs
<details>
<summary>Full Logs</summary>
<!-- You **must** use code blocks (or link gists) to paste in log lines. -->
my full logs or a link to a gist
Output of: flutter doctor -v
</details>
### Related issues / more information
_No response_
### Working on PR
no way
Checklist
Current bug behaviour
Bug Description
The application crashes on Windows when there is no audio output device available (e.g., no speakers, disabled audio device, or remote environment without sound output).
Instead of handling the missing audio device gracefully, the plugin throws an exception and crashes the app.
📌 Additional Context
This issue makes it difficult to run apps in:
A fallback mechanism or safe exception handling would be helpful.
💡 Suggested Fix
📎 Minimal Code Example
my relevant logs
my full logs or a link to a gist
Output of: flutter doctor -v