Answer the question
In order to leave comments, you need to log in
Clicking on the timeline of an audio element will restart the audio track. Why is that?
Good day to all!
I have the following situation: an mp3 file is stored in the database. On the server side, I translate it into a byte array and pass it to the client:
public FileResult StreamTrack(int VoiceId)
{
var file = repo.StreamTrack(VoiceId);
return File(file.ToArray(), "audio/mpeg");
}
<audio controls preload="none" codecs="mp3">
<source type="audio/mp3" src="/Home/StreamTrack?VoiceId=216">
</audio>
Answer the question
In order to leave comments, you need to log in
The problem was solved by adding a header:
Total method is now like this:
public FileResult StreamTrack(int VoiceId)
{
Response.AppendHeader("Accept-Ranges", "bytes");
var file = repo.StreamTrack(Response, VoiceId);
return File(file.ToArray(), "audio/mpeg");
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question