0

I am writing a Windows Phone 8.1 App (WINRT).

I want a 1 second tick sound to get played when user clicks on a button. I tried using MediaElement, but the problem is it pauses the MediaPlayer song. I even tried to change AudioCategory /Stream type but its not helping.

For example, while using whatsapp,messenger,etc, if a sound comes from app, it does not pause our xbox music. How to achieve this?

 private void CreateMediaElements()
      {
          //WINRT:
          MediaElementObject = new MediaElement();
          MediaElementObject.AudioCategory = AudioCategory.Alerts;

          MediaElementObject.IsLooping = false;
          MediaElementObject.Source = new Uri("ms-appx:///Audio/General/Alerts/ExitCloseAlert_01.wav", UriKind.RelativeOrAbsolute);
          MediaElementObject.Height = 0;
          MediaElementObject.Width = 0;

          MediaElementObject.AutoPlay = false;
          LoginPageMainGrid.Children.Add(MediaElementObject);
      }
Atif Shabeer
  • 553
  • 6
  • 18
  • Isn't one question enough? The code is 1:1 identical.. – Fred Jan 30 '15 at 21:45
  • possible duplicate of [Alert sound in Windows Phone 8.1 App](http://stackoverflow.com/questions/28231170/alert-sound-in-windows-phone-8-1-app) – Fred Jan 30 '15 at 21:46

0 Answers0