diff --git a/src/lib/tools/scripts.cpp b/src/lib/tools/scripts.cpp index ab917a982..fafff618c 100644 --- a/src/lib/tools/scripts.cpp +++ b/src/lib/tools/scripts.cpp @@ -279,30 +279,3 @@ QString Scripts::getFormData(const QPoint &pos) return source.arg(pos.x()).arg(pos.y()); } - -QString Scripts::toggleMediaPause(const QPoint &pos) -{ - QString source = QL1S("(function() {" - "var e = document.elementFromPoint(%1, %2);" - "if (!e)" - " return;" - "if (e.paused)" - " e.play();" - "else" - " e.pause();" - "})()"); - - return source.arg(pos.x()).arg(pos.y()); -} - -QString Scripts::toggleMediaMute(const QPoint &pos) -{ - QString source = QL1S("(function() {" - "var e = document.elementFromPoint(%1, %2);" - "if (!e)" - " return;" - "e.muted = !e.muted;" - "})()"); - - return source.arg(pos.x()).arg(pos.y()); -} diff --git a/src/lib/tools/scripts.h b/src/lib/tools/scripts.h index 9f46ae2ef..b2c66d41b 100644 --- a/src/lib/tools/scripts.h +++ b/src/lib/tools/scripts.h @@ -1,6 +1,6 @@ /* ============================================================ * QupZilla - WebKit based browser -* Copyright (C) 2015 David Rosca +* Copyright (C) 2015-2016 David Rosca * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -38,8 +38,6 @@ public: static QString getAllImages(); static QString getAllMetaAttributes(); static QString getFormData(const QPoint &pos); - static QString toggleMediaPause(const QPoint &pos); - static QString toggleMediaMute(const QPoint &pos); }; #endif // SCRIPTS_H diff --git a/src/lib/webengine/webview.cpp b/src/lib/webengine/webview.cpp index 199afed2f..17feabd9d 100644 --- a/src/lib/webengine/webview.cpp +++ b/src/lib/webengine/webview.cpp @@ -1,6 +1,6 @@ /* ============================================================ * QupZilla - WebKit based browser -* Copyright (C) 2010-2014 David Rosca +* Copyright (C) 2010-2016 David Rosca * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -873,12 +873,12 @@ void WebView::reloadAllSpeedDials() void WebView::toggleMediaPause() { - page()->runJavaScript(Scripts::toggleMediaPause(m_clickedPos)); + triggerPageAction(QWebEnginePage::ToggleMediaPlayPause); } void WebView::toggleMediaMute() { - page()->runJavaScript(Scripts::toggleMediaMute(m_clickedPos)); + triggerPageAction(QWebEnginePage::ToggleMediaMute); } void WebView::initializeActions()