I am trying to stream a file using the audio HTML5 tag. I have put the Controller action to return a FileStream and attached it to the src for the audio. However, the content
You should not return a FileStream
, you should return a FileStreamResult
or a FilePathResult
from your controller action, like this:
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
public ActionResult MyAudio()
{
var file = Server.MapPath("~/app_data/test.mp3");
return File(file, "audio/mp3");
}
}
and the ~/Views/Home/Index.cshtml
view:
@{
Layout = null;
}
Sound Sample
Some audio