首页 > 解决方案 > 如何在 ASP.NET MVC HTML 音频播放器中播放大文件 500Мb?

问题描述

我尝试了这些方法来解决这个问题。

  1. 返回文件的路径;

    [HttpGet]
    public ActionResult GetTrackById(Guid id)
    {
       string fileNameOnServer = GetFile(id);
       return  File(fileNameOnServer , Response.ContentType);
    }
    
  2. 返回字节数组

    [HttpGet]
    public ActionResult GetTrackById(Guid id)
    {
       byte[] bufferToSend = GetFile(id);
       return  File(bufferToSend, Response.ContentType);
    }
    

    在这种情况下,我得到 OutOfMemoryException。

  3. 返回流

    [HttpGet]
    public ActionResult GetTrackById(Guid id)
    {
       Stream stream = GetFile(id);
       return  File(stream , Response.ContentType);
    }
    

所以问题是,如何分部播放音频文件,并让音频播放器发送文件播放和加载的范围请求。我在谷歌上没有找到任何有用的东西。

标签: c#asp.net-mvchtml5-audio

解决方案



推荐阅读