在浏览器中播放流式音频 (Asp.net)
我现在正在努力让它发挥作用相当长一段时间。我有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须使用 Flash 或 ActiveX 或类似的东西。
You'll have to use Flash or ActiveX, or something like that.