Does Chromium Embedded Framework support HTML5 audio?

妖精的绣舞 提交于 2019-12-06 05:01:20

问题


I've been playing around with CefSharp and I can't seem to make any audio play. I can make the audio controls appear, but they remain frozen.

These are the versions I use:

Chromium: 21.0.1180.0, CEF: r728, CefSharp: 0.12.4596.50

I tried first .mp3, then .ogg, and finally .wav, but none would work.

This is the HTML and audio I load when trying with .ogg:

public bool OnBeforeResourceLoad(IWebBrowser browser, 
    IRequestResponse requestResponse)
{
    IRequest request = requestResponse.Request;

    if (request.Url.EndsWith(".gif")) {
        MemoryStream stream = new MemoryStream();
        Properties.Resources.cursor_test.Save(stream,
            System.Drawing.Imaging.ImageFormat.Bmp);
        requestResponse.RespondWith(stream, "image/gif");
    }
    else if (request.Url.EndsWith(".ogg")) {
        MemoryStream stream = new MemoryStream(Properties.Resources.foo);
        requestResponse.RespondWith(stream, "audio/ogg");
    }
    else {
        Stream resourceStream = new MemoryStream(Encoding.UTF8.GetBytes(
            @"<!DOCTYPE html>
<html>
<body>
    <img src=""bla1/bla2/foo.gif"" />
    <audio controls=""controls"" autoplay=""autoplay"">
        <source src=""foo.ogg""  />
    </audio>
</body>
</html>"));
        requestResponse.RespondWith(resourceStream, "text/html");
    }

    return false;
}

This is what Chromium looks like:

I read that perhaps with Chromium only open formats are supported. I also read the perhaps audio is just not available for now.

What is the current state of <audio /> in Chromium and CEF?


回答1:


By default, the support for MP3 audio is disabled for legal reasons.
You can enable it by rebuilding CEF. See the details here:
Chromium Embedded Framework MP3 support



来源:https://stackoverflow.com/questions/12355706/does-chromium-embedded-framework-support-html5-audio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!