在任何浏览器中播放客户端的声音文件 [英] Play sound file of a client in any browser

查看:82
本文介绍了在任何浏览器中播放客户端的声音文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

来吧,这让我摆脱了声音播放的问题,我有以下代码可以在IE中正常工作,但在其他浏览器中无法正常工作,请问我的解决方案是什么.

DirectoryInfo di = new DirectoryInfo("C://Users//Public//Music//Sample Music/Kalimba.mp3");
//FileInfo [] fi = di.GetFiles();
字符串FilePath = di.FullName;
如果(BrowserName =="IE")
scr = scr + @< BGSOUND SRC =""+ FilePath +"''LOOP =''1''></BGSOUND>;
否则,如果(BrowserName =="Chrome")
{
scr = scr + @< embed src =""+ FilePath +"";
scr = scr + @"AUTOSTART =" True"name =" chm"LOOP =" true"height =" 0"width =" 0"volume =" 85> </embed>;
}
否则,如果(BrowserName =="Firefox")
{
scr = scr + @< embed src =""+ FilePath +"";
scr = scr + @"AUTOSTART =" True"LOOP =" true"name =" firfox"height =" 0"width =" 0"volume =" 85> </embed>;
}

IE浏览器与bgsound标签工作正常,但其他2个不工作,虽然我也尝试在其他2个bgsound,但没有工作.请为此提供解决方案.我想从用户自己的本地磁盘播放文件,如DirectoryInfo中所示.

问候,
Usman Ali

come on man bring me out from this sound playing issues i have following code that work fine in IE but not in other browsers what''s the solution for that please help me out.

DirectoryInfo di = new DirectoryInfo("C://Users//Public//Music//Sample Music/Kalimba.mp3");
//FileInfo[] fi = di.GetFiles();
string FilePath = di.FullName;
if (BrowserName == "IE")
scr = scr + @"<BGSOUND SRC=''" + FilePath + "'' LOOP=''1''></BGSOUND>";
else if (BrowserName == "Chrome")
{
scr = scr + @"<embed src=''" + FilePath + "'' ";
scr = scr + @"AUTOSTART=''True'' name=''chm'' LOOP=''true'' height=''0'' width=''0'' volume=''85''></embed>";
}
else if (BrowserName == "Firefox")
{
scr = scr + @"<embed src=''" + FilePath + "'' ";
scr = scr + @"AUTOSTART=''True'' LOOP=''true'' name=''firfox'' height=''0'' width=''0'' volume=''85''></embed>";
}

IE working fine with bgsound tag but other 2 not working although i tried bgsound in other 2 also but didn''t work. please give a solution for that. and i wanna play file from user''s own localdisk as see in DirectoryInfo.

Regards,
Usman Ali

推荐答案

,我想从用户自己的本地磁盘播放文件,如DirectoryInfo中所示."

你不能您的服务器无法访问客户端本地磁盘:检索到的DirectoryInfo将用于服务器磁盘,而不是客户端.
"and i wanna play file from user''s own localdisk as see in DirectoryInfo."

You can''t. Your server has no access to the client local disk: the DirectoryInfo you retrieve will for the the server disk, not the client.


这篇关于在任何浏览器中播放客户端的声音文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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