I've installed a Chrome extension on Microsoft Edge (Chromium) to play HLS video. I've tried on Microsoft Edge (Chromium) and it works fine. The HLS URL is http://localhost/hls/taiguo/playlist.m3u8 and on Microsoft Edge browser and it displays the URL as follows: extension://ekcifneimckhkjdfklkkpdlnckcjhmke/index.html#http://localhost/hls/taiguo/playlist.m3u8.
When I use WebView2 to embed the browser in a Windows application following [Getting Started with WebView2 (developer preview)] (https://learn.microsoft.com/en-us/microsoft-edge/hosting/webview2/gettingstarted) sample code:
` CreateCoreWebView2EnvironmentWithDetails(nullptr, nullptr, nullptr, Callback( [hWnd](HRESULT result, ICoreWebView2Environment* env) -> HRESULT {
RETURN_IF_FAILED(result);
// Create a CoreWebView2Host and get the associated CoreWebView2 whose parent is the main window hWnd
env->CreateCoreWebView2Host(hWnd, Callback<ICoreWebView2CreateCoreWebView2HostCompletedHandler>(
[hWnd](HRESULT result, ICoreWebView2Host* host) -> HRESULT {
if (host != nullptr) {
webviewHost = host;
webviewHost->get_CoreWebView2(&webviewWindow);
}
// Add a few settings for the webview
// this is a redundant demo step as they are the default settings values
ICoreWebView2Settings* Settings;
webviewWindow->get_Settings(&Settings);
Settings->put_IsScriptEnabled(TRUE);
Settings->put_AreDefaultScriptDialogsEnabled(TRUE);
Settings->put_IsWebMessageEnabled(TRUE);
// Resize WebView to fit the bounds of the parent window
RECT bounds;
GetClientRect(hWnd, &bounds);
webviewHost->put_Bounds(bounds);
// Schedule an async task to navigate to Bing
webviewWindow->Navigate(L"http://localhost/hls/taiguo/playlist.m3u8");`
If I run the above code, the app will just download the playlist.m3u8 file without playing the video. If I change the URL parameter of webviewWindow->Navigate(...) to:
webviewWindow->Navigate(L"extension://ekcifneimckhkjdfklkkpdlnckcjhmke/index.html#http://localhost/hls/taiguo/playlist.m3u8");
Then I get an error message as shown below: App screen capture
I hope someone can tell me how to run extension using WebView2 API.