从网址下载后播放声音文件

时间:2013-12-19 10:25:14

标签: c# wpf audio webclient

我正在下载一个音频文件并将其存储在c#Wpf项目中的byte []中

byte[] audio = client.DownloadData(new Uri("http://static.sfdict.com/dictstatic/dictionary/audio/luna/E03/E0397400.mp3"))

我如何播放此声音文件。

1 个答案:

答案 0 :(得分:1)

你可以这样做:

byte[] audio = client.DownloadData(new Uri("http://static.sfdict.com/dictstatic/dictionary/audio/luna/E03/E0397400.mp3"))
System.IO.Stream s = new MemoryStream(audio);
SoundPlayer player = new SoundPlayer(s);
player.Play();