使用MVC3和的Flowplayer,我有一个设置为获得与下面的标记视频文件的视频播放器:
<div id="video">
<div id="video-viewport">
<!-- The data-ratio is a decimal number represeting the height of the video in proportion to the width -->
<div class="flowplayer" data-swf="http://releases.flowplayer.org/5.1.1/flowplayer.swf"
data-ratio="0.417" data-engine="html5" data-keyboard="true" data-native_ipad_fullscreen="true"
data-volume="0.6">
<video>
<!-- By default Flowplayer attempts to use HTML5 video and if it's not
supported then Flash (9.0+) and MP4 is used. MP4 is enough for
complete browser support but providing WebM and/or OGG gives you
broader support for HTML5 video which is the preferred technology. -->
<!-- MP4 gives a complete cross browser support with the aid of Flash -->
<source type="video/mp4" src="@Url.Action("GetVideo", "Video", new { id = Model.WebMp4Video.Id })"/>
<!-- WEBM gives HTML5 video support for the latest Firefox, Chrome and Opera browser -->
<source type="video/webm" src="@Url.Action("GetVideo", "Video", new { id = Model.WebMVideo.Id })"/>
<!-- OGG gives HTML5 support for older versions of Firefox and Opera -->
<source type="video/ogv" src="@Url.Action("GetVideo", "Video", new { id = Model.OgvVideo.Id })"/>
</video>
</div>
</div>
</div> <!--/video-->
在控制器我有这个方法返回的视频:
public ActionResult GetVideo(string id) {
...
var cd = new System.Net.Mime.ContentDisposition {
Inline = false
};
FileInfo info = new FileInfo(path);
Response.AppendHeader("Content-Disposition", cd.ToString());
return new RangeFilePathResult(MimeType, info.FullName, info.LastWriteTimeUtc, info.Length);
}
RangeFilePathResult已经在返回部分缓解生命的救星,这一切工作正常在Firefox和IE,但在Chrome中我得到一个错误频繁:
“之后HTTP标头已经发送服务器不能设置状态”。
而玩家本身崩溃,揭示了页面上出现以下错误:
HTML5:影片未正确编码
我仍然在试图让我的周围部分反应的头,但可能这是因为RangeFileResult设置的状态码206,每个部分缓解? 或者是有什么事我是缺少在这里?
编辑 :如果我调试通过RangeFileResult代码,并且还检查在Chrome网络选项卡,我注意到该请求到控制器方法返回部分响应,带有状态之前,只要代码点击这一行:
context.HttpContext.Response.Flush();
人们似乎对这个延迟,有时超过10秒,但是当这是完成的repsonse的状态变为206,而通常在视频播放,不过,状态再次变为取消 ,这是当
HTML5:影片未正确编码
视频播放器上显示的消息。
EDIT2:是我得到的repsonses如下(3个回应,第一和第三被取消,第二个有206种状态:
请求
URL: http://localhost:64729/Video/GetVideo/24
Method: GET
Status Code: 206 Partial Content
请求头
Accept:*/*
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:identity;q=1, *;q=0
Accept-Language:en-US,en;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Cookie:.ASPXAUTH=BD5B9748E6985F5659B56289A5543C11CACBF1602AFFD5D4335453560988B870F2543269809401D13EE9F12EFBAC2D4CE0322B5F826871B9968B3D2986C01E35C536B28B5EC24E8E4F631D094B0DBEFF76DA84DA7CCC753E06C38C0FA36A858AC87548099BD23D4BE9B80434970A542489EC5E5F4543A9C98CA573F196DCBFE1B8CC18C10AE1AFEB0E4E899C6CA4DEFC59138E170954016DCB9C007FDC7C2B2950436E24AA5FF9C0888822626C9AE01C07A98F317A9499F0E9D5E61434F959E9;ASP.NET_SessionId=o112vzki5owvbptr4kudbdax
Host:localhost:64729
Range:bytes=0-
Referer:http://localhost:64729/Video/Index/3
User-Agent:Mozilla/5.0 (Windows NT 6.2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17
响应头
Cache-Control:private, s-maxage=0
Connection:Close
Content-Length:7362920
Content-Range:bytes 0-7362919/7362920
Content-Type:video/mp4
Date:Tue, 15 Jan 2013 12:55:24 GMT
Server:ASP.NET Development Server/10.0.0.0
X-AspNet-Version:4.0.30319
X-AspNetMvc-Version:3.0
请求
URL: http://localhost:64729/Video/GetVideo/24
Method: GET
Status Code: 206 Partial Content
请求头
Accept:*/*
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:identity;q=1, *;q=0
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Cookie:.ASPXAUTH=BD5B9748E6985F5659B56289A5543C11CACBF1602AFFD5D4335453560988B870F2543269809401D13EE9F12EFBAC2D4CE0322B5F826871B9968B3D2986C01E35C536B28B5EC24E8E4F631D094B0DBEFF76DA84DA7CCC753E06C38C0FA36A858AC87548099BD23D4BE9B80434970A542489EC5E5F4543A9C98CA573F196DCBFE1B8CC18C10AE1AFEB0E4E899C6CA4DEFC59138E170954016DCB9C007FDC7C2B2950436E24AA5FF9C0888822626C9AE01C07A98F317A9499F0E9D5E61434F959E9;ASP.NET_SessionId=o112vzki5owvbptr4kudbdax
Host:localhost:64729
Range:bytes=7339303-
Referer:http://localhost:64729/Video/Index/3
User-Agent:Mozilla/5.0 (Windows NT 6.2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17
响应头
Cache-Control:private, s-maxage=0
Connection:Close
Content-Length:23617
Content-Range:bytes 7339303-7362919/7362920
Content-Type:video/mp4
Date:Tue, 15 Jan 2013 12:55:24 GMT
Server:ASP.NET Development Server/10.0.0.0
X-AspNet-Version:4.0.30319
X-AspNetMvc-Version:3.0
请求
URL: http://localhost:64729/Video/GetVideo/24
Method: GET
Status Code: 206 Partial Content
请求头
Accept:*/*
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:identity;q=1, *;q=0
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Cookie:.ASPXAUTH=BD5B9748E6985F5659B56289A5543C11CACBF1602AFFD5D4335453560988B870F2543269809401D13EE9F12EFBAC2D4CE0322B5F826871B9968B3D2986C01E35C536B28B5EC24E8E4F631D094B0DBEFF76DA84DA7CCC753E06C38C0FA36A858AC87548099BD23D4BE9B80434970A542489EC5E5F4543A9C98CA573F196DCBFE1B8CC18C10AE1AFEB0E4E899C6CA4DEFC59138E170954016DCB9C007FDC7C2B2950436E24AA5FF9C0888822626C9AE01C07A98F317A9499F0E9D5E61434F959E9;ASP.NET_SessionId=o112vzki5owvbptr4kudbdax
Host:localhost:64729
Range:bytes=48-
Referer:http://localhost:64729/Video/Index/3
User-Agent:Mozilla/5.0 (Windows NT 6.2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17
响应头
Cache-Control:private, s-maxage=0
Connection:Close
Content-Length:7362872
Content-Range:bytes 48-7362919/7362920
Content-Type:video/mp4
Date:Tue, 15 Jan 2013 12:55:24 GMT
Server:ASP.NET Development Server/10.0.0.0
X-AspNet-Version:4.0.30319
X-AspNetMvc-Version:3.0