无法使用Accept-Ranges重现Chrome中的Ogg音频:字节数

时间:2013-06-18 14:55:24

标签: c# asp.net html5 google-chrome audio

我正在尝试使用HTML5重现音频,但我在重现Ogg文件时遇到问题,这是我服务器中的配置(BasicHandler.ashx):

        string oggFileName = @"C:\Users\gustav\Desktop\Player\Files\TestAudio.ogg";

        byte[] bytes = File.ReadAllBytes(oggFileName);
        httpContext.Response.ContentType = "audio/ogg";
        httpContext.Response.AddHeader("pragma", "Public");
        httpContext.Response.AddHeader("Accept-Ranges", "bytes");
        httpContext.Response.Cache.SetCacheability(HttpCacheability.Public);
        httpContext.Response.Cache.SetLastModified(new DateTime(2000, 01, 01));
        httpContext.Response.Cache.SetExpires(new DateTime(2020, 01, 01));
        httpContext.Response.BinaryWrite(bytes);

我的播放器有这段代码:

<div id="Player">
<audio id="audioPlayer" preload="auto" controls onplay="ReloadPlayer()">
    <source src="http://localhost:4677/Services/BasicHandler.ashx" type="audio/ogg">
        Your browser does not support the audio element.frff
</audio>

播放器与音频MP3或MP4(AAC)完美配合,但是当我尝试使用Ogg时,无法播放音频(在Firefox中可行,但在Chrome中是问题)。对这个问题有什么看法吗?

1 个答案:

答案 0 :(得分:0)