问题描述
我正在尝试使用ASP / VBscript流式传输mp4文件。我使用ADODB.Stream
来午餐文件和一些代码来检测用户请求的范围。视频已成功加载,但是通过单击搜索栏没有任何反应。我已经在响应标头中设置了所有Accept-Ranges
,Content-Range
和Content-Length
:
<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 (将#修改为@)