Does Chromium Embedded Framework support HTML5 aud

2019-04-10 21:42发布

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:

enter image description here

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条回答
别忘想泡老子
2楼-- · 2019-04-10 22:31

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

查看更多
登录 后发表回答