When my main page opens up for my app, I need it to play a sound (no problem there), the sound needs to keep playing when frames switch(again, no problem with that)
My problem arises when I switch from another frame to my mainpage, when I do that, it will start playing the same sound on top of the old one
private async void PlaySound()
{
if (soundElement.AudioStreamCount == 0)
{
var file =
await
(await Package.Current.InstalledLocation.GetFolderAsync("Common")).GetFileAsync("Opening Theme.mp3");
var stream = await file.OpenAsync(FileAccessMode.Read);
this.soundElement.SetSource(stream, file.ContentType);
this.soundElement.Play();
this.soundElement.IsLooping = true;
}
}
I call this method in the MainPage initializer, I believe the problem is the check that I am doing at the beginning of the method, but I can't find a static MediaElement method that will tell me if any sound is playing when the method is called