[英]How do I get HTML5 Video to scrub in chrome when delivered via a service?
因此,由于内容与服务器应用程序的虚拟目录位于不同的驱动器上,因此我不得不实现文件获取服务。
我能够获取文件大小。 然后,我想设置内容标题,以便浏览器知道总大小,从而知道如何按比例确定搜索栏。
在这里,我设置总大小标题:
string bytes = Convert.ToString( fInfo.Length );
Response.AddHeader("Content-Length", bytes );
Response.AddHeader("Content-Range", "bytes 0-" + bytes + "/" + bytes);
导致:
Content-Length: 1389363
Content-Type: video/ogg
Content-Range: bytes 0-1389363/1389364
我下载了结果文件,并确认字节匹配。 在Firefox中可以正常工作,而在chrome中则古怪。 在chrome中,它播放到结尾,但不会移动搜索栏,然后在到达结尾时在当前时间显示负无穷大。 另外,我根本无法清理视频,这可能是因为视频时长无效。
直接在chrome中播放相同的文件可以正常工作,因此,可能是chrome希望firefox不提供as#%t的某些内容标题吗?
有任何想法吗? 长度单位错误? 内置服务器端g-zip编码会干扰吗?
我正在使用标准视频对象:
<video class="videoplayer" controls="" autoplay="autoplay" tabindex="0">
<source type="video/ogg" src="http://vb_html.dev/GetFile.aspx?filename=c:/_assets/4c2c09c2-f2ff-e011-a992-009056af18ff/softsignage/softsignage-00000000600.ogv"></source>
Your browser does not support the video tag.
</video>
有关更多参考,这是我传递文件数据的方式:
FileStream mystream = new FileStream(anyFilePath, FileMode.Open, FileAccess.Read);
byte[] buffer = new byte[4096];
using (BinaryReader reader = new BinaryReader(mystream))
{
while (true)
{
int bytesRead = mystream.Read(buffer, 0, buffer.Length);
if (bytesRead == 0) break;
Response.OutputStream.Write(buffer, 0, bytesRead);
}
}
尝试将状态代码设置为206:
response.StatusCode = 206;
基本上,您希望以字节为单位获取请求范围,并返回文件的该部分。 您可以在MVC中使用
RangeFileStreamResult(Stream fileStream, string contentType, string fileName, DateTime modificationDate);
使用在此库中找到的Codeplex示例http://mvcresumingactions.codeplex.com/
-
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.