Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquickmediaplayer_p.h
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QQUICKMEDIAPLAYER_H
5#define QQUICKMEDIAPLAYER_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists for the convenience
12// of other Qt classes. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QMediaPlayer>
19#include <QtQml/qqml.h>
20#include <qtmultimediaquickexports.h>
21#include <qurl.h>
22#include <private/qglobal_p.h>
23
25
26class Q_MULTIMEDIAQUICK_EXPORT QQuickMediaPlayer : public QMediaPlayer
27{
29 Q_PROPERTY(QUrl source READ qmlSource WRITE qmlSetSource NOTIFY qmlSourceChanged FINAL)
30
31 // qml doesn't support qint64, so we have to convert to the supported type.
32 // Int is expected to be enough for actual purposes.
33 Q_PROPERTY(int duration READ qmlDuration NOTIFY qmlDurationChanged FINAL)
34 Q_PROPERTY(int position READ qmlPosition WRITE setQmlPosition NOTIFY qmlPositionChanged FINAL)
35 Q_PROPERTY(bool autoPlay READ autoPlay WRITE setAutoPlay NOTIFY autoPlayChanged FINAL)
36
37 QML_NAMED_ELEMENT(MediaPlayer)
38
39public:
40 QQuickMediaPlayer(QObject *parent = nullptr);
41
42 void qmlSetSource(const QUrl &source);
43
44 QUrl qmlSource() const;
45
46 void setQmlPosition(int position);
47
48 int qmlPosition() const;
49
50 int qmlDuration() const;
51
52 bool autoPlay() const;
53
54 void setAutoPlay(bool autoPlay);
55
57 void onPositionChanged(qint64 position);
58 void onDurationChanged(qint64 position);
59 void onMediaStatusChanged(QMediaPlayer::MediaStatus status);
60
62 void qmlSourceChanged(const QUrl &source);
63 void qmlPositionChanged(int position);
64 void qmlDurationChanged(int duration);
65 void autoPlayChanged(bool autoPlay);
66
68 QUrl m_source;
69 bool m_autoPlay = false;
70 bool m_wasMediaLoaded = false;
71};
72
74
75#endif
The QMediaPlayer class allows the playing of a media files.
MediaStatus
\qmlproperty enumeration QtMultimedia::MediaPlayer::playbackState
\inmodule QtCore
Definition qobject.h:103
\inmodule QtCore
Definition qurl.h:94
Combined button and popup list for selecting options.
GLsizei GLsizei GLchar * source
#define QML_NAMED_ELEMENT(NAME)
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_SIGNALS
long long qint64
Definition qtypes.h:60