如何在C#中播放soud文件(wav或Mp3)? [英] How to play a soud file (wav or Mp3) in C#?

查看:102
本文介绍了如何在C#中播放soud文件(wav或Mp3)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用C#播放声音文件,它是否已在本地系统中成功运行但未在现场工作?这是我的代码。



System.Media.SoundPlayer player = new System.Media.SoundPlayer(Server.MapPath(../ Sound / beep-5.wav) ));

player.Play();



请帮助我,我的代码有什么问题?

I want play a sound file using C# it is successfully working in local system but not working in live? Here is my code.

System.Media.SoundPlayer player = new System.Media.SoundPlayer(Server.MapPath("../Sound/beep-5.wav"));
player.Play();

Please help me, what''s the wrong with my code?

推荐答案

我认为你的意思是它在开发过程中有效,但是我什么时候将它发布到网站上?

如果是这样,然后不,它不会工作。 C#代码在服务器上执行,而不是在客户端上执行。所以你的嘟嘟声在服务器机房里响起,远离客户端。并且可能会让主机管理员烦恼。



它似乎在开发中工作,因为服务器和客户端是同一台计算机。



看看这里:在客户端asp.net上播放声音 [ ^ ] - 它是google,你应该找到你想要的信息。
I assume you mean it works fin in development, but doesn''t when I publish it to a web site?
If so, then no, it won''t work. C# code is executed on the server, not the client. So your "Beep" is sounding in the server room, miles away from the client. And probably annoying the heck out of the host admin.

It appeared to work in development, because the server and the client were the same computer.

Have a look here: Playing sound on client asp.net[^] - it''s google, and you should find the info you want.


这篇关于如何在C#中播放soud文件(wav或Mp3)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆