Currently I had developed Windows 10 Mobile Apps that can play sounds/audio functions. When I write this statement to play the audio/sounds , it will display the error when the Image Tapped event is Tapped. The Source code as below:
MediaElement mysong = new MediaElement();
try
{
var folder = await StorageFolder.GetFolderFromPathAsync(@"ms-appx://Assets/Media/");
if (folder != null)
{
var file = await folder.GetFileAsync("police_alarm.mp3");
if (file != null)
{
var stream = await file.OpenReadAsync();
mysong.SetSource(stream, file.ContentType);
mysong.Volume = 100;
mysong.Play();
}
}
else
{
MessageDialog dialog = new MessageDialog("Siren can't play !!! Please keep yourself safe !!!", "Error");
await dialog.ShowAsync();
}
}
catch(Exception ex)
{
MessageDialog dialog = new MessageDialog(ex.ToString(), "Error");
await dialog.ShowAsync();
}
is that any solutions for this?
Thank You.
