R4Ynz
R4Ynz

Reputation: 41

Cefsharp and video tag WebRTC

I'm trying to write a wpf with webrtc support. The access to the camera works but the display of the <video> from the page doesn't. Can anyone help?

Upvotes: 4

Views: 6529

Answers (3)

Mixerreq
Mixerreq

Reputation: 1

The correct code is this Dim settings As New CefSettings settings.CefCommandLineArgs.Add("--enable-media-stream", "1") CefSharp.Cef.Initialize(settings) settings.CachePath = "cache"

Upvotes: 0

Batist
Batist

Reputation: 313

You can do something like this:

var cefSettings = new CefSettings();
cefSettings.CefCommandLineArgs.Add("enable-media-stream", "enable-media-stream");
Cef.Initialize(cefSettings);

This has the same effect as passing the command line argument

Upvotes: 4

jornh
jornh

Reputation: 1369

I assume you want to display video from your camera via WebRTC so I think it requires a call to .getUserMedia() to get hold of your camera. For that to work you must use CefSharp based on Chromium 30 or later. So either:

  • Use the latest CefSharp.Wpf NuGet. Right now you need latest -Pre release
  • or build from source with the current master branch.

I just did a quick test again using CefSharp.MinimalExample so here are the steps:

  1. Make sure your MinimalExample uses Chromium 31 or higher - see this PR - unless it already got merged by the time you are reading this.

  2. In MainView.xaml modify the <cefSharp:WebView Address= /> attribute to "https://simpl.info/getusermedia/sources/index.html"

  3. Build and when running add the --enable-media-stream command line flag.

That's it! With your camera connected and a bit of luck you should see your own face - or whatever the camera points to - on the screen.

Bonus info: Hopefully soon PR #365 can get a bit of extra love to allow for passing flags too and get merged into CefSharp. With that you can set the flag in code instead of having to pass it in as a command line parameter.

Upvotes: 2

Related Questions