【发布时间】:2015-11-30 17:07:07
【问题描述】:
- 如何将音频文件转换为 byte[] 并使用 Naudio 播放? (代码将不胜感激)
-
也与上述问题有关,如何使用 Naudio 在 Resource 中播放音频文件? 对于第二个问题,我有这个代码:
IWavePlayer waveOutDevice; IWaveProvider provider; public void PlaySound(byte[] sound) { waveoutDevice = new WaveOutEvent(); provider = new RawSourceWaveStrem(new MemoryStream(sound), new WaveFormat(); if (waveOutDevice != null) waveOutDevice.Stop(); waveOutDevice.Init(provider); waveOutDevice.Play(); }然后在我的表单构造函数中执行类似的操作 -
PlaySound(Properties.Resources.beepsound)beepsound 是声音文件....但我只是在调用此方法时听到噪音。有什么问题?
【问题讨论】:
-
您可以直接使用 naudio 播放声音。您不需要自己将文件转换为 byte[]
-
我知道声音文件可以直接播放,但在我的情况下,我需要转换为 byte[] 以避免处理器在硬盘上搜索文件。