I a Windows 8 Metro App (C#/XAML): How can I trigger the same sound effect twice so that it plays simultaneously.
The second play should start before the first has finished.
Related questions are:
Playing two sounds simultaneously c# and Play two sounds simultaneusly
I found this class for XNA which does what I want, but is not available under Metro: http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.audio.soundeffectinstance.aspx
Just create a separate media element for every sound effect.
(not sure I need to relocate the file every time)
public async void PlayLaserSound()
{
var package = Windows.ApplicationModel.Package.Current;
var installedLocation = package.InstalledLocation;
var storageFile = await installedLocation.GetFileAsync("Assets\\Sounds\\lazer.mp3");
if (storageFile != null)
{
var stream = await storageFile.OpenAsync(Windows.Storage.FileAccessMode.Read);
MediaElement snd = new MediaElement();
snd.SetSource(stream, storageFile.ContentType);
snd.Play();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With