I have a HttpHandler in C# that returns an MP3 file in an array of bytes, the code is like this:
public class BasicHandler : IHttpHandler
{
public void ProcessRequest(HttpContext httpContext)
{
string mp3FileName = @"C:\Users\gustavo.torrico\Desktop\WInAir\TestPlayer\Mp3Player\Files\TestFile.mp3";
byte[] bytes = File.ReadAllBytes(mp3FileName);
httpContext.Response.ContentType = "audio/mp3";
httpContext.Response.BinaryWrite(bytes);
}
public bool IsReusable
{
get
{
return false;
}
}
}
The file must be reproduced in a HTML5 player, the code of player looks like this:
<audio controls>
<source loop="on" preload="on" src="http://localhost:4677/Services/BasicHandler.ashx" type="audio/mpeg">
Your browser does not support the audio element.</audio>
The player, works perfect with IE +9 and Firefox 21, but with Chrome, there are a problem, just reproduces the file one time and no more. Is there any way to solve this problem without a plug-in like Silverlight or Flash?
The project of example is here