我正在尝试使用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
发布于 2020-09-08 15:18:28
您需要确保Api compatibility Level在Edit \ Project Settings \ Player中是正确的

https://stackoverflow.com/questions/63776764
复制相似问题