c# - Unity 中带有 NAudio WaveOut 的 PlatformNotSupportedException
问题描述
我正在尝试NAudio
在Unity
项目中使用的辅助声卡上播放声音。
它可以使用Play
编辑器中的按钮成功运行,但不能在可执行文件中运行。
这是我得到的错误:
System.PlatformNotSupportedException: Operation is not supported on this platform.
at System.Windows.Forms.Form..ctor () [0x00000] in <0b0c181c86c84da989ad80998d3a0a84>:0
at NAudio.Wave.WaveWindow.OnMdiChildActivate (System.EventArgs e) [0x00000] in <554b80148c284b99953f098db496ebd4>:0
at (wrapper remoting-invoke-with-check) NAudio.Wave.WaveWindow..ctor(NAudio.Wave.WaveInterop/WaveCallback)
at NAudio.Wave.WaveCallbackInfo.Connect (NAudio.Wave.WaveInterop+WaveCallback callback) [0x00009] in <554b80148c284b99953f098db496ebd4>:0
at NAudio.Wave.WaveOut..ctor (NAudio.Wave.WaveCallbackInfo callbackInfo) [0x0004e] in <554b80148c284b99953f098db496ebd4>:0
at NAudio.Wave.WaveOut..ctor () [0x00014] in <554b80148c284b99953f098db496ebd4>:0
at MainVideoScript.playSound (System.Int32 deviceNumber) [0x0002e] in <0d2c0b09fee74d5099fd910768d58ea9>:0
我正在运行Windows 10
,Target platform=Windows
那么为什么平台不支持我正在尝试做的事情?我能改变什么?
这是我要运行的代码:
string soundPath = System.IO.Path.Combine(Application.streamingAssetsPath, @"clic2.wav");
waveReader = new NAudio.Wave.WaveFileReader(soundPath);
var wave = new NAudio.Wave.WaveOut();
wave.DeviceNumber = deviceNumber;
wave.Init(waveReader);
wave.Play();
我正在使用 2019.2.8f1
解决方案
推荐阅读
- python - 应该如何定义全局变量以在 Python 中的模块层次结构中访问?
- docker - 需要“y”响应的 Docker 构建映像
- excel - 根据 If InStr 的值选择多个单元格,复制并粘贴到下一行的新工作表,然后向下递增到下一次出现
- r - 将列乘以 10^{某个指数}
- laravel - attach($user->id) 不起作用并呈现为 null
- javascript - 当我想从提款输入中添加余额时出现 Javascript 编码问题
- haproxy - HAProxy 后端限制会话的总和是错误的
- c - 使用 *x 和 int x 有什么区别?
- spring - 通过 php 和 Spring boot 中的 Rest 在本地机器中通信容器
- php - 我想在 php 中输入怀孕日期后计算孕妇的预产期