Source code

Revision control

Copy as Markdown

// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef VIDEOPLAYER_H
#define VIDEOPLAYER_H
#include <QMediaPlayer>
#include <QWidget>
QT_BEGIN_NAMESPACE
class QAbstractButton;
class QSlider;
class QLabel;
class QUrl;
QT_END_NAMESPACE
class VideoPlayer : public QWidget
{
Q_OBJECT
public:
VideoPlayer(QWidget *parent = nullptr);
~VideoPlayer();
void setUrl(const QUrl &url);
public slots:
void openFile();
void play();
private slots:
void mediaStateChanged(QMediaPlayer::PlaybackState state);
void positionChanged(qint64 position);
void durationChanged(qint64 duration);
void setPosition(int position);
void handleError();
private:
QMediaPlayer *m_mediaPlayer;
QAbstractButton *m_playButton;
QSlider *m_positionSlider;
QLabel *m_errorLabel;
};
#endif