Files

33 lines
950 B
C#
Raw Permalink Normal View History

#nullable enable
using System;
using System.Media;
using System.Windows;
namespace ReminderOrganizer.Services
{
/// <summary>Plays the reminder chime (Assets/reminder.wav, embedded as WPF resource).</summary>
public static class SoundService
{
private static SoundPlayer? _player;
public static void PlayReminder()
{
try
{
if (_player == null)
{
var res = Application.GetResourceStream(new Uri("pack://application:,,,/Assets/reminder.wav"));
if (res == null) { SystemSounds.Asterisk.Play(); return; }
_player = new SoundPlayer(res.Stream);
_player.Load();
}
_player.Play();
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"[Sound] {ex.Message}");
}
}
}
}