I have this code:
MediaElement player = new MediaElement();
Windows.Storage.StorageFolder folder;
Windows.Storage.StorageFile file;
string FileName = "";
private async void Play(string Tno, string Cno)
{
folder = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync("Assets");
for (int i = 1; i <= 4; i++)
{
switch (i)
{
case 1:
FileName = "Sound\\mysound1.wav";
break;
case 2:
FileName = "Sound\\mysound2.wav";
break;
case 3:
FileName = "Sound\\mysound3.wav";
break;
case 4:
FileName = "Sound\\mysound4.wav";
break;
}
file = await folder.GetFileAsync(FileName);
player.SetSource(await file.OpenAsync(Windows.Storage.FileAccessMode.Read), file.ContentType);
player.Play();
}
}
It plays sound "mysound4.wav". When I tracked the code, it plays the 4 files too quickly without any delays. So how can I play the second file only when the first one is finished?