flutter: windows: audios: Return functions if platform is Windows

This commit is contained in:
Calcitem 2021-05-09 23:25:47 +08:00
parent 2ddc9ca221
commit b42b3893a7
1 changed files with 16 additions and 0 deletions

View File

@ -39,6 +39,10 @@ class Audios {
static var winSoundId;
static Future<void> loadSounds() async {
if (Platform.isWindows) {
return;
}
_soundpool ??= Soundpool();
drawSoundId ??=
@ -64,16 +68,28 @@ class Audios {
}
static Future<void> _playSound(var soundId) async {
if (Platform.isWindows) {
return;
}
_alarmSoundStreamId = await _soundpool!.play(await soundId);
}
static Future<void> _stopSound() async {
if (Platform.isWindows) {
return;
}
if (_alarmSoundStreamId != null && _alarmSoundStreamId! > 0) {
await _soundpool!.stop(_alarmSoundStreamId!);
}
}
static Future<void> disposePool() async {
if (Platform.isWindows) {
return;
}
_soundpool!.dispose();
}