如何解决HTTP_RANGE在视频搜索栏上不起作用
我正在尝试使用ASP / VBscript流式传输mp4文件。我使用ADODB.Stream
来午餐文件和一些代码来检测用户请求的范围。视频已成功加载,但是通过单击搜索栏没有任何反应。我已经在响应标头中设置了所有Accept-Ranges
,Content-Range
和Content-Length
:
HTML代码:
<video controls>
<source src="video.asp">
</video>
video.asp
filename ="test.mp4"
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Type = 1
objStream.Open
objStream.LoadFromFile(server.mappath(filename))
sizebyte=objStream.size
Response.ContentType = "video/mp4"
Response.AddHeader "Accept-Ranges","0-" & sizebyte
'Checking if user requested a range (by clicking on seekbar)
if Request.ServerVariables("HTTP_RANGE")<>"" then
'Cleaning startbyte from (bytes=) and (-)
startbyte=replace(Request.ServerVariables("HTTP_RANGE"),"-","")
startbyte=replace(startbyte,"bytes=","")
Response.AddHeader "Content-Range","bytes " & startbyte & "-" & sizebyte-1 & "/" & sizebyte
response.AddHeader "Content-Length",(int(sizebyte) - int(startbyte))
else
response.AddHeader "Content-Length",sizebyte
end if
do while not objStream.EOS
response.binarywrite objStream.Read(1024000)
Response.Flush
loop
objStream.Close
Set objStream = Nothing
Response.StatusCode = 206
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。