我正在尝试在Windows Phone 7应用程序的Silverlight中播放音频。我有一个MP3音频文件,其构建操作设置为资源。要播放声音,我使用:为什么Windows Media Player无法播放此音频?
SoundEffectInstance sfi = null;
...
Stream source = Application.GetResourceStream(new Uri("/Bird Calls;component/Crow.mp3", UriKind.Relative)).Stream;
Microsoft.Xna.Framework.Audio.SoundEffect effect = SoundEffect.FromStream(source);
sfi = effect.CreateInstance();
sfi.Play();
此代码在SoundEffect.FromStream方法中引发InvalidOperationException。
查看Cong Tran的替代方案 – msbg