我在 Microsoft Edge (Chromium) 上安装了 Chrome 扩展程序来播放 HLS 视频。我在 Microsoft Edge (Chromium) 上试过,效果很好。HLS URL 是http://localhost/hls/taiguo/playlist.m3u8,在 Microsoft Edge 浏览器上,它显示 URL 如下:extension://ekcifneimckhkjdfklkkpdlnckcjhmke/index.html# http://localhost/hls/taiguo/播放列表.m3u8。
当我按照 [Getting Started with WebView2 (developer preview)] ( https://docs.microsoft.com/en-us/microsoft-edge/hosting/webview2/gettingstarted ) 示例代码使用 WebView2 将浏览器嵌入到 Windows 应用程序中时:
` 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");`
Run Code Online (Sandbox Code Playgroud)
如果我运行上面的代码,应用程序将只下载 playlist.m3u8 文件而不播放视频。如果我将 webviewWindow->Navigate(...) 的 URL 参数更改为:
webviewWindow->Navigate(L"extension://ekcifneimckhkjdfklkkpdlnckcjhmke/index.html#http://localhost/hls/taiguo/playlist.m3u8");
Run Code Online (Sandbox Code Playgroud)
然后我收到一条错误消息,如下所示: App screen capture
我希望有人能告诉我如何使用 WebView2 API 运行扩展。
我在 WebView2 项目上工作。首先让我说 WebView2 目前不支持扩展。这是一个相当复杂的功能,我们必须做出很多设计选择,所以在解决这些问题之前,我们特意关闭了扩展。我们绝对愿意在未来支持它,并且我们的反馈存储库跟踪功能请求存在问题 - https://github.com/MicrosoftEdge/WebViewFeedback/issues/81. 很高兴让您加入并讨论您的用例,因此我们对您正在寻找的内容有更多的了解。例如,开发人员为他们的应用程序启用任意扩展程序(例如,我想要一个广告拦截器监视我的网络内容),我认为这就是您要问的,与为最终用户提供安装扩展程序的方式非常不同网页视图。
也就是说,从技术角度来看,即使 WebView2 现在支持扩展,用户从浏览器安装的扩展也不会显示在 WebView2 中。浏览器将其扩展存储在其用户数据文件夹中(请参阅 C:\Users\ username \AppData\Local\Microsoft\Edge SxS\User Data\Default\Extensions for Canary),其中还包含 cookie、缓存等内容。 WebView2应用程序有自己的用户数据文件夹,由于安全隐患,不能使用浏览器用户数据。
| 归档时间: |
|
| 查看次数: |
1519 次 |
| 最近记录: |