Jellyfin Qt
QML Library for interacting with the Jellyfin multimedia server
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
27namespace Jellyfin {
28namespace Model {
29
31
33 Q_GADGET
34public:
35 enum Value {
38 Paused
39 };
41private:
43};
44
62
65
69class Player : public QObject {
70 Q_OBJECT
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
81public:
82public:
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;
93public 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
100signals:
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);
109 void seeked();
115};
116
117#define USE_QTMULTIMEDIA_PLAYER
118#ifdef USE_QTMULTIMEDIA_PLAYER
119class QtMultimediaPlayerPrivate;
124 Q_OBJECT
125 Q_DECLARE_PRIVATE(QtMultimediaPlayer);
126public:
127 explicit QtMultimediaPlayer(QObject *parent = nullptr);
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;
138public 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;
144private:
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
Definition player.h:45
Value
Definition player.h:48
@ NoMedia
Definition player.h:49
@ Buffered
Definition player.h:54
@ Loaded
Definition player.h:51
@ Error
Definition player.h:56
@ Stalled
Definition player.h:52
@ Buffering
Definition player.h:53
@ Loading
Definition player.h:50
@ EndOfMedia
Definition player.h:55
Definition player.h:32
Value
Definition player.h:35
@ Playing
Definition player.h:37
@ Stopped
Definition player.h:36
Abstract class for a player.
Definition player.h:69
Jellyfin::Model::PlayerStateClass::Value state
Definition player.h:71
virtual void seek(qint64 position)=0
bool hasVideo
Definition player.h:77
virtual void setMedia(const QUrl &url, int audioIndex=-1, int subTitleIndex=-1)=0
qint64 position
Definition player.h:73
qint64 duration
Definition player.h:74
void mediaStatusChanged(Jellyfin::Model::MediaStatusClass::Value newMediaStatus)
void durationChanged(qint64 newDuration)
void seeked()
Sent when the position changed due to calling the seek method.
QObject * videoOutputSource
Definition player.h:80
void stateChanged(Jellyfin::Model::PlayerStateClass::Value newState)
bool seekable
Definition player.h:75
virtual void pause()=0
virtual void play(qint64 startPos=0)=0
virtual void stop()=0
void positionChanged(qint64 newPosition)
bool hasAudio
Definition player.h:76
Jellyfin::Model::MediaStatusClass::Value mediaStatus
Definition player.h:72
QString errorString
Definition player.h:78
void seekableChanged(bool seekable)
Player implementation that uses QtMultimedia.
Definition player.h:123
MediaStatus mediaStatus() const override
qint64 position() const override
QObject * videoOutputSource() const override
bool seekable() const override
bool hasVideo() const override
QString errorString() const override
void play(qint64 startPos=0) override
qint64 duration() const override
void setMedia(const QUrl &url, int audioIndex, int subtitleIndex) override
QtMultimediaPlayer(QObject *parent=nullptr)
void seek(qint64 position) override
PlayerState state() const override
bool hasAudio() const override
Q_DECLARE_LOGGING_CATEGORY(playbackManager)