This is my code, I took it from an example from MSDN forum (https://social.msdn.microsoft.com/Forums/ie/en-US/ddb1b7f1-e988-40c7-8e1e-eaf6d8573ec2/uwp-how-to-play-sound-from-wav-fileresource?forum=wpdevelop).
private DispatcherTimer timer;
private TimeSpan myTime = new TimeSpan(0, 0, 60);
public MainPage()
{
this.InitializeComponent();
timer = new DispatcherTimer();
timer.Interval = new TimeSpan(0, 0, 1);
timer.Tick += Timer_Tick;
timer.Start();
}
private void Timer_Tick(Object sender, object e)
{
if (myTime.Seconds > 0)
{
myTime -= new TimeSpan(0, 0, 1);
MainTextBlock.Text = myTime.ToString();
}
else
{
timer.Stop();
MainTextBlock.Text = "Finished";
PlaySound_Async();
}
}
private async void PlaySound_Async()
{
MediaElement timesup = new MediaElement();
Windows.Storage.StorageFolder folder = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync("Assets");
Windows.Storage.StorageFile file = await folder.GetFileAsync("timesup.mp3");
var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read);
timesup.SetSource(stream, file.ContentType);
timesup.Play();
}
And this is the exception I get this exception I have already added the file in the right folder