diff options
Diffstat (limited to 'examples/multimediawidgets/customvideosurface/customvideoitem')
7 files changed, 0 insertions, 651 deletions
diff --git a/examples/multimediawidgets/customvideosurface/customvideoitem/CMakeLists.txt b/examples/multimediawidgets/customvideosurface/customvideoitem/CMakeLists.txt deleted file mode 100644 index a6fa324a2..000000000 --- a/examples/multimediawidgets/customvideosurface/customvideoitem/CMakeLists.txt +++ /dev/null @@ -1,51 +0,0 @@ -# Generated from customvideoitem.pro. - -cmake_minimum_required(VERSION 3.14) -project(customvideoitem LANGUAGES CXX) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/multimediawidgets/customvideosurface/customvideoitem") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Multimedia) -find_package(Qt6 COMPONENTS MultimediaWidgets) -find_package(Qt6 COMPONENTS Widgets) - -qt_add_executable(customvideoitem - main.cpp - videoitem.cpp videoitem.h - videoplayer.cpp videoplayer.h -) -set_target_properties(customvideoitem PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -target_link_libraries(customvideoitem PUBLIC - Qt::Core - Qt::Gui - Qt::Multimedia - Qt::MultimediaWidgets - Qt::Widgets -) - -if(TARGET Qt::OpenGL) - target_link_libraries(customvideoitem PUBLIC - Qt::OpenGL - ) -endif() - -install(TARGETS customvideoitem - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/multimediawidgets/customvideosurface/customvideoitem/customvideoitem.pro b/examples/multimediawidgets/customvideosurface/customvideoitem/customvideoitem.pro deleted file mode 100644 index 2fb123e77..000000000 --- a/examples/multimediawidgets/customvideosurface/customvideoitem/customvideoitem.pro +++ /dev/null @@ -1,16 +0,0 @@ -TEMPLATE = app -TARGET = customvideoitem - -QT += multimedia multimediawidgets widgets - -qtHaveModule(opengl): QT += opengl - -HEADERS += videoplayer.h \ - videoitem.h - -SOURCES += main.cpp \ - videoplayer.cpp \ - videoitem.cpp - -target.path = $$[QT_INSTALL_EXAMPLES]/multimediawidgets/customvideosurface/customvideoitem -INSTALLS += target diff --git a/examples/multimediawidgets/customvideosurface/customvideoitem/main.cpp b/examples/multimediawidgets/customvideosurface/customvideoitem/main.cpp deleted file mode 100644 index 8db790deb..000000000 --- a/examples/multimediawidgets/customvideosurface/customvideoitem/main.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** 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$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 "videoplayer.h" - -#include <QApplication> - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - VideoPlayer player; - player.show(); - - return app.exec(); -} - diff --git a/examples/multimediawidgets/customvideosurface/customvideoitem/videoitem.cpp b/examples/multimediawidgets/customvideosurface/customvideoitem/videoitem.cpp deleted file mode 100644 index 0271f023a..000000000 --- a/examples/multimediawidgets/customvideosurface/customvideoitem/videoitem.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/**************************************************************************** -** -** 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$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 "videoitem.h" - -#include <QPainter> -#include <QTransform> -#include <QVideoSurfaceFormat> - -VideoItem::VideoItem(QGraphicsItem *parent) - : QGraphicsItem(parent) - , imageFormat(QImage::Format_Invalid) - , framePainted(false) -{ -} - -VideoItem::~VideoItem() = default; - -QRectF VideoItem::boundingRect() const -{ - return QRectF(QPointF(0,0), surfaceFormat().sizeHint()); -} - -void VideoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) -{ - Q_UNUSED(option); - Q_UNUSED(widget); - - if (currentFrame.map(QVideoFrame::ReadOnly)) { - const QTransform oldTransform = painter->transform(); - - if (surfaceFormat().scanLineDirection() == QVideoSurfaceFormat::BottomToTop) { - painter->scale(1, -1); - painter->translate(0, -boundingRect().height()); - } - - painter->drawImage(boundingRect(), QImage( - currentFrame.bits(), - imageSize.width(), - imageSize.height(), - imageFormat)); - - painter->setTransform(oldTransform); - - framePainted = true; - - currentFrame.unmap(); - } -} - -QList<QVideoFrame::PixelFormat> VideoItem::supportedPixelFormats( - QVideoFrame::HandleType handleType) const -{ - if (handleType == QVideoFrame::NoHandle) { - return QList<QVideoFrame::PixelFormat>() - << QVideoFrame::Format_RGB32 - << QVideoFrame::Format_ARGB32 - << QVideoFrame::Format_ARGB32_Premultiplied - << QVideoFrame::Format_RGB565 - << QVideoFrame::Format_RGB555; - } - - return QList<QVideoFrame::PixelFormat>(); -} - -bool VideoItem::start(const QVideoSurfaceFormat &format) -{ - if (isFormatSupported(format)) { - imageFormat = QVideoFrame::imageFormatFromPixelFormat(format.pixelFormat()); - imageSize = format.frameSize(); - framePainted = true; - - QAbstractVideoSurface::start(format); - - prepareGeometryChange(); - - return true; - } - - return false; -} - -void VideoItem::stop() -{ - currentFrame = QVideoFrame(); - framePainted = false; - - QAbstractVideoSurface::stop(); -} - -bool VideoItem::present(const QVideoFrame &frame) -{ - if (!framePainted) { - if (!QAbstractVideoSurface::isActive()) - setError(StoppedError); - - return false; - } - - currentFrame = frame; - framePainted = false; - - update(); - - return true; -} diff --git a/examples/multimediawidgets/customvideosurface/customvideoitem/videoitem.h b/examples/multimediawidgets/customvideosurface/customvideoitem/videoitem.h deleted file mode 100644 index 7fff81a2f..000000000 --- a/examples/multimediawidgets/customvideosurface/customvideoitem/videoitem.h +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** 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$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 VIDEOITEM_H -#define VIDEOITEM_H - -#include <QAbstractVideoSurface> -#include <QGraphicsItem> - -class VideoItem - : public QAbstractVideoSurface, - public QGraphicsItem -{ - Q_OBJECT - Q_INTERFACES(QGraphicsItem) - -public: - explicit VideoItem(QGraphicsItem *parentItem = 0); - ~VideoItem(); - - QRectF boundingRect() const override; - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) override; - - //video surface - QList<QVideoFrame::PixelFormat> supportedPixelFormats( - QVideoFrame::HandleType handleType = QVideoFrame::NoHandle) const override; - - bool start(const QVideoSurfaceFormat &format) override; - void stop() override; - bool present(const QVideoFrame &frame) override; - -private: - QImage::Format imageFormat; - QSize imageSize; - - QVideoFrame currentFrame; - bool framePainted; -}; - -#endif // VIDEOITEM_H - diff --git a/examples/multimediawidgets/customvideosurface/customvideoitem/videoplayer.cpp b/examples/multimediawidgets/customvideosurface/customvideoitem/videoplayer.cpp deleted file mode 100644 index 2c2286d72..000000000 --- a/examples/multimediawidgets/customvideosurface/customvideoitem/videoplayer.cpp +++ /dev/null @@ -1,185 +0,0 @@ -/**************************************************************************** -** -** 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$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 "videoplayer.h" -#include "videoitem.h" - -#include <QtWidgets> -#include <QVideoSurfaceFormat> - -#if !defined(QT_NO_OPENGL) -# include <QOpenGLWidget> -#endif - -VideoPlayer::VideoPlayer(QWidget *parent) - : QWidget(parent) - , mediaPlayer(nullptr) - , videoItem(nullptr) - , playButton(nullptr) - , positionSlider(nullptr) -{ - videoItem = new VideoItem; - - QGraphicsScene *scene = new QGraphicsScene(this); - QGraphicsView *graphicsView = new QGraphicsView(scene); - -#if !defined(QT_NO_OPENGL) - graphicsView->setViewport(new QOpenGLWidget); -#endif - - scene->addItem(videoItem); - - QSlider *rotateSlider = new QSlider(Qt::Horizontal); - rotateSlider->setRange(-180, 180); - rotateSlider->setValue(0); - - connect(rotateSlider, &QSlider::valueChanged, - this, &VideoPlayer::rotateVideo); - - QAbstractButton *openButton = new QPushButton(tr("Open...")); - connect(openButton, &QAbstractButton::clicked, - this, &VideoPlayer::openFile); - - playButton = new QPushButton; - playButton->setEnabled(false); - playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay)); - - connect(playButton, &QAbstractButton::clicked, - this, &VideoPlayer::play); - - positionSlider = new QSlider(Qt::Horizontal); - positionSlider->setRange(0, 0); - - connect(positionSlider, &QSlider::sliderMoved, - this, &VideoPlayer::setPosition); - - QBoxLayout *controlLayout = new QHBoxLayout; - controlLayout->setContentsMargins(0, 0, 0, 0); - controlLayout->addWidget(openButton); - controlLayout->addWidget(playButton); - controlLayout->addWidget(positionSlider); - - QBoxLayout *layout = new QVBoxLayout; - layout->addWidget(graphicsView); - layout->addWidget(rotateSlider); - layout->addLayout(controlLayout); - - setLayout(layout); - - mediaPlayer.setVideoOutput(videoItem); - connect(&mediaPlayer, &QMediaPlayer::stateChanged, - this, &VideoPlayer::mediaStateChanged); - connect(&mediaPlayer, &QMediaPlayer::positionChanged, this, &VideoPlayer::positionChanged); - connect(&mediaPlayer, &QMediaPlayer::durationChanged, this, &VideoPlayer::durationChanged); -} - -VideoPlayer::~VideoPlayer() -{ -} - - -void VideoPlayer::openFile() -{ - QString fileName = QFileDialog::getOpenFileName(this, tr("Open Movie"),QDir::homePath()); - - if (!fileName.isEmpty()) { - mediaPlayer.setMedia(QUrl::fromLocalFile(fileName)); - - playButton->setEnabled(true); - } -} - -void VideoPlayer::play() -{ - switch(mediaPlayer.state()) { - case QMediaPlayer::PlayingState: - mediaPlayer.pause(); - break; - default: - mediaPlayer.play(); - break; - } -} - -void VideoPlayer::mediaStateChanged(QMediaPlayer::State state) -{ - switch(state) { - case QMediaPlayer::PlayingState: - playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPause)); - break; - default: - playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay)); - break; - } -} - -void VideoPlayer::positionChanged(qint64 position) -{ - positionSlider->setValue(position); -} - -void VideoPlayer::durationChanged(qint64 duration) -{ - positionSlider->setRange(0, duration); -} - -void VideoPlayer::setPosition(int position) -{ - mediaPlayer.setPosition(position); -} - - -void VideoPlayer::rotateVideo(int angle) -{ - //rotate around the center of video element - qreal x = videoItem->boundingRect().width() / 2.0; - qreal y = videoItem->boundingRect().height() / 2.0; - videoItem->setTransform(QTransform().translate(x, y).rotate(angle).translate(-x, -y)); -} diff --git a/examples/multimediawidgets/customvideosurface/customvideoitem/videoplayer.h b/examples/multimediawidgets/customvideosurface/customvideoitem/videoplayer.h deleted file mode 100644 index 0ee7d751e..000000000 --- a/examples/multimediawidgets/customvideosurface/customvideoitem/videoplayer.h +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** 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$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 VIDEOPLAYER_H -#define VIDEOPLAYER_H - -#include <QMediaPlayer> -#include <QMovie> -#include <QWidget> - -QT_BEGIN_NAMESPACE -class QAbstractButton; -class QSlider; -QT_END_NAMESPACE - -class VideoItem; - -class VideoPlayer : public QWidget -{ - Q_OBJECT - -public: - VideoPlayer(QWidget *parent = 0); - ~VideoPlayer(); - - QSize sizeHint() const override { return QSize(800, 600); } - -public slots: - void openFile(); - void play(); - -private slots: - void mediaStateChanged(QMediaPlayer::State state); - void positionChanged(qint64 position); - void durationChanged(qint64 duration); - void setPosition(int position); - void rotateVideo(int angle); - -private: - QMediaPlayer mediaPlayer; - VideoItem *videoItem; - QAbstractButton *playButton; - QSlider *positionSlider; -}; - -#endif // VIDEOPLAYER_H - |