使用 aspx 文件作为音频标签的来源可防止快速转发

Using an aspx file as the source of an audio tag prevents fast forwarding

我正在尝试创建一个基本的 ASP.NET 音频库,使用 HTML5 音频标签和 ASPX 文件作为音频源。问题是当我使用 ASPX 文件而不是直接使用 mp3 文件时,音频播放器不允许快进或快退曲目,只能暂停、恢复和重新启动曲目。

我使用 ASPX 文件作为源的原因是为了不公开音频文件并让 ASPX 文件在传输文件之前处理 authentication/authorization。我在 ASPX 页面的一侧包括相关代码以及我正在使用的基本音频标记代码。

也许我做错了?有没有更好的方法将 mp3 文件提供给音频标签而不暴露它?我应该寻找更强大的音频播放器而不是尝试使用音频标签吗?

<audio controls preload="metadata" style="width: 100%;">
    <source src="FileDownload.aspx" type="audio/mpeg">
</audio>
protected void Page_Load(object sender, EventArgs e) {
     Response.Clear();
     Response.ClearHeaders();
     Response.ClearContent();
     Response.AddHeader("Content-Disposition", "attachment; filename=" sample.mp3");
     Response.AddHeader("Content-Length", 2000);
     Response.ContentType = "audio/mpeg";
     Response.Flush();
     Response.TransmitFile("C:\temp\sample.mp3");
     Response.End();
}

作为Mat J said, you have to use HTTP range requests as documented at https://developer.mozilla.org/en-US/docs/Web/HTTP/Range_requests