Jellyfin Qt
QML Library for interacting with the Jellyfin multimedia server
Toggle main menu visibility
Loading...
Searching...
No Matches
player.h
Go to the documentation of this file.
1
/*
2
* Sailfin: a Jellyfin client written using Qt
3
* Copyright (C) 2021-2022 Chris Josten and the Sailfin Contributors.
4
*
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Lesser General Public
7
* License as published by the Free Software Foundation; either
8
* version 2.1 of the License, or (at your option) any later version.
9
*
10
* This library is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* Lesser General Public License for more details.
14
*
15
* You should have received a copy of the GNU Lesser General Public
16
* License along with this library; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
*/
19
20
#ifndef JELLYFIN_MODEL_PLAYER_H
21
#define JELLYFIN_MODEL_PLAYER_H
22
23
#include <QLoggingCategory>
24
#include <QObject>
25
#include <QUrl>
26
27
namespace
Jellyfin
{
28
namespace
Model
{
29
30
Q_DECLARE_LOGGING_CATEGORY
(player)
31
32
class PlayerStateClass {
33
Q_GADGET
34
public
:
35
enum
Value
{
36
Stopped
,
37
Playing
,
38
Paused
39
};
40
Q_ENUM
(
Value
);
41
private
:
42
PlayerStateClass() {}
43
};
44
45
class
MediaStatusClass {
46
Q_GADGET
47
public
:
48
enum
Value
{
49
NoMedia
,
50
Loading
,
51
Loaded
,
52
Stalled
,
53
Buffering
,
54
Buffered
,
55
EndOfMedia
,
56
Error
57
};
58
Q_ENUM
(
Value
);
59
private
:
60
MediaStatusClass() {}
61
};
62
63
using
PlayerState
=
PlayerStateClass::Value
;
64
using
MediaStatus
=
MediaStatusClass::Value
;
65
69
class
Player
:
public
QObject {
70
Q_OBJECT
71
Q_PROPERTY(
Jellyfin::Model::PlayerStateClass::Value
state
READ
state
NOTIFY
stateChanged
)
72
Q_PROPERTY(
Jellyfin
::
Model
::
MediaStatusClass
::Value
mediaStatus
READ
mediaStatus
NOTIFY
mediaStatusChanged
)
73
Q_PROPERTY(qint64
position
READ
position
NOTIFY
positionChanged
)
74
Q_PROPERTY(qint64
duration
READ
duration
NOTIFY
durationChanged
)
75
Q_PROPERTY(
bool
seekable
READ
seekable
NOTIFY
seekableChanged
)
76
Q_PROPERTY(
bool
hasAudio
READ
hasAudio
NOTIFY
hasAudioChanged
)
77
Q_PROPERTY(
bool
hasVideo
READ
hasVideo
NOTIFY
hasVideoChanged
)
78
Q_PROPERTY(QString
errorString
READ
errorString
NOTIFY
errorStringChanged
)
79
// Used in QML by the VideoOutput
80
Q_PROPERTY(QObject*
videoOutputSource
READ
videoOutputSource
NOTIFY
videoOutputSourceChanged
);
81
public:
82
public:
83
~
Player
();
84
virtual
PlayerState
state
() const = 0;
85
virtual
MediaStatus
mediaStatus
() const = 0;
86
virtual qint64
position
() const = 0;
87
virtual qint64
duration
() const = 0;
88
virtual
bool
seekable
() const = 0;
89
virtual
bool
hasVideo
() const = 0;
90
virtual
bool
hasAudio
() const = 0;
91
virtual QString
errorString
() const = 0;
92
virtual QObject *
videoOutputSource
() const = 0;
93
public slots:
94
virtual
void
pause
() = 0;
95
virtual
void
play
(qint64 startPos = 0) = 0;
96
virtual
void
stop
() = 0;
97
virtual
void
seek
(qint64
position
) = 0;
98
virtual
void
setMedia
(const QUrl &url,
int
audioIndex = -1,
int
subTitleIndex = -1) = 0;
99
100
signals:
101
void
stateChanged
(
Jellyfin
::
Model
::
PlayerStateClass
::Value newState);
102
void
mediaStatusChanged
(
Jellyfin
::
Model
::
MediaStatusClass
::Value newMediaStatus);
103
void
positionChanged
(qint64 newPosition);
104
void
durationChanged
(qint64 newDuration);
105
void
errorStringChanged
();
109
void
seeked
();
110
void
seekableChanged
(
bool
seekable
);
111
void
hasAudioChanged
();
112
void
hasVideoChanged
();
113
void
aboutToFinish
();
114
void
videoOutputSourceChanged
();
115
};
116
117
#define USE_QTMULTIMEDIA_PLAYER
118
#ifdef USE_QTMULTIMEDIA_PLAYER
119
class
QtMultimediaPlayerPrivate;
123
class
QtMultimediaPlayer
:
public
Player
{
124
Q_OBJECT
125
Q_DECLARE_PRIVATE(
QtMultimediaPlayer
);
126
public
:
127
explicit
QtMultimediaPlayer
(QObject *parent =
nullptr
);
128
virtual
~QtMultimediaPlayer
();
129
PlayerState
state
()
const override
;
130
MediaStatus
mediaStatus
()
const override
;
131
qint64
position
()
const override
;
132
qint64
duration
()
const override
;
133
bool
seekable
()
const override
;
134
bool
hasVideo
()
const override
;
135
bool
hasAudio
()
const override
;
136
QString
errorString
()
const override
;
137
QObject *
videoOutputSource
()
const override
;
138
public
slots:
139
void
pause
()
override
;
140
void
play
(qint64 startPos = 0)
override
;
141
void
stop
()
override
;
142
void
seek
(qint64
position
)
override
;
143
void
setMedia
(
const
QUrl &url,
int
audioIndex,
int
subtitleIndex)
override
;
144
private
:
145
QScopedPointer<QtMultimediaPlayerPrivate> d_ptr;
146
};
147
#endif
// ifdef USE_QTMULTIMEDIA_PLAYER
148
149
}
// NS Model
150
}
// NS Jellyfin
151
152
#endif
// JELLYFIN_MODEL_PLAYER_H
Jellyfin::Model::MediaStatusClass
Definition
player.h:45
Jellyfin::Model::MediaStatusClass::Value
Value
Definition
player.h:48
Jellyfin::Model::MediaStatusClass::NoMedia
@ NoMedia
Definition
player.h:49
Jellyfin::Model::MediaStatusClass::Buffered
@ Buffered
Definition
player.h:54
Jellyfin::Model::MediaStatusClass::Loaded
@ Loaded
Definition
player.h:51
Jellyfin::Model::MediaStatusClass::Error
@ Error
Definition
player.h:56
Jellyfin::Model::MediaStatusClass::Stalled
@ Stalled
Definition
player.h:52
Jellyfin::Model::MediaStatusClass::Buffering
@ Buffering
Definition
player.h:53
Jellyfin::Model::MediaStatusClass::Loading
@ Loading
Definition
player.h:50
Jellyfin::Model::MediaStatusClass::EndOfMedia
@ EndOfMedia
Definition
player.h:55
Jellyfin::Model::MediaStatusClass::Q_ENUM
Q_ENUM(Value)
Jellyfin::Model::PlayerStateClass
Definition
player.h:32
Jellyfin::Model::PlayerStateClass::Q_ENUM
Q_ENUM(Value)
Jellyfin::Model::PlayerStateClass::Value
Value
Definition
player.h:35
Jellyfin::Model::PlayerStateClass::Playing
@ Playing
Definition
player.h:37
Jellyfin::Model::PlayerStateClass::Stopped
@ Stopped
Definition
player.h:36
Jellyfin::Model::PlayerStateClass::Paused
@ Paused
Definition
player.h:38
Jellyfin::Model::Player
Abstract class for a player.
Definition
player.h:69
Jellyfin::Model::Player::state
Jellyfin::Model::PlayerStateClass::Value state
Definition
player.h:71
Jellyfin::Model::Player::seek
virtual void seek(qint64 position)=0
Jellyfin::Model::Player::hasVideo
bool hasVideo
Definition
player.h:77
Jellyfin::Model::Player::setMedia
virtual void setMedia(const QUrl &url, int audioIndex=-1, int subTitleIndex=-1)=0
Jellyfin::Model::Player::position
qint64 position
Definition
player.h:73
Jellyfin::Model::Player::errorStringChanged
void errorStringChanged()
Jellyfin::Model::Player::duration
qint64 duration
Definition
player.h:74
Jellyfin::Model::Player::mediaStatusChanged
void mediaStatusChanged(Jellyfin::Model::MediaStatusClass::Value newMediaStatus)
Jellyfin::Model::Player::durationChanged
void durationChanged(qint64 newDuration)
Jellyfin::Model::Player::seeked
void seeked()
Sent when the position changed due to calling the seek method.
Jellyfin::Model::Player::hasVideoChanged
void hasVideoChanged()
Jellyfin::Model::Player::videoOutputSource
QObject * videoOutputSource
Definition
player.h:80
Jellyfin::Model::Player::stateChanged
void stateChanged(Jellyfin::Model::PlayerStateClass::Value newState)
Jellyfin::Model::Player::hasAudioChanged
void hasAudioChanged()
Jellyfin::Model::Player::seekable
bool seekable
Definition
player.h:75
Jellyfin::Model::Player::videoOutputSourceChanged
void videoOutputSourceChanged()
Jellyfin::Model::Player::pause
virtual void pause()=0
Jellyfin::Model::Player::play
virtual void play(qint64 startPos=0)=0
Jellyfin::Model::Player::stop
virtual void stop()=0
Jellyfin::Model::Player::positionChanged
void positionChanged(qint64 newPosition)
Jellyfin::Model::Player::hasAudio
bool hasAudio
Definition
player.h:76
Jellyfin::Model::Player::mediaStatus
Jellyfin::Model::MediaStatusClass::Value mediaStatus
Definition
player.h:72
Jellyfin::Model::Player::errorString
QString errorString
Definition
player.h:78
Jellyfin::Model::Player::seekableChanged
void seekableChanged(bool seekable)
Jellyfin::Model::Player::aboutToFinish
void aboutToFinish()
Jellyfin::Model::QtMultimediaPlayer::mediaStatus
MediaStatus mediaStatus() const override
Jellyfin::Model::QtMultimediaPlayer::~QtMultimediaPlayer
virtual ~QtMultimediaPlayer()
Jellyfin::Model::QtMultimediaPlayer::position
qint64 position() const override
Jellyfin::Model::QtMultimediaPlayer::videoOutputSource
QObject * videoOutputSource() const override
Jellyfin::Model::QtMultimediaPlayer::seekable
bool seekable() const override
Jellyfin::Model::QtMultimediaPlayer::hasVideo
bool hasVideo() const override
Jellyfin::Model::QtMultimediaPlayer::errorString
QString errorString() const override
Jellyfin::Model::QtMultimediaPlayer::stop
void stop() override
Jellyfin::Model::QtMultimediaPlayer::play
void play(qint64 startPos=0) override
Jellyfin::Model::QtMultimediaPlayer::duration
qint64 duration() const override
Jellyfin::Model::QtMultimediaPlayer::setMedia
void setMedia(const QUrl &url, int audioIndex, int subtitleIndex) override
Jellyfin::Model::QtMultimediaPlayer::QtMultimediaPlayer
QtMultimediaPlayer(QObject *parent=nullptr)
Jellyfin::Model::QtMultimediaPlayer::seek
void seek(qint64 position) override
Jellyfin::Model::QtMultimediaPlayer::state
PlayerState state() const override
Jellyfin::Model::QtMultimediaPlayer::hasAudio
bool hasAudio() const override
Jellyfin::Model::QtMultimediaPlayer::pause
void pause() override
Jellyfin::Model
Definition
controllablesession.h:18
Jellyfin::Model::PlayerState
PlayerStateClass::Value PlayerState
Definition
player.h:63
Jellyfin::Model::MediaStatus
MediaStatusClass::Value MediaStatus
Definition
player.h:64
Jellyfin::Model::Q_DECLARE_LOGGING_CATEGORY
Q_DECLARE_LOGGING_CATEGORY(playbackManager)
Jellyfin
core
include
JellyfinQt
model
player.h
Generated by
1.17.0