summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJüri Valdmann <juri.valdmann@qt.io>2017-04-05 17:14:16 +0200
committerJüri Valdmann <juri.valdmann@qt.io>2017-05-04 12:45:40 +0000
commitb24a6419869c14e32e87cb97e529cc25c246b5e0 (patch)
tree78fbdb3729c4f9de8ef36c25bb187bdecb4c1726
parent8ed45ab8997757ddd98ea8132f0a9bb3ad26e52a (diff)
Create example for full screen feature in WebEngine
Adds an example ('videoplayer') showing how to enable the Fullscreen API[1] in QWebEngineView. This is one of the missing examples blocking the removal of demobrowser. [1]: https://fullscreen.spec.whatwg.org Task-number: QTBUG-59820 Change-Id: Ib02a1556515d87e595ca54c2bce18c9144030fbc Reviewed-by: Kai Koehne <kai.koehne@qt.io> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Michal Klocek <michal.klocek@qt.io>
-rw-r--r--examples/webenginewidgets/videoplayer/data/index.html23
-rw-r--r--examples/webenginewidgets/videoplayer/data/videoplayer.qrc5
-rw-r--r--examples/webenginewidgets/videoplayer/doc/images/videoplayer-example.pngbin0 -> 34140 bytes
-rw-r--r--examples/webenginewidgets/videoplayer/doc/src/videoplayer.qdoc186
-rw-r--r--examples/webenginewidgets/videoplayer/fullscreennotification.cpp87
-rw-r--r--examples/webenginewidgets/videoplayer/fullscreennotification.h61
-rw-r--r--examples/webenginewidgets/videoplayer/fullscreenwindow.cpp88
-rw-r--r--examples/webenginewidgets/videoplayer/fullscreenwindow.h68
-rw-r--r--examples/webenginewidgets/videoplayer/main.cpp53
-rw-r--r--examples/webenginewidgets/videoplayer/mainwindow.cpp72
-rw-r--r--examples/webenginewidgets/videoplayer/mainwindow.h64
-rw-r--r--examples/webenginewidgets/videoplayer/videoplayer.pro19
-rw-r--r--examples/webenginewidgets/webenginewidgets.pro3
-rw-r--r--src/webengine/doc/qtwebengine.qdocconf2
14 files changed, 729 insertions, 2 deletions
diff --git a/examples/webenginewidgets/videoplayer/data/index.html b/examples/webenginewidgets/videoplayer/data/index.html
new file mode 100644
index 000000000..4a1bdc33e
--- /dev/null
+++ b/examples/webenginewidgets/videoplayer/data/index.html
@@ -0,0 +1,23 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8">
+ <style type="text/css">
+ #ytplayer {
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 100%;
+ }
+ </style>
+ </head>
+ <body>
+ <iframe
+ id="ytplayer"
+ src="https://www.youtube.com/embed/CjyjEUFn_FI"
+ frameborder="0"
+ allowfullscreen>
+ </iframe>
+ </body>
+</html>
diff --git a/examples/webenginewidgets/videoplayer/data/videoplayer.qrc b/examples/webenginewidgets/videoplayer/data/videoplayer.qrc
new file mode 100644
index 000000000..c3322b454
--- /dev/null
+++ b/examples/webenginewidgets/videoplayer/data/videoplayer.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/">
+ <file>index.html</file>
+ </qresource>
+</RCC>
diff --git a/examples/webenginewidgets/videoplayer/doc/images/videoplayer-example.png b/examples/webenginewidgets/videoplayer/doc/images/videoplayer-example.png
new file mode 100644
index 000000000..9cf51d84a
--- /dev/null
+++ b/examples/webenginewidgets/videoplayer/doc/images/videoplayer-example.png
Binary files differ
diff --git a/examples/webenginewidgets/videoplayer/doc/src/videoplayer.qdoc b/examples/webenginewidgets/videoplayer/doc/src/videoplayer.qdoc
new file mode 100644
index 000000000..599e13e6c
--- /dev/null
+++ b/examples/webenginewidgets/videoplayer/doc/src/videoplayer.qdoc
@@ -0,0 +1,186 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \example webenginewidgets/videoplayer
+ \title WebEngine Widgets Video Player Example
+ \ingroup webengine-widgetexamples
+ \brief Displays full screen video using \l QWebEngineView
+
+ \image videoplayer-example.png
+
+ \e {Video Player} demonstrates how to support full screen playback of HTML5
+ video using \l QWebEngineView.
+
+ \l {https://fullscreen.spec.whatwg.org/}{The Fullscreen API} is a
+ cross-browser Javascript API that enables a web page to request that one of
+ its HTML elements be made to occupy the user's entire screen. It is
+ commonly used for full screen video playback via the \c <video> element, but
+ can in principle be used to display any HTML content in full screen mode. Qt
+ WebEngine supports this API, however it is disabled by default. This example
+ shows the steps needed to switch it on, including:
+
+ \list
+ \li Enabling it in \l QWebEngineSettings.
+ \li Handling the \l QWebEnginePage::fullScreenRequested signal by creating
+ a new full screen window.
+ \li Displaying a notification popup to ensure that the user is aware
+ that something is being displayed full screen.
+ \endlist
+
+ \include examples-run.qdocinc
+
+ \section1 Overview
+
+ Once started, the example program will create a normal (non-fullscreen)
+ window with a \l QWebEngineView showing an embedded YouTube video player.
+ You can then click on the full screen toggle button (bottom-right corner) to
+ enter full screen mode. This should also display a centered notification
+ overlay informing you that you can exit full screen mode by pressing the
+ escape key.
+
+ Implementation-wise entering full screen mode entails creating a new full
+ screen window with a separate \l QWebEngineView instance and migrating the
+ \l QWebEnginePage from the normal window's \l QWebEngineView to this new \l
+ QWebEngineView. Exiting full screen mode reverses this migration.
+
+ The example code is divided between three classes, \c MainWindow, \c
+ FullScreenWindow, and \c FullScreenNotification. The classes \c MainWindow
+ and \c FullScreenWindow are each responsible for managing one top-level
+ window, while \c FullScreenNotification is responsible for styling and
+ animating the notification box. A \c MainWindow is created on startup and
+ lives for the entire program runtime, while a new \c FullScreenWindow is
+ created every time full screen mode is entered.
+
+ \section1 MainWindow Class Declaration
+
+ A \c MainWindow is a \l QMainWindow with a \l QWebEngineView as the central
+ widget:
+
+ \quotefromfile webenginewidgets/videoplayer/mainwindow.h
+ \skipto #include
+ \printuntil /^\}/
+
+ \section1 MainWindow Class Definition
+
+ In the constructor we start by setting up the \l QWebEngineView as the
+ central widget:
+
+ \quotefromfile webenginewidgets/videoplayer/mainwindow.cpp
+ \skipto MainWindow::MainWindow
+ \printuntil setCentralWidget
+
+ We then configure Qt WebEngine to advertise support for the Fullscreen API:
+
+ \printline QWebEngineSettings
+
+ Without this line the full screen toggle button would be disabled (grayed
+ out) as the Javascript running on the page can detect that our browser
+ does not support full screen mode.
+
+ Next we connect the \c fullScreenRequested signal to our slot:
+
+ \printuntil &MainWindow::fullScreenRequested
+
+ This signal is emitted whenever the Javascript on the page wants to enter or
+ exit full screen mode. Without handling this signal (but still keeping the
+ \c FullScreenSupportEnabled attribute as \c true) the toggle button will be
+ enabled but clicking on it will have no effect as Javascript's full screen
+ request will be denied.
+
+ Finally, we load some HTML (see
+ \l{webenginewidgets/videoplayer/data/index.html}{index.html} included with
+ the example) into our \l QWebEngineView:
+
+ \printline load
+
+ The second part of \c MainWindow is handling the full screen requests:
+
+ \skipto MainWindow::fullScreenRequested
+ \printuntil /^\}/
+
+ We create a new \c FullScreenWindow when entering full screen mode, and
+ delete it when exiting.
+
+ \section1 FullScreenWindow Class Declaration
+
+ A \c FullScreenWindow is a \l QWidget containing a \l QWebEngineView and a
+ \c FullScreenNotification.
+
+ \quotefromfile webenginewidgets/videoplayer/fullscreenwindow.h
+ \skipto #include
+ \printuntil /^\}/
+
+ \section1 FullScreenWindow Class Definition
+
+ The constructor is responsible for hiding the normal window (while saving
+ its geometry) and showing the new \c FullScreenWindow instead:
+
+ \quotefromfile webenginewidgets/videoplayer/fullscreenwindow.cpp
+ \skipto FullScreenWindow::FullScreenWindow
+ \printuntil /^\}/
+
+ The call to \l QWebEngineView::setPage will move the web page from the \c
+ MainWindow's view to \c FullScreenWindow's view.
+
+ In the destructor we use the same method to move the page back, after which
+ we restore the main window's geometry and visibility:
+
+ \skipto FullScreenWindow::~FullScreenWindow
+ \printuntil /^\}/
+
+ We override \l QWidget::resizeEvent to do manual layout, keeping the \l
+ QWebEngineView maximized, and the \c FullScreenNotification centered within
+ the window:
+
+ \skipto FullScreenWindow::resizeEvent
+ \printuntil /^\}/
+
+ \section1 FullScreenNotification Class Declaration
+
+ A \c FullScreenNotification is just a \l QLabel with some styling and
+ animation:
+
+ \quotefromfile webenginewidgets/videoplayer/fullscreennotification.h
+ \skipto #include
+ \printuntil /^\}/
+
+ \section1 FullScreenWindow Class Definition
+
+ In the constructor we configure the QLabel and set up a delayed fade-out
+ animation using \l {The Animation Framework}:
+
+ \quotefromfile webenginewidgets/videoplayer/fullscreennotification.cpp
+ \skipto FullScreenNotification::FullScreenNotification
+ \printuntil /^\}/
+
+ The custom signal \c shown, which we use to trigger the animation, is
+ emitted from the \c showEvent method:
+
+ \skipto FullScreenNotification::showEvent
+ \printuntil /^\}/
+*/
diff --git a/examples/webenginewidgets/videoplayer/fullscreennotification.cpp b/examples/webenginewidgets/videoplayer/fullscreennotification.cpp
new file mode 100644
index 000000000..e65e2cbad
--- /dev/null
+++ b/examples/webenginewidgets/videoplayer/fullscreennotification.cpp
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "fullscreennotification.h"
+
+#include <QGraphicsOpacityEffect>
+#include <QPropertyAnimation>
+#include <QSequentialAnimationGroup>
+
+FullScreenNotification::FullScreenNotification(QWidget *parent)
+ : QLabel(parent)
+ , m_previouslyVisible(false)
+{
+ setText(tr("You are now in full screen mode. Press ESC to quit!"));
+ setStyleSheet(
+ "font-size: 24px;"
+ "color: white;"
+ "background-color: black;"
+ "border-color: white;"
+ "border-width: 2px;"
+ "border-style: solid;"
+ "padding: 100px");
+ setAttribute(Qt::WA_TransparentForMouseEvents);
+
+ auto effect = new QGraphicsOpacityEffect;
+ effect->setOpacity(1);
+ setGraphicsEffect(effect);
+
+ auto animations = new QSequentialAnimationGroup(this);
+ animations->addPause(3000);
+ auto opacityAnimation = new QPropertyAnimation(effect, "opacity", animations);
+ opacityAnimation->setDuration(2000);
+ opacityAnimation->setStartValue(1.0);
+ opacityAnimation->setEndValue(0.0);
+ opacityAnimation->setEasingCurve(QEasingCurve::OutQuad);
+ animations->addAnimation(opacityAnimation);
+
+ connect(this, &FullScreenNotification::shown,
+ [animations](){ animations->start(); });
+
+ connect(animations, &QAbstractAnimation::finished,
+ [this](){ this->hide(); });
+}
+
+void FullScreenNotification::showEvent(QShowEvent *event)
+{
+ QLabel::showEvent(event);
+ if (!m_previouslyVisible && isVisible())
+ emit shown();
+ m_previouslyVisible = isVisible();
+}
diff --git a/examples/webenginewidgets/videoplayer/fullscreennotification.h b/examples/webenginewidgets/videoplayer/fullscreennotification.h
new file mode 100644
index 000000000..9f1befb9f
--- /dev/null
+++ b/examples/webenginewidgets/videoplayer/fullscreennotification.h
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef FULLSCREENNOTIFICATION_H
+#define FULLSCREENNOTIFICATION_H
+
+#include <QLabel>
+
+class FullScreenNotification : public QLabel
+{
+ Q_OBJECT
+public:
+ FullScreenNotification(QWidget *parent = nullptr);
+
+protected:
+ void showEvent(QShowEvent *event) override;
+
+signals:
+ void shown();
+
+private:
+ bool m_previouslyVisible;
+};
+
+#endif // FULLSCREENNOTIFICATION_H
diff --git a/examples/webenginewidgets/videoplayer/fullscreenwindow.cpp b/examples/webenginewidgets/videoplayer/fullscreenwindow.cpp
new file mode 100644
index 000000000..df28839a2
--- /dev/null
+++ b/examples/webenginewidgets/videoplayer/fullscreenwindow.cpp
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "fullscreenwindow.h"
+
+#include "fullscreennotification.h"
+
+#include <QAction>
+#include <QLabel>
+#include <QWebEngineView>
+
+FullScreenWindow::FullScreenWindow(QWebEngineView *oldView, QWidget *parent)
+ : QWidget(parent)
+ , m_view(new QWebEngineView(this))
+ , m_notification(new FullScreenNotification(this))
+ , m_oldView(oldView)
+ , m_oldGeometry(oldView->window()->geometry())
+{
+ m_view->stackUnder(m_notification);
+
+ auto exitAction = new QAction(this);
+ exitAction->setShortcut(Qt::Key_Escape);
+ connect(exitAction, &QAction::triggered, [this]() {
+ m_view->triggerPageAction(QWebEnginePage::ExitFullScreen);
+ });
+ addAction(exitAction);
+
+ m_view->setPage(m_oldView->page());
+ setGeometry(m_oldGeometry);
+ showFullScreen();
+ m_oldView->window()->hide();
+}
+
+FullScreenWindow::~FullScreenWindow()
+{
+ m_oldView->setPage(m_view->page());
+ m_oldView->window()->setGeometry(m_oldGeometry);
+ m_oldView->window()->show();
+ hide();
+}
+
+void FullScreenWindow::resizeEvent(QResizeEvent *event)
+{
+ QRect viewGeometry(QPoint(0, 0), size());
+ m_view->setGeometry(viewGeometry);
+
+ QRect notificationGeometry(QPoint(0, 0), m_notification->sizeHint());
+ notificationGeometry.moveCenter(viewGeometry.center());
+ m_notification->setGeometry(notificationGeometry);
+
+ QWidget::resizeEvent(event);
+}
diff --git a/examples/webenginewidgets/videoplayer/fullscreenwindow.h b/examples/webenginewidgets/videoplayer/fullscreenwindow.h
new file mode 100644
index 000000000..dda0a9885
--- /dev/null
+++ b/examples/webenginewidgets/videoplayer/fullscreenwindow.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef FULLSCREENWINDOW_H
+#define FULLSCREENWINDOW_H
+
+#include <QWidget>
+
+QT_BEGIN_NAMESPACE
+class QWebEngineView;
+QT_END_NAMESPACE
+
+class FullScreenNotification;
+
+class FullScreenWindow : public QWidget
+{
+ Q_OBJECT
+public:
+ explicit FullScreenWindow(QWebEngineView *oldView, QWidget *parent = nullptr);
+ ~FullScreenWindow();
+
+protected:
+ void resizeEvent(QResizeEvent *event) override;
+
+private:
+ QWebEngineView *m_view;
+ FullScreenNotification *m_notification;
+ QWebEngineView *m_oldView;
+ QRect m_oldGeometry;
+};
+
+#endif // FULLSCREENWINDOW_H
diff --git a/examples/webenginewidgets/videoplayer/main.cpp b/examples/webenginewidgets/videoplayer/main.cpp
new file mode 100644
index 000000000..fcddd988e
--- /dev/null
+++ b/examples/webenginewidgets/videoplayer/main.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "mainwindow.h"
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+ QApplication app(argc, argv);
+
+ MainWindow mainWindow;
+ mainWindow.show();
+
+ return app.exec();
+}
diff --git a/examples/webenginewidgets/videoplayer/mainwindow.cpp b/examples/webenginewidgets/videoplayer/mainwindow.cpp
new file mode 100644
index 000000000..55885e0c5
--- /dev/null
+++ b/examples/webenginewidgets/videoplayer/mainwindow.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "mainwindow.h"
+
+#include <QWebEngineView>
+#include <QWebEngineSettings>
+#include <QWebEngineFullScreenRequest>
+
+MainWindow::MainWindow(QWidget *parent)
+ : QMainWindow(parent)
+ , m_view(new QWebEngineView(this))
+{
+ setCentralWidget(m_view);
+ m_view->settings()->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, true);
+ connect(m_view->page(),
+ &QWebEnginePage::fullScreenRequested,
+ this,
+ &MainWindow::fullScreenRequested);
+ m_view->load(QUrl(QStringLiteral("qrc:/index.html")));
+}
+
+void MainWindow::fullScreenRequested(QWebEngineFullScreenRequest request)
+{
+ if (request.toggleOn()) {
+ if (m_fullScreenWindow)
+ return;
+ request.accept();
+ m_fullScreenWindow.reset(new FullScreenWindow(m_view));
+ } else {
+ if (!m_fullScreenWindow)
+ return;
+ request.accept();
+ m_fullScreenWindow.reset();
+ }
+}
diff --git a/examples/webenginewidgets/videoplayer/mainwindow.h b/examples/webenginewidgets/videoplayer/mainwindow.h
new file mode 100644
index 000000000..a270c6295
--- /dev/null
+++ b/examples/webenginewidgets/videoplayer/mainwindow.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include "fullscreenwindow.h"
+
+#include <QMainWindow>
+#include <QWebEngineView>
+#include <QWebEngineFullScreenRequest>
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ explicit MainWindow(QWidget *parent = nullptr);
+
+private slots:
+ void fullScreenRequested(QWebEngineFullScreenRequest request);
+
+private:
+ QWebEngineView *m_view;
+ QScopedPointer<FullScreenWindow> m_fullScreenWindow;
+};
+
+#endif // MAINWINDOW_H
diff --git a/examples/webenginewidgets/videoplayer/videoplayer.pro b/examples/webenginewidgets/videoplayer/videoplayer.pro
new file mode 100644
index 000000000..ab55992e0
--- /dev/null
+++ b/examples/webenginewidgets/videoplayer/videoplayer.pro
@@ -0,0 +1,19 @@
+TEMPLATE = app
+
+QT += webenginewidgets
+
+HEADERS += \
+ mainwindow.h \
+ fullscreenwindow.h \
+ fullscreennotification.h
+
+SOURCES += main.cpp \
+ mainwindow.cpp \
+ fullscreenwindow.cpp \
+ fullscreennotification.cpp
+
+RESOURCES += \
+ data/videoplayer.qrc
+
+target.path = $$[QT_INSTALL_EXAMPLES]/webenginewidgets/videoplayer
+INSTALLS += target
diff --git a/examples/webenginewidgets/webenginewidgets.pro b/examples/webenginewidgets/webenginewidgets.pro
index 353104d6a..41582bbf7 100644
--- a/examples/webenginewidgets/webenginewidgets.pro
+++ b/examples/webenginewidgets/webenginewidgets.pro
@@ -6,7 +6,8 @@ SUBDIRS += \
cookiebrowser \
demobrowser \
markdowneditor \
- simplebrowser
+ simplebrowser \
+ videoplayer
contains(WEBENGINE_CONFIG, use_spellchecker):!cross_compile {
!contains(WEBENGINE_CONFIG, use_native_spellchecker) {
diff --git a/src/webengine/doc/qtwebengine.qdocconf b/src/webengine/doc/qtwebengine.qdocconf
index fe83b082f..bc63addbe 100644
--- a/src/webengine/doc/qtwebengine.qdocconf
+++ b/src/webengine/doc/qtwebengine.qdocconf
@@ -67,7 +67,7 @@ exampledirs += . \
../../core/doc/snippets \
../../webenginewidgets/doc/snippets
-examples.fileextensions += *.aff *.dic
+examples.fileextensions += *.aff *.dic *.html
imagedirs += images