I have an asp.net mvc 5 site and on the home page I need to display a video in mp4 format. Everything works nice except the seeking functionality. I spent several hours looking for a solution but I didn't had any luck.
The html element:
<video id="appVideo" controls style="width: 100%; height: 100%">
<source src="@Url.Action("HomePageVideo", "Home")" type="video/mp4" />
</video>
The controller method for retrieving the video:
[HttpGet]
[AllowAnonymous]
public ActionResult HomePageVideo()
{
return File(@"somePath\file.mp4", "video/mp4");
}
What am I missing? Thanks in advance!
The problem is most likely on the server side, not the client side.
Depending on how you host your video the seek functionality will work slightly differently.
For example if you are using a 'proper' streaming server and an adaptive bit rate streaming protocol (like HLS, Smooth streaming, MPEG DASH etc) then your client will be able to request a particular 'chunk' of the video easily and jump to it (i.e. seek functionality).
If you are using HTTP 'pseudo' streaming (which is probably more likely) then your client should still be able to request just a certain part of the video, but to support this your server has to support 'Accept-Ranges' response header.
This mechanism essentially allows the client request just a portion of the file form the server - it allows a browser save bandwidth by just downloading small chunks of a video before they are to play rather than always downloading the whole video, and it also allows it seek easily by requesting the chunk corresponding to the place the user is seeking to.
Not all servers support this or have it configured out of the box, so this may be where your problem sits.
Note that your mp4 video also has to be set up to have the metadata at the start to support playback before it has downloaded (see: http://multimedia.cx/eggs/improving-qt-faststart/), but from your description it sounds like you already have this.