Alert sound in Windows Phone 8.1 App

2019-06-14 04:11发布

I am writing a Windows Phone 8.1 App (WINRT). On click of a button, a beep must play. So i used MediaElement, but the problem is it pauses the MediaPlayer song. I even tried to change AudioCategory /Stream type but its not helping.

Stream types

Any solution?

         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);
      }

Then on button click :

MediaElementObject.Play();

0条回答
登录 后发表回答