@Pablo Glomby , based on my test, I also reproduced your problem. Based on my research, it may be an issue for the webview2. I recommend that you could sumbit the issue in the Github.
A generic solution like IsMuted=true for audio... Because I don't want to go inside the HTML since the video renderer may be different.
Currently, I could not find other way to stop the video like the IsMuted property. I also find a workaround about the html method you mentioned.
You could refer to the following code to do it.
private async void SuspendWebView2(WebView2 webView2)
{
string pausefunctionString = @"
var videos = document.querySelectorAll('video');
[].forEach.call(videos, function(video) { video.pause(); });
";
await webView2.ExecuteScriptAsync(pausefunctionString);
}
However, as you said, the method may have certain flaws because their video renderer may be different.(based on my test, it works for YouTube video)
BTW, if you still want to use CoreWebView2.TrySuspendAsync method to solve it, I still recommend that you submit the issue in Github.
Best Regards,
Jack
If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.