Play an audio file in Windows 7 Phone

后端 未结 4 1759
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-25 14:32

I am working on Windows 7 based application development in Silverlight. I have not been able to find a way to play a an audio file in windows 7 phone programmatically. I hav

4条回答
  •  生来不讨喜
    2020-12-25 14:54

    Use Xna to play the sound. You can cross reference Xna from a Silverlight app though, for playing a sound file, you need to the following:

    using Microsoft.Xna.Framework;
    using Microsoft.Xna.Framework.Audio
    // ...
    Stream stream = TitleContainer.OpenStream("sounds/bonk.wav");
    SoundEffect effect = SoundEffect.FromStream(stream);
    FrameworkDispatcher.Update();
    effect.Play();
    

    All the best for your application development!

提交回复
热议问题