How do show an local video using ASP.Net MVC 3
I have a Video Content/Videos/samsung.mp4
. I want to show that video but I can't seem to access it in the view, I am not sure what C# code I should use to access the resource.
This doesn't show the video:
@开发者_开发问答{
ViewBag.Title = "Some site!";
var videourl = Url.Content("/Content/Videos/samsung.mp4");
}
<h2>Some site this is!</h2>
<p>
<video>@videourl</video>
</p>
<video>
is a HTML5 element and it does support MP4 videos.
But the browser may not. Which browser and version are you using?
Also, your syntax above is incorrect. The correct syntax for the video element with an MP4 video would be:
<video src="samsung.mp4"></video>
Alternatively you can serve up different formats to different browsers (which is recommended) with:
<video>
<source src="samsung.ogg" type="video/ogg">
<source src="samsung.mp4" type="video/mp4">
<source src="samsung.webm" type="video/webm">
Your browser doesn't support the video element
</video>
Have a look at the Microsoft Web Helpers package. There is a Video helper to do just this.
More details at http://msdn.microsoft.com/en-us/library/microsoft.web.helpers(v=VS.99).aspx
You can download the package from Nuget.
You need to embed it in a Quicktime player or another thats supports mp4. it doesn't have anything to do with c# more HTML/javascript.
Not sure the code needed but the above information will be enough to find it on google
精彩评论