I am search for a few hours, to find a good way to mute a QWebPage. I don't want to display the web page. I just fetched it and then i evaluate one line of javascript code in it. Then i close the QPageView.
But the web page includes some mp3 streams, so while the javascript code is evaluated i can hear from this stream. I try to cut the mp3 sound until terminated the QWebBrowser.
I use QWebKit instead of QWebEngine because there is no available package for msys posix platoform (link).
So the problem is for just one or two seconds. I didn't find anything useful about in QWebSettings page
In file: C:\mysys64\mingw64\include\QtWebKit\5.212.0\QtWebKit\private\qwebpreferences_p.h at line 108 i found this:
void setWebAudioEnabled(bool enable);
So somehow it might be a way to mute the QWebView or the QWebPage.
I found an answer here in stackoverflow that evaluates javascript code when the page is loaded to mute all video and audio tags that the page has. But this answer also has a delay problem.
So, how can i mute all the sound a web page has in python QWebKit - QWebPage?
Have you considered using
QWebPage.ToggleMediaMute? According to the C++ documentation:This means that you should be able to take a QWebPage from your source code and call
qwp.action(QWebPage.ToggleMediaMute)in order to mute audio from the page.