title: Windows 8 store app MediaElement events not firing
body: <p>I've developing a Windows 8 app in Visual Studio 2012 ultimate but i'm having an issue with the MediaElement where the MediaOpened and MediaEnded events are not being fired.</p>
  
  <p>Below is my code:</p>
  
  <pre><code>    public static async void PlaySound(string AudioFile, RoutedEventHandler PlayerEnded)
      {
          Uri audioUri = new Uri("ms-appx:///Assets/" + AudioFile);
  
          StorageFile audioStorage = await StorageFile.GetFileFromApplicationUriAsync(audioUri);
  
          if (audioStorage != null)
          {
              var stream = await audioStorage.OpenAsync(Windows.Storage.FileAccessMode.Read);
  
              MediaElement player = new MediaElement();
  
              player.AudioCategory = AudioCategory.GameEffects;
  
              player.AutoPlay = false;
  
              player.MediaEnded += PlayerEnded;
  
              player.MediaOpened += new RoutedEventHandler(delegate(Object sender, RoutedEventArgs e)
                  {
                      player.Play();
                  });
  
              player.SetSource(stream, audioStorage.ContentType);
          }
      }
  </code></pre>
  
  <p>Basically this will be passed a button click sound file which after finish playing will call the this.Frame.Navigate method to switch to another page.  But it doesn't work since none of the events are being fired.</p>
  
  <p>If I set AutoPlay = true then it plays fine, but then events still don't get fired.</p>
  
  <p>Can anyone see what is wrong?</p>
  
  <p>Thanks for your help</p>