The following code plays a short sound (a simple wav file) every time a button is clicked.
But after putting the computer to sleep and waking it up again - it doesn't play the sound anymore when the button is clicked (though the event handler Button_Click is being called). Why?
The code:
public partial class MainWindow : Window
{
MediaPlayer player1;
public MainWindow()
{
InitializeComponent();
player1 = new MediaPlayer();
player1.Open(new Uri("Some\\Path\\sound.wav"));
}
private void Button_Click(object sender, RoutedEventArgs e)
{
player1.Position = TimeSpan.Zero;
player1.Play();
}
}
I know I can Open the file again when the user logs on again. But that shouldn't be needed.
