1

我正在使用 SKype4Com,似乎每当我播放 wav 文件时,我都无法换回我的麦克风。我真的必须结束通话,然后回电才能再次使用我的麦克风。这是一些代码:

DeviceType = TCallIoDeviceType.callIoDeviceTypeFile
var filename = Path.GetTempFileName();
using (this.Speak = new SpeechSynthesizer())
{
    this.Speak.SetOutputToWaveFile(
        filename,
        new System.Speech.AudioFormat.SpeechAudioFormatInfo(
            16000,
            System.Speech.AudioFormat.AudioBitsPerSample.Sixteen,
            System.Speech.AudioFormat.AudioChannel.Mono));
    this.Speak.Speak(reply);
    this.Speak.SetOutputToDefaultAudioDevice();
    this.Speak.Speak(reply);
    CurrentCall.set_InputDevice(DeviceType, filename);
    this.skype.SendMessage(pMessage.FromHandle, reply);
    this.Speak.SetOutputToNull();
    this.Speak.Dispose();
    CurrentCall.set_InputDevice(DeviceType,"");
}
CurrentCall.set_InputDevice(TCallIoDeviceType.callIoDeviceTypeSoundcard, "default");
Dispatcher.Invoke(new Action(() =>
    {
        tb1.Text += "sound card: ";
        tb1.Text += CurrentCall.get_InputDevice(TCallIoDeviceType.callIoDeviceTypeSoundcard);
        tb1.Text += Environment.NewLine;
        tb1.Text += "port: ";
        tb1.Text += CurrentCall.get_InputDevice(TCallIoDeviceType.callIoDeviceTypePort);
        tb1.Text += Environment.NewLine;
        tb1.Text += "file: ";
        tb1.Text += CurrentCall.get_InputDevice(TCallIoDeviceType.callIoDeviceTypeFile);
        tb1.Text += Environment.NewLine;
    }));
}

有什么想法可以让它发挥作用吗?自动完成后,我只听到永远的沉默。

4

2 回答 2

0

您可以尝试检查您播放的文件是否仍然忙。

do
{
    System.Threading.Thread.Sleep(1000);
} while (IsBusy(filename));
CurrentCall.set_InputDevice(DeviceType,"");

IsBusy方法声明如下:

public bool IsBusy(string filePath)
{
    try
    {
        using (FileStream stream = File.OpenWrite(filePath))
        {
            stream.Close();
            return false;
        }
    }
    catch (IOException)
    {
        return true;
    }
}
于 2013-01-10T11:14:18.717 回答
0

有一种方法可以使用 tcp 将音频放入 Skype,所以我这样做了。

于 2013-05-19T01:56:40.200 回答