C#/ ASP.NET - 播放动态生成的客户端点击WAV文件 [英] C#/ASP.NET - Play dynamically generated WAV file on client click

查看:120
本文介绍了C#/ ASP.NET - 播放动态生成的客户端点击WAV文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想打,我在HTTP处理程序动态生成WAV文件和设置HyperLink控件的NavigateUrl属性:

I'm trying to play a WAV file that I generate dynamically in a HTTP handler and setting the NavigateUrl property of HyperLink control:

<asp:HyperLink runat="server" NavigateUrl="~/ServeAudio.ashx" Text="Play Sound" ImageUrl="~/images/speaker_louder_32.png"
                        ToolTip="Play Sound"></asp:HyperLink>

但是,当我点击该链接,它会打开Windows媒体播放器 - 我不希望出现这种情况。我只是想播放声音。

But when I click on that link, it opens Windows Media Player - I don't want that. I just want the sound to play.

我也使用一些了jQuery插件的尝试,他们似乎如果我有一个固定的URL为WAV文件的工作,但如果我设置的URL,我的HTTP处理程序他们没有工作。

I have also tried using a few of the jQuery plugins and they seem to work if I have have a fixed URL to a WAV file but they don't work if I set the URL to my HTTP handler.

任何想法?先谢谢了。

推荐答案

使用一个HTTP分析器如提琴手或浏览器的开发工具如萤火虫(在IE或开发工具)时看到您正在访问哪些发送HTTP头部WAV文件直接。

Use an HTTP analyser like Fiddler or browser development tools like Firebug (or dev tools on IE) to see what HTTP headers are sent when you are accessing the WAV file directly.

然后,通过使用的 Htt的presponse.AppendHeader方法。也许是这样的:

Then mimic the HTTP headers from your handler by setting the them using HttpResponse.AppendHeader Method. Possibly something like this:

Response.AppendHeader("Content-Type", "audio/x-wav");

这可能有助于另一个技巧是工艺的网址,所以它看起来像一个文件(你不应该需要这个,如果你可以使用相应的HTTP头):

Another trick that might help is to craft the url, so it looks like a file (you should not need this if you can use the appropriate HTTP headers):

"~/ServeAudio.ashx/my.wav"

这篇关于C#/ ASP.NET - 播放动态生成的客户端点击WAV文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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