0
A
回答
1
即使使用Silverlight,仍然可以引用XNA库。如果你这样做,你可以使用SoundEffect
类来播放音乐:
Uri uri = new Uri("file.wav", UriKind.Relative);
StreamResourceInfo sri = Application.GetResourceStream(uri);
SoundEffect effect = SoundEffect.FromStream(sri.Stream);
effect.Play();
5
查尔斯Petzold的最近的博客上讲述播放音乐文件。你必须对它进行测试,看它是否保持播放:
http://www.charlespetzold.com/blog/2010/11/Playing-Music-Files-on-WP7.html
如果还是不行,请海梅·罗德里格斯的对锁屏下运行的应用程序后:
_http:// blogs.msdn.com/b/jaimer/archive/2010/11/01/running-a-windows-phone-application-under-the-lock-screen.aspx
希望这些链接帮助!
1
你甚至都不需要添加任何XNA库,因为Silverlight有内置MediaElement
既能从后台代码中使用(LayoutRoot是主电网):
MediaElement element = new MediaElement();
element.Source = new Uri("sound.mp3",UriKind.Relative);
LayoutRoot.Children.Add(element);
element.Play();
和XAML:
<MediaElement Source="sound.mp3" AutoPlay="True"></MediaElement>
你在使用Silverlight还是XNA? – ctacke 2010-07-13 13:52:21
silverlight for windows phone应用开发。 – Sravanti 2010-07-14 03:55:14
[在windows phone 7中添加媒体元素?]的可能重复?(http://stackoverflow.com/questions/3287360/adding-media-element-in-windows-phone-7) – dthorpe 2011-11-02 06:30:33