There is a need to stream video. When you send a stream of small video, everything is fine, but when a video is sent for 20 minutes or more, it OutOfMmemoryException. Controller

 public class VideoController : Controller { // GET: Video public FileStreamResult Index() { Stream fileStream = System.IO.File.Open(@"F:\Мусор\Test.mp4", FileMode.Open); return new FileStreamResult(fileStream, "video/mp4");//Исключение } public PartialViewResult GetPlayer() { return PartialView(); } } 

Representation:

 <script src="~/scripts/jquery-2.2.2.js"></script> <script src="~/scripts/jquery.jplayer.js"></script> <script> $(function () { $("#jpId").jPlayer({ ready: function () { $(this).jPlayer("setMedia", { m4v: '@Url.Action("Index")' }).jPlayer("play"); }, supplied: "m4v", swfPath: "jPlayer/js" }); }); </script> <div id="jpId"></div> 

Maybe there is a way to split the stream into several equal parts. Or another solution ZY. JPlayer plugin used

    1 answer 1

    FileStreamResult is not streaming in its pure form, but simply reading the file + sending to the client. Pure ASP.NET MVC currently does not support streaming.

    If you need streaming - transfer this method to an ASP.NET WebAPI controller and return StreamContent / PushStreamContent - they both turn off buffering and send data as it is read from stream / push to stream.

    • Must see the implementation. It feels like there is enough just to disable buffering ... - Pavel Mayorov