1
我使用NAudio將音頻文件輸出到揚聲器和窗口10筆記本電腦上的耳機。我創建了兩個WaveOut並分配了相應的設備編號。但是當耳機插入時,我不能在這裏聽到揚聲器的音頻。誰能讓我知道如何解決這個問題?這裏是我的代碼(它適用於耳機或單獨的揚聲器很好,但我希望聽到來自他們的聲音在同一時間):同時向揚聲器和耳機輸出音頻?
var input1 = new Mp3FileReader(PATH + "left.mp3");
var input2 = new Mp3FileReader(PATH + "right.mp3");
var waveProvider = new MultiplexingWaveProvider(new IWaveProvider[] { input1, input2 }, 2);
var input3 = new Mp3FileReader(PATH + "left.mp3");
int channel = ((Mp3FileReader)input1).Mp3WaveFormat.Channels;
Debug.WriteLine(channel);
waveProvider.ConnectInputToOutput(0, 0);
waveProvider.ConnectInputToOutput(3, 1);
WaveOut wave = new WaveOut();
wave.DeviceNumber = 1;
wave.Init(waveProvider);
WaveOut wave1 = new WaveOut();
wave1.DeviceNumber = 0;
wave1.Init(input3);
wave.Play();
wave1.Play();