You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to allow camera and microphone permissions dynamically if i connect the microphone and camera while teams call is already running in edgewebview2, I am initially launching the webview like this
std::wstring args;
args.append(L" --ignore-certificate-errors");
args.append(L" --hide-scrollbars");
args.append(L"--disable-features=BlockThirdPartyCookies");
/ANK 29-01: just leaving this commented, might be useful if we decide to play videos muted/
// args.append(L" --mute-audio");
args.append(L" --autoplay-policy=no-user-gesture-required");
// args.append(L" --auto-accept-camera-and-microphone-capture");
if(scrn == 0)
{
args.append(L" --auto-select-desktop-capture-source="Entire screen"");
}
else if(scrn ==1)
{
args.append(L" --auto-select-desktop-capture-source="Screen 1"");
}
else
{
args.append(L" --auto-select-desktop-capture-source="Screen 2"");
}
qDebug()<<"args are "<<args;
auto options = Microsoft::WRL::Make<CoreWebView2EnvironmentOptions>();
options->put_AdditionalBrowserArguments(args.c_str());
Microsoft::WRL::ComPtr<ICoreWebView2EnvironmentOptions5> options5;
if (options.As(&options5) == S_OK)
{
options5->put_EnableTrackingPrevention(FALSE);
}
qDebug()<<"options are ready";
HRESULT res = CreateCoreWebView2EnvironmentWithOptions(
nullptr, userDataFolder, options.Get(),
new webview2_com_handler(wnd, cb,
[&](ICoreWebView2Controller *controller) {
m_controller = controller;
qDebug()<<"got controller"<<controller;
m_controller->get_CoreWebView2(&m_webview);
qDebug()<<"got webview"<<m_webview;
m_webview->AddRef();
flag.clear();
}));
qDebug()<<"res is "<<res;
if (res != S_OK) {
qDebug()<<"res failed";
return false;
}
MSG msg = {};
while (flag.test_and_set() && GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
init("window.external={invoke:s=>window.chrome.webview.postMessage(s)}");
return true;
}
void resize(HWND wnd) {
if (m_controller == nullptr) {
return;
}
RECT bounds;
GetClientRect(wnd, &bounds);
m_controller->put_Bounds(bounds);
}
class webview2_com_handler
: public ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler,
public ICoreWebView2CreateCoreWebView2ControllerCompletedHandler,
public ICoreWebView2WebMessageReceivedEventHandler,
public ICoreWebView2PermissionRequestedEventHandler {
using webview2_com_handler_cb_t =
std::function<void(ICoreWebView2Controller *)>;
this code suppresses the permission popup which comes initially but how to make it allow dynamically. when i try to mute / unmute with microphone connected , it says to allow microphone from omnibar, but i run the teams in headless/ app mode which doesn't show any omnibar, Any help is appreciated :)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I want to allow camera and microphone permissions dynamically if i connect the microphone and camera while teams call is already running in edgewebview2, I am initially launching the webview like this
std::wstring args;
args.append(L" --ignore-certificate-errors");
args.append(L" --hide-scrollbars");
args.append(L"--disable-features=BlockThirdPartyCookies");
/ANK 29-01: just leaving this commented, might be useful if we decide to play videos muted/
// args.append(L" --mute-audio");
args.append(L" --autoplay-policy=no-user-gesture-required");
// args.append(L" --auto-accept-camera-and-microphone-capture");
if(scrn == 0)
{
args.append(L" --auto-select-desktop-capture-source="Entire screen"");
}
else if(scrn ==1)
{
args.append(L" --auto-select-desktop-capture-source="Screen 1"");
}
else
{
args.append(L" --auto-select-desktop-capture-source="Screen 2"");
}
}
void resize(HWND wnd) {
if (m_controller == nullptr) {
return;
}
RECT bounds;
GetClientRect(wnd, &bounds);
m_controller->put_Bounds(bounds);
}
virtual void on_message(const std::string &msg) = 0;
HWND m_window;
POINT m_minsz = POINT{0, 0};
POINT m_maxsz = POINT{0, 0};
DWORD m_main_thread = GetCurrentThreadId();
ICoreWebView2 *m_webview = nullptr;
ICoreWebView2Controller *m_controller = nullptr;
class webview2_com_handler
: public ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler,
public ICoreWebView2CreateCoreWebView2ControllerCompletedHandler,
public ICoreWebView2WebMessageReceivedEventHandler,
public ICoreWebView2PermissionRequestedEventHandler {
using webview2_com_handler_cb_t =
std::function<void(ICoreWebView2Controller *)>;
public:
webview2_com_handler(HWND hwnd, msg_cb_t msgCb,
webview2_com_handler_cb_t cb)
: m_window(hwnd), m_msgCb(msgCb), m_cb(cb) {}
ULONG STDMETHODCALLTYPE AddRef() { return 1; }
ULONG STDMETHODCALLTYPE Release() { return 1; }
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, LPVOID *ppv) {
(void)riid;
(void)ppv;
return S_OK;
}
HRESULT STDMETHODCALLTYPE Invoke(HRESULT res,
ICoreWebView2Environment *env) {
(void)res;
env->CreateCoreWebView2Controller(m_window, this);
return S_OK;
}
HRESULT STDMETHODCALLTYPE Invoke(HRESULT res,
ICoreWebView2Controller *controller) {
(void)res;
controller->AddRef();
this code suppresses the permission popup which comes initially but how to make it allow dynamically. when i try to mute / unmute with microphone connected , it says to allow microphone from omnibar, but i run the teams in headless/ app mode which doesn't show any omnibar, Any help is appreciated :)
Beta Was this translation helpful? Give feedback.
All reactions