本文介绍了如何播放存储在数据库Access中的声音文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

请给我可以让我读取存储在数据库中的file.wav("alarme.wav")的代码,我尝试了以下代码:

Hello

Please can you give me the code that allows me to read a file.wav ("alarme.wav") stored in a database, I tried the following code:

private void button1_Click (object sender, EventArgs e)
{

OdbcConnection cn = new OdbcConnection ("DSN = cp1");
cn.Open ();
OdbcCommand cmd1 = new OdbcCommand ("select path from WHERE Code Alarm alarm = 32 ", cn);
cmd1.Connection = cn;
fileName = cmd1.ToString ();
WaveOut wave = new ();
wave.DeviceNumber = 0;
playSound (0);



但这给了我以下错误:
找不到文件"C:\ Users \ wafa \ Documents \ Visual Studio 2010 \ Projects \ ALARMED \ ALARMED \ bin \ Debug \ System.Data.Odbc.OdbcCommand"."
在此行:
"waveReader =新的NAudio.Wave.WaveFileReader(fileName);"在我的"playSound"函数中:



But that gave me the following error:
"Could not find file ''C: \ Users \ wafa \ Documents \ Visual Studio 2010 \ Projects \ ALARMED \ ALARMED \ bin \ Debug \ System.Data.Odbc.OdbcCommand''."
At the line:
"waveReader = new NAudio.Wave.WaveFileReader (fileName);" in my "playSound" function:

public void PlaySound (int deviceNumber)
{
disposeWave ();// stop previous sounds Before Starting
waveReader = new NAudio.Wave.WaveFileReader (fileName);
var waveOut NAudio.Wave.WaveOut = new ();
waveOut.DeviceNumber = deviceNumber;
var output = waveOut;
output.Init (waveReader);
output.Play ();
}



提前谢谢您.
美好的一天:)



Thank you in advance.
Good day:)

推荐答案



这篇关于如何播放存储在数据库Access中的声音文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 14:01