在浏览器中播放流式音频 (Asp.net)

发布于 2024-09-15 19:26:59 字数 775 浏览 4 评论 0原文

我现在正在努力让它发挥作用相当长一段时间。我有一个 asp.net 页面,我试图在其中播放 wav 文件。页面加载事件中的代码如下:

Response.Clear()  
Response.ContentType = "audio/wav"  
Response.AppendHeader("Content-Disposition", "inline;filename=" + "temp.wav")  
Dim filePath As String = Server.MapPath("/temp.wav")  
If Not String.IsNullOrEmpty(filePath) Then  
    'Here I am converting the file to a byte array,as eventually I'll be creating the wav files on the fly  
    Dim fileBytes As Byte() = GetFileBytes(filePath)  
    Response.BinaryWrite(fileBytes)  
    Response.Flush()  
End If

我遇到的问题是每次运行此页面时,Windows Media Player 都会打开。我希望使用浏览器中的一些内置插件来播放音频。例如,当您单击语音图标时,如何在不打开任何播放器的情况下弹出声音。

如果我在 ashx 处理程序中有相同的内容,会更好吗?

我无法使用嵌入标签,因为我不会在服务器上拥有物理文件,它将使用响应流动态生成。

任何帮助表示赞赏!

I am trying to get this to work for quite some time now. I have an asp.net page in which I am trying to play a wav file. The code in the page load event is as follows:

Response.Clear()  
Response.ContentType = "audio/wav"  
Response.AppendHeader("Content-Disposition", "inline;filename=" + "temp.wav")  
Dim filePath As String = Server.MapPath("/temp.wav")  
If Not String.IsNullOrEmpty(filePath) Then  
    'Here I am converting the file to a byte array,as eventually I'll be creating the wav files on the fly  
    Dim fileBytes As Byte() = GetFileBytes(filePath)  
    Response.BinaryWrite(fileBytes)  
    Response.Flush()  
End If

The problem I am having is every time I run this page, the windows media player opens up. I would like the audio to be played using some inbuilt plugin in the browser. Something like, when you click on a voice icon, how the sound pops up without opening any player.

If I have the same content in an ashx handler, would it be better?

I could not use the embed tag because, I shall not be having a physical file on the server, it would be generated on the fly using a response stream.

Any help is appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

因为看清所以看轻 2024-09-22 19:27:00

您必须使用 Flash 或 ActiveX 或类似的东西。

You'll have to use Flash or ActiveX, or something like that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文