Alert sound in Windows Phone 8.1 App

守給你的承諾、 提交于 2019-12-08 14:48:50

问题


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

来源:https://stackoverflow.com/questions/28231170/alert-sound-in-windows-phone-8-1-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!