有没有可能 运行 UWP WebView 在最小化的 App 中,包括声音输出?
Is there a possibility to run a UWP WebView in minimized App, inclusive sound output?
我想在 UWP WebView 中渲染 Jellyfin 的 UI,这已经很好了。
但每次我最小化应用程序时,当前正在播放的音乐或视频声音都会停止播放到我的扬声器。最大化后,时间流逝,再次输出声音。
那么,有没有一个选项可以让 运行 即使在应用程序最小化时也能显示网页视图?
Is there a possibility to run a UWP WebView in minimized App, inclusive sound output?
恐怕您无法使用WebView 控件播放音频背景。目前 UWP WebView 不支持后台播放。因此播放器将在最小化应用程序时暂停。我们建议您使用 SMTC and enable Background Media PlayBack capability, For more info please refer this document.
进行后台媒体播放
可以让 WebView 在最小化时继续播放音频。在文档的下方是 instructions for enabling it。本质上,您调用:
SystemMediaTransportControls.GetForCurrentView().IsPlayEnabled = true;
SystemMediaTransportControls.GetForCurrentView().IsPauseEnabled = true;
文档指出您还应该处理 buttonPressed 事件,但我发现只需设置以上两个字段以及 enabling background audio in the manifest 即可使其正常工作。
我想在 UWP WebView 中渲染 Jellyfin 的 UI,这已经很好了。
但每次我最小化应用程序时,当前正在播放的音乐或视频声音都会停止播放到我的扬声器。最大化后,时间流逝,再次输出声音。
那么,有没有一个选项可以让 运行 即使在应用程序最小化时也能显示网页视图?
Is there a possibility to run a UWP WebView in minimized App, inclusive sound output?
恐怕您无法使用WebView 控件播放音频背景。目前 UWP WebView 不支持后台播放。因此播放器将在最小化应用程序时暂停。我们建议您使用 SMTC and enable Background Media PlayBack capability, For more info please refer this document.
进行后台媒体播放可以让 WebView 在最小化时继续播放音频。在文档的下方是 instructions for enabling it。本质上,您调用:
SystemMediaTransportControls.GetForCurrentView().IsPlayEnabled = true;
SystemMediaTransportControls.GetForCurrentView().IsPauseEnabled = true;
文档指出您还应该处理 buttonPressed 事件,但我发现只需设置以上两个字段以及 enabling background audio in the manifest 即可使其正常工作。