我正在尝试捕获skype呼叫,并将其保存在我的PC中,扩展名为wave,但每次我尝试mciSendString时,它都无法创建声音文件。
以下是我的代码
public void Skype_CallStatus(Call call, TCallStatus status)
{
int result = 0;
Configuration config = ConfigurationManager.OpenExeConfiguration(System.Windows.Forms.Application.ExecutablePath);
if (status == TCallStatus.clsInProgress)
{
mciSendString("open new Type waveaudio Alias recsound", "", 0, 0);
mciSendString("record recsound", "", 0, 0);
}
//else if (status == TCallStatus.clsFinished)
else if (status == TCallStatus.clsFinished)
{
DateTime currdate = DateTime.Now;
//string datetime = currdate.Day + currdate.Month + currdate.Year + "_" + currdate.Hour + currdate.Minute + currdate.Second;
string datetime = string.Format("{0:yyyyMMddhhmmss}.wav", DateTime.Now);
string wavfilename = "";
if (config.AppSettings.Settings["VoiceRecordsPath"].Value != null)
{
//wavfilename = config.AppSettings.Settings["VoiceRecordsPath"].Value.Replace(",","") + "_" + CSRBusiness.User.Country + "_" + datetime + @".wav";
wavfilename = CSRBusiness.User.Country + "_" + datetime;
}
Directory.SetCurrentDirectory(config.AppSettings.Settings["VoiceRecordsPath"].Value.Replace(",", ""));
result = mciSendString("save recsound " + wavfilename, "", 0, 0);
//result = mciSendString("save recsound d://test.wav", "", 0, 0);
mciSendString("close recsound ", "", 0, 0);
MessageBox.Show(result.ToString());
}
// MessageBox.Show(result.ToString());
}路径是我需要保存文件的位置:
C:\\Users\\tridip.BBAKOLKATA\\Documents\\Visual Studio 2010\\Projects\\CSRAssistant\\CSRAssistant\\bin\\Debug\\VoiceRecords我的代码中有什么错误?
但是当我像result = mciSendString("save recsound d://test.wav", "", 0, 0);一样在mciSendString中硬编码路径和文件名时,就创建了一个文件,但是当我播放该wave文件时,skype调用并没有被记录下来。
我的路径规范中有什么问题?
第二件事是,当wave文件生成时,语音没有被记录下来。为什么?
发布于 2014-03-18 22:46:32
如果命令字符串中的路径或文件名包含嵌入空格,则API调用可能会失败。因此,请将路径包括在双引号中:
result = mciSendString("save recsound \"" + wavfilename + "\"", "", 0, 0);或者,从C# 6.0开始:
result = mciSendString($"save recsound \"{wavfilename}\"", "", 0, 0);请参阅KB191089 PRB: Multimedia API Calls May Fail with Long File Names
发布于 2015-06-23 05:28:42
在调用"save recsound“之前,你应该在所需的路径下创建文件夹"VoiceRecords”。
https://stackoverflow.com/questions/22482322
复制相似问题