Partial content in .NET Core MVC (for video/audio streaming)

前端 未结 2 1363
旧巷少年郎
旧巷少年郎 2020-12-31 06:09

I am trying to implement video and audio streaming on my website (to enable seeking in Chrome) and I recently found out that .NET Core 2.0 apparently provides a relatively s

2条回答
  •  我在风中等你
    2020-12-31 06:44

    My answer is based on Yuli Bonner, but with the adaptations so that it answers the question directly, and with Core 2.2

     public IActionResult GetFileDirect(string f)
    {
       var path = Path.Combine(Defaults.StorageLocation, f);
       var res = File(System.IO.File.OpenRead(path), "video/mp4");
       res.EnableRangeProcessing = true;
       return res;
    } 
    

    This allowed for seeking in the browser.

提交回复
热议问题