我正在从MVC3网站提供视频,控制器操作返回视频返回FilePathResult,并且当试图在浏览器中播放时,我看到一些令人沮丧的问题,无论我使用video.js还是mediaelement.js。来自MVC3操作的HTML5视频无法正常工作
- 铬不会让你使用进度条改变位置,也不允许你可以重播视频一旦完成
- IE9显得比较细
- Firefox不显示经过/剩余时间正确
但是,如果我只是给托管文件的相对路径,它一切正常。 视频只需要属于特定角色的用户使用,因此这不是真正的选择。
行动:
[Authorize]
public ActionResult Video(string fileName)
{
var pathBase = Server.MapPath("~/Downloads/Videos/");
var filePath = pathBase + fileName;
var contentType = ContentType(fileName);
return new FilePathResult(filePath, contentType) { FileDownloadName = fileName };
}
剃刀:
<!-- @t = the video entity -->
<video width="640" height="360" id="@t.Id" poster="@Url.Action("Video", "Download", new { fileName = @t.Poster })" controls="controls" preload="none">
<!-- MP4 source must come first for iOS -->
<source src="@Url.Action("Video", "Download", new { fileName = @t.Mp4 })" type='video/mp4' />
<!-- WebM for Firefox 4 and Opera -->
<source src="@Url.Action("Video", "Download", new { fileName = @t.WebM })" type='video/webm' />
<!-- OGG for Firefox 3 -->
<source src="@Url.Action("Video", "Download", new { fileName = @t.Ogv })" type='video/ogg' />
<!-- Fallback flash player for no-HTML5 browsers with JavaScript turned off -->
<object width="640" height="360" type="application/x-shockwave-flash" data="@Url.Content("~/Content/flashmediaelement.swf")">
<param name="movie" value="@Url.Content("~/Content/flashmediaelement.swf")" />
<param name="flashvars" value="controls=true&[email protected]("Video", "Download", new { fileName = @t.Poster })&[email protected]("Video", "Download", new { fileName = @t.Mp4 })" />
<!-- Image fall back for non-HTML5 browser with JavaScript turned off and no Flash player installed -->
<img src="@Url.Action("Video", "Download", new { fileName = @t.Poster })" width="640" height="360" alt="@t.Title"
title="No video playback capabilities" />
</object>
</video>
做的网址是什么样子时,他们完全解析? – heff 2012-08-08 01:09:01
Download/Video?fileName = file.ext – damienc88 2012-08-08 05:52:51