用C#写了个播放声音的程序,但播放声音的有时放不出来,到下次又有声音了 50
DirectX,MicrosoftspeechobjectLibrary,SoundPlayer,这三种播放方式都试过了,还有没有其它稳定可靠的?WindowsMedia...
DirectX,Microsoft speech object Library,SoundPlayer,这三种播放方式都试过了,还有没有其它稳定可靠的?
Windows Media Player这个也用过了,也不行
另外电脑接的是功放 展开
Windows Media Player这个也用过了,也不行
另外电脑接的是功放 展开
3个回答
展开全部
如果你要播放是的是windows 的声音文件格式(wav波形文件),SoundPlayer就可以。其实很简单。
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog dialog = new OpenFileDialog();
dialog.Filter = "Audio Files (.wav)|*.wav";
if (dialog.ShowDialog() == DialogResult.OK)
{
string path = dialog.FileName;
playSound(path);
}
}
private void playSound(string path)
{
System.Media.SoundPlayer player =
new System.Media.SoundPlayer();
player.SoundLocation = path;
player.Load();
player.Play();
}
主要是你要播放什么格式?
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog dialog = new OpenFileDialog();
dialog.Filter = "Audio Files (.wav)|*.wav";
if (dialog.ShowDialog() == DialogResult.OK)
{
string path = dialog.FileName;
playSound(path);
}
}
private void playSound(string path)
{
System.Media.SoundPlayer player =
new System.Media.SoundPlayer();
player.SoundLocation = path;
player.Load();
player.Play();
}
主要是你要播放什么格式?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询