Verified Commit 5af9fbea authored by Artem Sidyakin's avatar Artem Sidyakin
Browse files

Picture in picture demo

parent c54ef27d
......@@ -17,6 +17,7 @@ A set of rather simple projects that demonstrate various Qt features.
- [2D and 3D in the same application](#2d-and-3d-in-the-same-application)
- [SQLite from QML](#sqlite-from-qml)
- [Working with filesystem](#working-with-filesystem)
- [Picture in picture](#picture-in-picture)
## Open Source API
......@@ -98,3 +99,9 @@ Working with SQLite database from QML. Actually it's not from QML.
Creating and deleting files.
<img src="/img/working-with-filesystem.png" width="800">
## Picture in picture
One video is playing on top of another (nested).
<img src="/img/picture-in-picture.png" width="800">
#include <QGuiApplication>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
if (engine.rootObjects().isEmpty()) { return -1; }
return app.exec();
}
import QtQuick 2.12
import QtQuick.Window 2.12
import QtMultimedia 5.12
Window {
visible: true
width: 900
minimumWidth: 700
height: 500
minimumHeight: 400
title: qsTr("Picture in picture")
Rectangle {
anchors.fill: parent
border.width: 1
Video {
id: mainVideo
anchors.fill: parent
anchors.margins: 1
fillMode: VideoOutput.PreserveAspectCrop
loops: MediaPlayer.Infinite
autoPlay: true
muted: true
source: "qrc:/video1.mp4"
Rectangle {
anchors.right: parent.right
anchors.rightMargin: -1
anchors.bottom: parent.bottom
anchors.bottomMargin: -1
width: parent.width / 2
height: parent.height / 2
border.width: 1
Video {
id: secondVideo
anchors.fill: parent
anchors.margins: 1
fillMode: VideoOutput.PreserveAspectCrop
loops: MediaPlayer.Infinite
autoPlay: true
muted: true
source: "qrc:/video2.mp4"
}
}
}
}
}
QT += quick multimedia
CONFIG += c++11
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Refer to the documentation for the
# deprecated API to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
main.cpp
RESOURCES += qml.qrc
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
# Additional import path used to resolve QML modules just for Qt Quick Designer
QML_DESIGNER_IMPORT_PATH =
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
<RCC>
<qresource prefix="/">
<file>main.qml</file>
<file>video2.mp4</file>
<file>video1.mp4</file>
</qresource>
</RCC>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment