我尝试了这些方法来解决这个问题。
返回文件路径;
[HttpGet]
public ActionResult GetTrackById(Guid id)
{
string fileNameOnServer = GetFile(id);
return File(fileNameOnServer , Response.ContentType);
}
返回字节数组
[HttpGet]
public ActionResult GetTrackById(Guid id)
{
byte[] bufferToSend = GetFile(id);
return File(bufferToSend, Response.ContentType);
}
在这种情况下,我得到 OutOfMemoryException。
返回流
[HttpGet]
public ActionResult GetTrackById(Guid id)
{
Stream stream = GetFile(id);
return File(stream , Response.ContentType);
}
所以问题是,如何分段播放音频文件,并使音频播放器发送文件播放和加载的范围请求。我在谷歌上没有找到任何有用的东西。