alert method
Implementation
Future<void> alert() async {
if (!isAlert || test?.bpmEntries.isEmpty != false || _isAlertOnCooldown) {
return;
}
final int latestBpm = test!.bpmEntries.last;
if (latestBpm >= 160 || latestBpm <= 110) {
_isAlertOnCooldown = true;
await _audioPlayer.play(AssetSource('audio/marker_beep.wav'));
// Start cooldown
Future.delayed(const Duration(seconds: 3), () {
_isAlertOnCooldown = false;
});
}
}