我正在尝试播放存储在称为 bytes 的字节数组中的 wav 声音。 我知道我应该将字节数组转换为 wav 文件并将其保存在我的本地驱动器中,然后调用保存的文件,但我无法将字节数组转换为 wav 文件。
请帮我提供示例代码,将 wav 声音的字节数组转换为 wav 文件。
这是我的代码:
protected void Button1_Click(object sender, EventArgs e)
{
byte[] bytes = GetbyteArray();
//missing code to convert the byte array to wav file
.....................
System.Media.SoundPlayer myPlayer = new System.Media.SoundPlayer(myfile);
myPlayer.Stream = new MemoryStream();
myPlayer.Play();
}
最佳答案
试试这个:
System.IO.File.WriteAllBytes("yourfilepath.wav", bytes);
关于c# - 将字节数组转换为wav文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2665362/