【问题标题】:Using Vorbis and NAudio to play OGG files使用 Vorbis 和 NAudio 播放 OGG 文件
【发布时间】:2014-08-28 18:46:37
【问题描述】:

我正在尝试使用 NVorbis 和 NAudio 播放 OGG 文件流,如我尝试访问 VorbisWaveReader 类的文档中所述,但没有成功,这是我的代码:

using System;
using System.Collections.Generic;
using System.Text;
using NVorbis;
using NAudio;

namespace Paradise
{
    class Program
    {
        static void Main(string[] args)
        {
            using (var vorbis = new NVorbis.NAudioSupport.VorbisWaveReader(@"C:\PATH\TO\OGG\FILE.ogg"))
            using (var waveOut = new NAudio.Wave.WaveOut())
            {
            waveOut.Init(vorbis);
            waveOut.Play();
            }
        }
    }
}

我收到以下错误:

type or namespace name 'VorbisWaveReader' does not exist in the namespace 'NVorbis.NAudioSupport'

它看起来很基本,应该可以工作,我可以在源代码中看到 VorbisWaveReader 存在于代码中,你能帮我看一下吗?

谢谢!

【问题讨论】:

  • 您使用的是 DLL 还是源代码?
  • 确保您在项目中同时引用了 NVorbis.dll 和 NVorbis.NAudioSupport.dll(当然还有 NVorbis.dll)。此外,waveOut.Play() 是异步的,因此您实际上不会听到任何使用此代码的声音(除了可能是一两声流行音乐)。在退出 using 子句之前,您必须以某种方式延迟。

标签: c# naudio ogg vorbis


【解决方案1】:

NVorbis.NAudioSupport改成NAudio.Vorbis

在包管理器控制台中输入:

Install-Package NAudio.Vorbis

【讨论】:

  • 嗨 @Hossein 是否可以使用 NVorbis 库将 OGG 音频文件剪切到所需的时隙?
猜你喜欢
  • 2016-02-25
  • 2019-11-23
  • 2010-12-27
  • 1970-01-01
  • 2015-12-06
  • 1970-01-01
  • 2019-03-23
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多