Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在WPF应用程序中播放声音文件_Wpf - Fatal编程技术网

在WPF应用程序中播放声音文件

在WPF应用程序中播放声音文件,wpf,Wpf,我将一个声音文件作为字节[]存储在数据库中。现在,我想在我的WPF程序中播放这个声音文件。我如何才能做到这一点?您需要执行以下操作: private void PlaySoundFromBytes(byte[] rawSoundBytes) { Stream rawStream = new MemoryStream(rawSoundBytes); var player = new SoundPlayer(rawStream); player.Play(); } 谢谢。顺

我将一个声音文件作为
字节[]
存储在数据库中。现在,我想在我的WPF程序中播放这个声音文件。我如何才能做到这一点?

您需要执行以下操作:

private void PlaySoundFromBytes(byte[] rawSoundBytes)
{
    Stream rawStream = new MemoryStream(rawSoundBytes);
    var player = new SoundPlayer(rawStream);
    player.Play();
}

谢谢。顺便问一下,现在几点了?这个答案对你有用吗?如果如此接近,请将其标记为答案。
SoundPlayer
如何知道播放原始字节的采样率和位深度?SoundPlayer使用的是包含音频元数据的WAV文件格式。您可以在此处找到一些文件格式文档: