我试图使用mp3框架4.6.1在chrome中打开.Net音频文件。
下面是我在View和Controller中的代码。
视图
<div class="jumbotron">
<button type="button" onclick="PlayVoiceFile()">click</button>
</div>
<script>
function PlayVoiceFile() {
window.open('/Home/PlayFile?path=' + 'C:\\blahblahblah\\Audio\\TestSampleMP3.mp3');
}
</script>HomeController
public ActionResult PlayFile(string path = "")
{
return MediaFile(path);
}
private ActionResult MediaFile(string path = "")
{
var byteWave = System.IO.File.ReadAllBytes(path);
return File(byteWave, "audio/mp3");
}一切都像我所期望的那样正常工作,除了我不能快速前进或倒带文件。每当我试图单击进度条以跳过文件的特定部分时,就不会发生任何事情。在work.Any建议中,进度条似乎没有吗?谢谢。
发布于 2021-02-02 10:19:03
下面的代码应该起到神奇的作用。enableRangeProcessing是关键参数。
public ActionResult PlayFile(string path = "")
{
return PhysicalFile(path, "audio/mp3", enableRangeProcessing: true);
}https://stackoverflow.com/questions/66006820
复制相似问题