5

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 Answers1

4

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

Community
  • 1
  • 1
zah
  • 5,314
  • 1
  • 34
  • 31
  • I have certainly produced a CEF build with support for the audio tag and mp3/ogg/wav. I haven't tried CefSharp, but the vanilla [cefclient demo](http://code.google.com/p/chromiumembedded/downloads/list) is able to play ogg/wav. – zah Sep 11 '12 at 22:32