Reputation:
Hi totally confused here! I can't figure out how to get my method to play a system sound (beep) on an error. The system.media class is not available. So I am totally lost!
private void SubmitApplicant_Click(object sender, RoutedEventArgs e)
{
if (!string.IsNullOrEmpty(attendenceManagment.Applicant))
attendenceManagment.CheckApplicant();
else
//play a beep
;
}
Working code:
XAML Tag
<MediaElement x:Name="myMediaElement"/>
Code behind
private void Button_Click(object sender, RoutedEventArgs e)
{
if (!string.IsNullOrEmpty(attendenceManagment.Applicant))
attendenceManagment.CheckApplicant();
else
{
myMediaElement.Source = new Uri("ms-appx:///Assets/Windows Error.wav");
myMediaElement.Play();
}
}
Upvotes: 5
Views: 1276
Reputation: 1437
You may consider using MediaElement, but you'll need to do some magic to hide it and also to load beep sound to resources yourself.
As far as I know, Beep is not available for mobile.
Upvotes: 1