Quantcast
Channel: QtWebEngine
Viewing all articles
Browse latest Browse all 13965

Disable sound in QWebPage

$
0
0
Is it possible to disable sound in QWebPage ? Till now I’ve managed to completely disable javascript pop-ups etc using this code: class CustomWebPage : public QWebPage { protected:     virtual QString chooseFile(QWebFrame *, const QString&) { return QString(); }     virtual void javaScriptAlert (QWebFrame*, const QString &) {}     virtual bool javaScriptConfirm(QWebFrame *, const QString &) { return false; }     virtual bool javaScriptPrompt(QWebFrame *, const QString &, const QString &, QString *) { return false; } }; I also tried muting any <audio> and <video>, but unsuccessfully: QWebElement bodyElem = webPage->mainFrame()->documentElement().findFirst("body");       bodyElem.evaluateJavaScript("var mute=function(tag){"\                                              "    var elems = document.getElementsByTagName(tag);"\                                              "    for(var i = 0; i < elems.length; i++){"\                                              "        elems[i].muted=true;" \                                              "    }    "\                                              "}"\                                              "mute(\"video\");"\                                              "mute(\"audio\");"\                                              ); While the above code works here, for example: http://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_audio_muted But this was just a workaround. I would like, if possible, to mute the whole QWebPage.

Viewing all articles
Browse latest Browse all 13965