2020-09-27 18:38:33 +00:00
|
|
|
/*
|
2021-03-24 19:04:03 +00:00
|
|
|
* Sailfin: a Jellyfin client written using Qt
|
core: Split PlaybackManager up into smaller parts
The PlaybackManager was a giant class that handled UI bindings, fetching
stream URLS, playback logic.
It now has been split up into:
- ViewModel::PlaybackManager, which handles UI interfacing and allowing
to swap out the Model::Playback implementation on the fly.
- Model::PlaybackManager, which is an interface for what a
PlaybackManager must do, handling queues/playlists, and controlling a
player.
- Model::LocalPlaybackManager, which is an Model::PlaybackManager
implementation for playing back Jellyfin media within the application.
- Model::PlaybackReporter, which reports the current playback state to
the Jellyfin server, for keeping track of played items.
- Model::Player, which handles playing back media from an URL and
the usual play/pause et cetera.
In a future commit, this would allow for introducing a
Model::RemoteJellyfinPlaybackManager, to control other Jellyfin
instances.
2022-01-05 20:24:52 +00:00
|
|
|
* Copyright (C) 2021-2022 Chris Josten and the Sailfin Contributors.
|
2021-03-24 19:04:03 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
#ifndef JELLYFIN_VIEWMODEL_PLAYBACKMANAGER_H
|
|
|
|
#define JELLYFIN_VIEWMODEL_PLAYBACKMANAGER_H
|
2020-09-25 12:46:39 +00:00
|
|
|
|
2021-02-20 22:20:39 +00:00
|
|
|
#include <QAbstractItemModel>
|
2022-12-28 20:20:04 +00:00
|
|
|
#include <QFuture>
|
2020-09-25 12:46:39 +00:00
|
|
|
#include <QJsonArray>
|
|
|
|
#include <QJsonObject>
|
2021-09-09 23:36:30 +00:00
|
|
|
#include <QLoggingCategory>
|
2020-09-25 12:46:39 +00:00
|
|
|
#include <QObject>
|
2022-12-28 20:20:04 +00:00
|
|
|
#include <QSharedPointer>
|
2021-02-13 23:21:49 +00:00
|
|
|
#include <QtGlobal>
|
2020-09-25 12:46:39 +00:00
|
|
|
#include <QUrlQuery>
|
2021-02-20 22:20:39 +00:00
|
|
|
#include <QVariant>
|
2020-09-25 12:46:39 +00:00
|
|
|
|
|
|
|
#include <QtMultimedia/QMediaPlayer>
|
2021-02-20 22:20:39 +00:00
|
|
|
#include <QtMultimedia/QMediaPlaylist>
|
|
|
|
|
|
|
|
#include <functional>
|
2020-09-25 12:46:39 +00:00
|
|
|
|
2022-12-28 20:20:04 +00:00
|
|
|
#include <JellyfinQt/dto/baseitemdto.h>
|
|
|
|
#include <JellyfinQt/dto/playbackinfodto.h>
|
|
|
|
#include <JellyfinQt/dto/playbackinforesponse.h>
|
|
|
|
#include <JellyfinQt/dto/playmethod.h>
|
|
|
|
#include <JellyfinQt/loader/requesttypes.h>
|
|
|
|
#include <JellyfinQt/model/controllablesession.h>
|
|
|
|
#include <JellyfinQt/model/player.h>
|
|
|
|
#include <JellyfinQt/model/playlist.h>
|
|
|
|
#include <JellyfinQt/support/jsonconv.h>
|
|
|
|
#include <JellyfinQt/viewmodel/item.h>
|
|
|
|
#include <JellyfinQt/viewmodel/playlist.h>
|
|
|
|
#include <JellyfinQt/apiclient.h>
|
2021-03-26 20:27:35 +00:00
|
|
|
#include "itemmodel.h"
|
2020-09-25 12:46:39 +00:00
|
|
|
|
2021-02-20 22:20:39 +00:00
|
|
|
|
2020-09-25 12:46:39 +00:00
|
|
|
namespace Jellyfin {
|
|
|
|
|
2021-02-13 23:21:49 +00:00
|
|
|
// Forward declaration of Jellyfin::ApiClient found in jellyfinapiclient.h
|
|
|
|
class ApiClient;
|
2021-02-20 22:20:39 +00:00
|
|
|
class ItemModel;
|
2021-09-09 23:36:30 +00:00
|
|
|
|
|
|
|
namespace DTO {
|
|
|
|
class PlaystateRequest;
|
|
|
|
}
|
2021-02-21 04:02:05 +00:00
|
|
|
|
2021-03-24 19:04:03 +00:00
|
|
|
namespace ViewModel {
|
2021-09-09 23:36:30 +00:00
|
|
|
Q_DECLARE_LOGGING_CATEGORY(playbackManager);
|
2021-02-13 23:21:49 +00:00
|
|
|
|
core: Split PlaybackManager up into smaller parts
The PlaybackManager was a giant class that handled UI bindings, fetching
stream URLS, playback logic.
It now has been split up into:
- ViewModel::PlaybackManager, which handles UI interfacing and allowing
to swap out the Model::Playback implementation on the fly.
- Model::PlaybackManager, which is an interface for what a
PlaybackManager must do, handling queues/playlists, and controlling a
player.
- Model::LocalPlaybackManager, which is an Model::PlaybackManager
implementation for playing back Jellyfin media within the application.
- Model::PlaybackReporter, which reports the current playback state to
the Jellyfin server, for keeping track of played items.
- Model::Player, which handles playing back media from an URL and
the usual play/pause et cetera.
In a future commit, this would allow for introducing a
Model::RemoteJellyfinPlaybackManager, to control other Jellyfin
instances.
2022-01-05 20:24:52 +00:00
|
|
|
class PlaybackManagerPrivate;
|
2021-07-31 13:06:17 +00:00
|
|
|
|
2021-02-13 23:21:49 +00:00
|
|
|
/**
|
core: Split PlaybackManager up into smaller parts
The PlaybackManager was a giant class that handled UI bindings, fetching
stream URLS, playback logic.
It now has been split up into:
- ViewModel::PlaybackManager, which handles UI interfacing and allowing
to swap out the Model::Playback implementation on the fly.
- Model::PlaybackManager, which is an interface for what a
PlaybackManager must do, handling queues/playlists, and controlling a
player.
- Model::LocalPlaybackManager, which is an Model::PlaybackManager
implementation for playing back Jellyfin media within the application.
- Model::PlaybackReporter, which reports the current playback state to
the Jellyfin server, for keeping track of played items.
- Model::Player, which handles playing back media from an URL and
the usual play/pause et cetera.
In a future commit, this would allow for introducing a
Model::RemoteJellyfinPlaybackManager, to control other Jellyfin
instances.
2022-01-05 20:24:52 +00:00
|
|
|
* @brief The PlaybackManager class manages the playback of Jellyfin items.
|
2021-02-20 22:20:39 +00:00
|
|
|
*
|
core: Split PlaybackManager up into smaller parts
The PlaybackManager was a giant class that handled UI bindings, fetching
stream URLS, playback logic.
It now has been split up into:
- ViewModel::PlaybackManager, which handles UI interfacing and allowing
to swap out the Model::Playback implementation on the fly.
- Model::PlaybackManager, which is an interface for what a
PlaybackManager must do, handling queues/playlists, and controlling a
player.
- Model::LocalPlaybackManager, which is an Model::PlaybackManager
implementation for playing back Jellyfin media within the application.
- Model::PlaybackReporter, which reports the current playback state to
the Jellyfin server, for keeping track of played items.
- Model::Player, which handles playing back media from an URL and
the usual play/pause et cetera.
In a future commit, this would allow for introducing a
Model::RemoteJellyfinPlaybackManager, to control other Jellyfin
instances.
2022-01-05 20:24:52 +00:00
|
|
|
* It is a small wrapper around an instance of Jellyfin::Model::PlaybackManager,
|
|
|
|
* which do the actual work. The Jellyfin::Model::PlaybackManager can be switched
|
|
|
|
* on the fly, allowing this class to switch between controlling the playback locally
|
|
|
|
* or remote.
|
2021-02-13 23:21:49 +00:00
|
|
|
*/
|
|
|
|
class PlaybackManager : public QObject, public QQmlParserStatus {
|
2020-09-25 12:46:39 +00:00
|
|
|
Q_OBJECT
|
core: Split PlaybackManager up into smaller parts
The PlaybackManager was a giant class that handled UI bindings, fetching
stream URLS, playback logic.
It now has been split up into:
- ViewModel::PlaybackManager, which handles UI interfacing and allowing
to swap out the Model::Playback implementation on the fly.
- Model::PlaybackManager, which is an interface for what a
PlaybackManager must do, handling queues/playlists, and controlling a
player.
- Model::LocalPlaybackManager, which is an Model::PlaybackManager
implementation for playing back Jellyfin media within the application.
- Model::PlaybackReporter, which reports the current playback state to
the Jellyfin server, for keeping track of played items.
- Model::Player, which handles playing back media from an URL and
the usual play/pause et cetera.
In a future commit, this would allow for introducing a
Model::RemoteJellyfinPlaybackManager, to control other Jellyfin
instances.
2022-01-05 20:24:52 +00:00
|
|
|
Q_DECLARE_PRIVATE(PlaybackManager);
|
2021-02-13 23:21:49 +00:00
|
|
|
Q_INTERFACES(QQmlParserStatus)
|
2020-09-25 12:46:39 +00:00
|
|
|
public:
|
2020-10-01 19:45:34 +00:00
|
|
|
|
2020-10-08 01:00:08 +00:00
|
|
|
explicit PlaybackManager(QObject *parent = nullptr);
|
core: Split PlaybackManager up into smaller parts
The PlaybackManager was a giant class that handled UI bindings, fetching
stream URLS, playback logic.
It now has been split up into:
- ViewModel::PlaybackManager, which handles UI interfacing and allowing
to swap out the Model::Playback implementation on the fly.
- Model::PlaybackManager, which is an interface for what a
PlaybackManager must do, handling queues/playlists, and controlling a
player.
- Model::LocalPlaybackManager, which is an Model::PlaybackManager
implementation for playing back Jellyfin media within the application.
- Model::PlaybackReporter, which reports the current playback state to
the Jellyfin server, for keeping track of played items.
- Model::Player, which handles playing back media from an URL and
the usual play/pause et cetera.
In a future commit, this would allow for introducing a
Model::RemoteJellyfinPlaybackManager, to control other Jellyfin
instances.
2022-01-05 20:24:52 +00:00
|
|
|
virtual ~PlaybackManager();
|
2021-02-20 22:20:39 +00:00
|
|
|
|
core: Split PlaybackManager up into smaller parts
The PlaybackManager was a giant class that handled UI bindings, fetching
stream URLS, playback logic.
It now has been split up into:
- ViewModel::PlaybackManager, which handles UI interfacing and allowing
to swap out the Model::Playback implementation on the fly.
- Model::PlaybackManager, which is an interface for what a
PlaybackManager must do, handling queues/playlists, and controlling a
player.
- Model::LocalPlaybackManager, which is an Model::PlaybackManager
implementation for playing back Jellyfin media within the application.
- Model::PlaybackReporter, which reports the current playback state to
the Jellyfin server, for keeping track of played items.
- Model::Player, which handles playing back media from an URL and
the usual play/pause et cetera.
In a future commit, this would allow for introducing a
Model::RemoteJellyfinPlaybackManager, to control other Jellyfin
instances.
2022-01-05 20:24:52 +00:00
|
|
|
Q_PROPERTY(ApiClient *apiClient READ apiClient WRITE setApiClient)
|
2022-12-28 20:20:04 +00:00
|
|
|
Q_PROPERTY(QString controllingSessionId READ controllingSessionId NOTIFY controllingSessionIdChanged)
|
|
|
|
Q_PROPERTY(QString controllingSessionName READ controllingSessionName NOTIFY controllingSessionNameChanged)
|
|
|
|
/**
|
|
|
|
* Whether the playback is done by this client
|
|
|
|
*/
|
|
|
|
Q_PROPERTY(bool controllingSessionLocal READ controllingSessionLocal NOTIFY controllingSessionLocalChanged)
|
|
|
|
|
core: Split PlaybackManager up into smaller parts
The PlaybackManager was a giant class that handled UI bindings, fetching
stream URLS, playback logic.
It now has been split up into:
- ViewModel::PlaybackManager, which handles UI interfacing and allowing
to swap out the Model::Playback implementation on the fly.
- Model::PlaybackManager, which is an interface for what a
PlaybackManager must do, handling queues/playlists, and controlling a
player.
- Model::LocalPlaybackManager, which is an Model::PlaybackManager
implementation for playing back Jellyfin media within the application.
- Model::PlaybackReporter, which reports the current playback state to
the Jellyfin server, for keeping track of played items.
- Model::Player, which handles playing back media from an URL and
the usual play/pause et cetera.
In a future commit, this would allow for introducing a
Model::RemoteJellyfinPlaybackManager, to control other Jellyfin
instances.
2022-01-05 20:24:52 +00:00
|
|
|
Q_PROPERTY(int audioIndex READ audioIndex WRITE setAudioIndex NOTIFY audioIndexChanged)
|
|
|
|
Q_PROPERTY(int subtitleIndex READ subtitleIndex WRITE setSubtitleIndex NOTIFY subtitleIndexChanged)
|
2020-09-25 12:46:39 +00:00
|
|
|
Q_PROPERTY(QString streamUrl READ streamUrl NOTIFY streamUrlChanged)
|
core: Split PlaybackManager up into smaller parts
The PlaybackManager was a giant class that handled UI bindings, fetching
stream URLS, playback logic.
It now has been split up into:
- ViewModel::PlaybackManager, which handles UI interfacing and allowing
to swap out the Model::Playback implementation on the fly.
- Model::PlaybackManager, which is an interface for what a
PlaybackManager must do, handling queues/playlists, and controlling a
player.
- Model::LocalPlaybackManager, which is an Model::PlaybackManager
implementation for playing back Jellyfin media within the application.
- Model::PlaybackReporter, which reports the current playback state to
the Jellyfin server, for keeping track of played items.
- Model::Player, which handles playing back media from an URL and
the usual play/pause et cetera.
In a future commit, this would allow for introducing a
Model::RemoteJellyfinPlaybackManager, to control other Jellyfin
instances.
2022-01-05 20:24:52 +00:00
|
|
|
//Q_PROPERTY(bool autoOpen MEMBER m_autoOpen NOTIFY autoOpenChanged)
|
|
|
|
/**
|
|
|
|
* Whether the player should resume playback.
|
|
|
|
*/
|
|
|
|
Q_PROPERTY(bool resumePlayback READ resumePlayback WRITE setResumePlayback NOTIFY resumePlaybackChanged)
|
2021-07-31 13:06:17 +00:00
|
|
|
Q_PROPERTY(Jellyfin::DTO::PlayMethodClass::Value playMethod READ playMethod NOTIFY playMethodChanged)
|
2020-09-25 12:46:39 +00:00
|
|
|
|
2022-12-28 20:20:04 +00:00
|
|
|
// Current Item and queue information
|
2021-07-31 13:06:17 +00:00
|
|
|
Q_PROPERTY(QObject *item READ item NOTIFY itemChanged)
|
2021-02-20 22:20:39 +00:00
|
|
|
Q_PROPERTY(int queueIndex READ queueIndex NOTIFY queueIndexChanged)
|
2021-08-21 20:01:13 +00:00
|
|
|
Q_PROPERTY(Jellyfin::ViewModel::Playlist *queue READ queue NOTIFY queueChanged)
|
2021-02-20 22:20:39 +00:00
|
|
|
|
|
|
|
// Current media player related property getters
|
|
|
|
Q_PROPERTY(qint64 duration READ duration NOTIFY durationChanged)
|
|
|
|
Q_PROPERTY(QMediaPlayer::Error error READ error NOTIFY errorChanged)
|
|
|
|
Q_PROPERTY(QString errorString READ errorString NOTIFY errorStringChanged)
|
|
|
|
Q_PROPERTY(bool hasVideo READ hasVideo NOTIFY hasVideoChanged)
|
2021-08-11 21:35:33 +00:00
|
|
|
Q_PROPERTY(bool seekable READ seekable NOTIFY seekableChanged)
|
core: Split PlaybackManager up into smaller parts
The PlaybackManager was a giant class that handled UI bindings, fetching
stream URLS, playback logic.
It now has been split up into:
- ViewModel::PlaybackManager, which handles UI interfacing and allowing
to swap out the Model::Playback implementation on the fly.
- Model::PlaybackManager, which is an interface for what a
PlaybackManager must do, handling queues/playlists, and controlling a
player.
- Model::LocalPlaybackManager, which is an Model::PlaybackManager
implementation for playing back Jellyfin media within the application.
- Model::PlaybackReporter, which reports the current playback state to
the Jellyfin server, for keeping track of played items.
- Model::Player, which handles playing back media from an URL and
the usual play/pause et cetera.
In a future commit, this would allow for introducing a
Model::RemoteJellyfinPlaybackManager, to control other Jellyfin
instances.
2022-01-05 20:24:52 +00:00
|
|
|
Q_PROPERTY(QObject* mediaObject READ mediaObject NOTIFY mediaObjectChanged);
|
|
|
|
Q_PROPERTY(Jellyfin::Model::MediaStatusClass::Value mediaStatus READ mediaStatus NOTIFY mediaStatusChanged)
|
|
|
|
Q_PROPERTY(Jellyfin::Model::PlayerStateClass::Value playbackState READ playbackState NOTIFY playbackStateChanged)
|
2021-02-20 22:20:39 +00:00
|
|
|
Q_PROPERTY(qint64 position READ position NOTIFY positionChanged)
|
2021-08-30 23:29:51 +00:00
|
|
|
Q_PROPERTY(bool hasNext READ hasNext NOTIFY hasNextChanged)
|
|
|
|
Q_PROPERTY(bool hasPrevious READ hasPrevious NOTIFY hasPreviousChanged)
|
2021-09-09 23:36:30 +00:00
|
|
|
/// Whether playstate commands received over the websocket should be handled
|
|
|
|
Q_PROPERTY(bool handlePlaystateCommands READ handlePlaystateCommands WRITE setHandlePlaystateCommands NOTIFY handlePlaystateCommandsChanged)
|
2020-10-01 19:45:34 +00:00
|
|
|
|
core: Split PlaybackManager up into smaller parts
The PlaybackManager was a giant class that handled UI bindings, fetching
stream URLS, playback logic.
It now has been split up into:
- ViewModel::PlaybackManager, which handles UI interfacing and allowing
to swap out the Model::Playback implementation on the fly.
- Model::PlaybackManager, which is an interface for what a
PlaybackManager must do, handling queues/playlists, and controlling a
player.
- Model::LocalPlaybackManager, which is an Model::PlaybackManager
implementation for playing back Jellyfin media within the application.
- Model::PlaybackReporter, which reports the current playback state to
the Jellyfin server, for keeping track of played items.
- Model::Player, which handles playing back media from an URL and
the usual play/pause et cetera.
In a future commit, this would allow for introducing a
Model::RemoteJellyfinPlaybackManager, to control other Jellyfin
instances.
2022-01-05 20:24:52 +00:00
|
|
|
// R/W props
|
|
|
|
ApiClient *apiClient() const;
|
2021-02-21 04:02:05 +00:00
|
|
|
void setApiClient(ApiClient *apiClient);
|
core: Split PlaybackManager up into smaller parts
The PlaybackManager was a giant class that handled UI bindings, fetching
stream URLS, playback logic.
It now has been split up into:
- ViewModel::PlaybackManager, which handles UI interfacing and allowing
to swap out the Model::Playback implementation on the fly.
- Model::PlaybackManager, which is an interface for what a
PlaybackManager must do, handling queues/playlists, and controlling a
player.
- Model::LocalPlaybackManager, which is an Model::PlaybackManager
implementation for playing back Jellyfin media within the application.
- Model::PlaybackReporter, which reports the current playback state to
the Jellyfin server, for keeping track of played items.
- Model::Player, which handles playing back media from an URL and
the usual play/pause et cetera.
In a future commit, this would allow for introducing a
Model::RemoteJellyfinPlaybackManager, to control other Jellyfin
instances.
2022-01-05 20:24:52 +00:00
|
|
|
bool resumePlayback() const;
|
|
|
|
void setResumePlayback(bool newResumePlayback);
|
|
|
|
int audioIndex() const;
|
|
|
|
void setAudioIndex(int newAudioIndex);
|
|
|
|
int subtitleIndex() const;
|
|
|
|
void setSubtitleIndex(int newAudioIndex);
|
|
|
|
|
|
|
|
ViewModel::Item *item() const;
|
|
|
|
QSharedPointer<Model::Item> dataItem() const;
|
|
|
|
|
2022-12-28 20:20:04 +00:00
|
|
|
QSharedPointer<Model::ControllableSession> controllingSession() const;
|
|
|
|
void setControllingSession(QSharedPointer<Model::ControllableSession> session);
|
|
|
|
QString controllingSessionId() const;
|
|
|
|
QString controllingSessionName() const;
|
|
|
|
bool controllingSessionLocal() const;
|
core: Split PlaybackManager up into smaller parts
The PlaybackManager was a giant class that handled UI bindings, fetching
stream URLS, playback logic.
It now has been split up into:
- ViewModel::PlaybackManager, which handles UI interfacing and allowing
to swap out the Model::Playback implementation on the fly.
- Model::PlaybackManager, which is an interface for what a
PlaybackManager must do, handling queues/playlists, and controlling a
player.
- Model::LocalPlaybackManager, which is an Model::PlaybackManager
implementation for playing back Jellyfin media within the application.
- Model::PlaybackReporter, which reports the current playback state to
the Jellyfin server, for keeping track of played items.
- Model::Player, which handles playing back media from an URL and
the usual play/pause et cetera.
In a future commit, this would allow for introducing a
Model::RemoteJellyfinPlaybackManager, to control other Jellyfin
instances.
2022-01-05 20:24:52 +00:00
|
|
|
QString streamUrl() const;
|
|
|
|
PlayMethod playMethod() const;
|
|
|
|
qint64 position() const;
|
|
|
|
qint64 duration() const;
|
|
|
|
ViewModel::Playlist *queue() const;
|
|
|
|
int queueIndex() const;
|
|
|
|
bool hasNext() const;
|
|
|
|
bool hasPrevious() const;
|
2021-02-20 22:20:39 +00:00
|
|
|
|
|
|
|
// Current media player related property getters
|
core: Split PlaybackManager up into smaller parts
The PlaybackManager was a giant class that handled UI bindings, fetching
stream URLS, playback logic.
It now has been split up into:
- ViewModel::PlaybackManager, which handles UI interfacing and allowing
to swap out the Model::Playback implementation on the fly.
- Model::PlaybackManager, which is an interface for what a
PlaybackManager must do, handling queues/playlists, and controlling a
player.
- Model::LocalPlaybackManager, which is an Model::PlaybackManager
implementation for playing back Jellyfin media within the application.
- Model::PlaybackReporter, which reports the current playback state to
the Jellyfin server, for keeping track of played items.
- Model::Player, which handles playing back media from an URL and
the usual play/pause et cetera.
In a future commit, this would allow for introducing a
Model::RemoteJellyfinPlaybackManager, to control other Jellyfin
instances.
2022-01-05 20:24:52 +00:00
|
|
|
QObject* mediaObject() const;
|
|
|
|
Model::PlayerState playbackState() const;
|
|
|
|
Model::MediaStatus mediaStatus() const;
|
|
|
|
bool hasVideo() const;
|
|
|
|
bool seekable() const;
|
2021-09-09 20:16:39 +00:00
|
|
|
QMediaPlayer::Error error () const;
|
|
|
|
QString errorString() const;
|
2021-09-09 23:36:30 +00:00
|
|
|
|
core: Split PlaybackManager up into smaller parts
The PlaybackManager was a giant class that handled UI bindings, fetching
stream URLS, playback logic.
It now has been split up into:
- ViewModel::PlaybackManager, which handles UI interfacing and allowing
to swap out the Model::Playback implementation on the fly.
- Model::PlaybackManager, which is an interface for what a
PlaybackManager must do, handling queues/playlists, and controlling a
player.
- Model::LocalPlaybackManager, which is an Model::PlaybackManager
implementation for playing back Jellyfin media within the application.
- Model::PlaybackReporter, which reports the current playback state to
the Jellyfin server, for keeping track of played items.
- Model::Player, which handles playing back media from an URL and
the usual play/pause et cetera.
In a future commit, this would allow for introducing a
Model::RemoteJellyfinPlaybackManager, to control other Jellyfin
instances.
2022-01-05 20:24:52 +00:00
|
|
|
bool handlePlaystateCommands() const;
|
|
|
|
void setHandlePlaystateCommands(bool newHandlePlaystateCommands);
|
2020-09-25 12:46:39 +00:00
|
|
|
signals:
|
core: Split PlaybackManager up into smaller parts
The PlaybackManager was a giant class that handled UI bindings, fetching
stream URLS, playback logic.
It now has been split up into:
- ViewModel::PlaybackManager, which handles UI interfacing and allowing
to swap out the Model::Playback implementation on the fly.
- Model::PlaybackManager, which is an interface for what a
PlaybackManager must do, handling queues/playlists, and controlling a
player.
- Model::LocalPlaybackManager, which is an Model::PlaybackManager
implementation for playing back Jellyfin media within the application.
- Model::PlaybackReporter, which reports the current playback state to
the Jellyfin server, for keeping track of played items.
- Model::Player, which handles playing back media from an URL and
the usual play/pause et cetera.
In a future commit, this would allow for introducing a
Model::RemoteJellyfinPlaybackManager, to control other Jellyfin
instances.
2022-01-05 20:24:52 +00:00
|
|
|
void itemChanged();
|
2022-12-28 20:20:04 +00:00
|
|
|
void controllingSessionChanged();
|
|
|
|
void controllingSessionIdChanged();
|
|
|
|
void controllingSessionNameChanged();
|
|
|
|
void controllingSessionLocalChanged();
|
2020-09-25 12:46:39 +00:00
|
|
|
void streamUrlChanged(const QString &newStreamUrl);
|
|
|
|
void autoOpenChanged(bool autoOpen);
|
2020-09-25 15:14:44 +00:00
|
|
|
void audioIndexChanged(int audioIndex);
|
|
|
|
void subtitleIndexChanged(int subtitleIndex);
|
2021-02-13 23:21:49 +00:00
|
|
|
void mediaPlayerChanged(QObject *newMediaPlayer);
|
|
|
|
void resumePlaybackChanged(bool newResumePlayback);
|
2021-02-14 12:29:30 +00:00
|
|
|
void playMethodChanged(PlayMethod newPlayMethod);
|
2020-09-25 12:46:39 +00:00
|
|
|
|
2021-09-09 23:36:30 +00:00
|
|
|
// Emitted when seek has been called.
|
|
|
|
void seeked(qint64 newPosition);
|
|
|
|
|
core: Split PlaybackManager up into smaller parts
The PlaybackManager was a giant class that handled UI bindings, fetching
stream URLS, playback logic.
It now has been split up into:
- ViewModel::PlaybackManager, which handles UI interfacing and allowing
to swap out the Model::Playback implementation on the fly.
- Model::PlaybackManager, which is an interface for what a
PlaybackManager must do, handling queues/playlists, and controlling a
player.
- Model::LocalPlaybackManager, which is an Model::PlaybackManager
implementation for playing back Jellyfin media within the application.
- Model::PlaybackReporter, which reports the current playback state to
the Jellyfin server, for keeping track of played items.
- Model::Player, which handles playing back media from an URL and
the usual play/pause et cetera.
In a future commit, this would allow for introducing a
Model::RemoteJellyfinPlaybackManager, to control other Jellyfin
instances.
2022-01-05 20:24:52 +00:00
|
|
|
void hasNextChanged(bool newHasNext);
|
|
|
|
void hasPreviousChanged(bool newHasPrevious);
|
|
|
|
|
2021-02-20 22:20:39 +00:00
|
|
|
// Current media player related property signals
|
core: Split PlaybackManager up into smaller parts
The PlaybackManager was a giant class that handled UI bindings, fetching
stream URLS, playback logic.
It now has been split up into:
- ViewModel::PlaybackManager, which handles UI interfacing and allowing
to swap out the Model::Playback implementation on the fly.
- Model::PlaybackManager, which is an interface for what a
PlaybackManager must do, handling queues/playlists, and controlling a
player.
- Model::LocalPlaybackManager, which is an Model::PlaybackManager
implementation for playing back Jellyfin media within the application.
- Model::PlaybackReporter, which reports the current playback state to
the Jellyfin server, for keeping track of played items.
- Model::Player, which handles playing back media from an URL and
the usual play/pause et cetera.
In a future commit, this would allow for introducing a
Model::RemoteJellyfinPlaybackManager, to control other Jellyfin
instances.
2022-01-05 20:24:52 +00:00
|
|
|
void mediaObjectChanged(QObject *newPlayer);
|
2021-02-20 22:20:39 +00:00
|
|
|
void positionChanged(qint64 newPosition);
|
|
|
|
void durationChanged(qint64 newDuration);
|
2021-08-21 20:01:13 +00:00
|
|
|
void queueChanged(QAbstractItemModel *newQueue);
|
2021-02-20 22:20:39 +00:00
|
|
|
void queueIndexChanged(int newIndex);
|
core: Split PlaybackManager up into smaller parts
The PlaybackManager was a giant class that handled UI bindings, fetching
stream URLS, playback logic.
It now has been split up into:
- ViewModel::PlaybackManager, which handles UI interfacing and allowing
to swap out the Model::Playback implementation on the fly.
- Model::PlaybackManager, which is an interface for what a
PlaybackManager must do, handling queues/playlists, and controlling a
player.
- Model::LocalPlaybackManager, which is an Model::PlaybackManager
implementation for playing back Jellyfin media within the application.
- Model::PlaybackReporter, which reports the current playback state to
the Jellyfin server, for keeping track of played items.
- Model::Player, which handles playing back media from an URL and
the usual play/pause et cetera.
In a future commit, this would allow for introducing a
Model::RemoteJellyfinPlaybackManager, to control other Jellyfin
instances.
2022-01-05 20:24:52 +00:00
|
|
|
void playbackStateChanged(Jellyfin::Model::PlayerStateClass::Value newState);
|
|
|
|
void mediaStatusChanged(Jellyfin::Model::MediaStatusClass::Value newMediaStatus);
|
2021-02-20 22:20:39 +00:00
|
|
|
void hasVideoChanged(bool newHasVideo);
|
2021-08-11 21:35:33 +00:00
|
|
|
void seekableChanged(bool newSeekable);
|
2021-02-20 22:20:39 +00:00
|
|
|
void errorChanged(QMediaPlayer::Error newError);
|
|
|
|
void errorStringChanged(const QString &newErrorString);
|
2021-09-09 23:36:30 +00:00
|
|
|
void handlePlaystateCommandsChanged(bool newHandlePlaystateCommands);
|
2020-09-25 12:46:39 +00:00
|
|
|
public slots:
|
2021-02-14 17:40:46 +00:00
|
|
|
/**
|
2021-09-09 20:16:39 +00:00
|
|
|
* @brief playItem Replaces the current queue and plays the given item.
|
2021-05-21 13:46:30 +00:00
|
|
|
*
|
|
|
|
* This will construct the Jellyfin::Item internally
|
2021-02-14 17:40:46 +00:00
|
|
|
* and delete it later.
|
2021-07-31 13:06:17 +00:00
|
|
|
* @param item The item to play.
|
2021-02-14 17:40:46 +00:00
|
|
|
*/
|
2021-07-31 13:06:17 +00:00
|
|
|
void playItem(Item *item);
|
2021-09-09 20:16:39 +00:00
|
|
|
|
|
|
|
void playItem(QSharedPointer<Model::Item> item);
|
|
|
|
/**
|
|
|
|
* @brief playItem Replaces the current queue and plays the item with the given id.
|
|
|
|
*
|
|
|
|
* This will construct the Jellyfin::Item internally
|
|
|
|
* and delete it later.
|
|
|
|
* @param item The itemId to play.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void playItemId(const QString &itemId);
|
2021-02-20 22:20:39 +00:00
|
|
|
void playItemInList(ItemModel *itemList, int index);
|
2021-08-21 20:33:23 +00:00
|
|
|
/**
|
|
|
|
* @brief skipToItemIndex Skips to an item in the current playlist
|
|
|
|
* @param index The index to skip to
|
|
|
|
*/
|
|
|
|
void skipToItemIndex(int index);
|
2021-09-09 20:16:39 +00:00
|
|
|
void play();
|
core: Split PlaybackManager up into smaller parts
The PlaybackManager was a giant class that handled UI bindings, fetching
stream URLS, playback logic.
It now has been split up into:
- ViewModel::PlaybackManager, which handles UI interfacing and allowing
to swap out the Model::Playback implementation on the fly.
- Model::PlaybackManager, which is an interface for what a
PlaybackManager must do, handling queues/playlists, and controlling a
player.
- Model::LocalPlaybackManager, which is an Model::PlaybackManager
implementation for playing back Jellyfin media within the application.
- Model::PlaybackReporter, which reports the current playback state to
the Jellyfin server, for keeping track of played items.
- Model::Player, which handles playing back media from an URL and
the usual play/pause et cetera.
In a future commit, this would allow for introducing a
Model::RemoteJellyfinPlaybackManager, to control other Jellyfin
instances.
2022-01-05 20:24:52 +00:00
|
|
|
void pause();
|
2021-09-09 20:16:39 +00:00
|
|
|
void seek(qint64 pos);
|
|
|
|
void stop();
|
2021-02-17 18:42:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief previous Play the previous track in the current playlist.
|
|
|
|
*/
|
|
|
|
void previous();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief next Play the next track in the current playlist.
|
|
|
|
*/
|
|
|
|
void next();
|
2021-02-20 22:20:39 +00:00
|
|
|
|
2021-09-09 23:36:30 +00:00
|
|
|
void handlePlaystateRequest(const DTO::PlaystateRequest &request);
|
|
|
|
|
2021-02-13 23:21:49 +00:00
|
|
|
private slots:
|
core: Split PlaybackManager up into smaller parts
The PlaybackManager was a giant class that handled UI bindings, fetching
stream URLS, playback logic.
It now has been split up into:
- ViewModel::PlaybackManager, which handles UI interfacing and allowing
to swap out the Model::Playback implementation on the fly.
- Model::PlaybackManager, which is an interface for what a
PlaybackManager must do, handling queues/playlists, and controlling a
player.
- Model::LocalPlaybackManager, which is an Model::PlaybackManager
implementation for playing back Jellyfin media within the application.
- Model::PlaybackReporter, which reports the current playback state to
the Jellyfin server, for keeping track of played items.
- Model::Player, which handles playing back media from an URL and
the usual play/pause et cetera.
In a future commit, this would allow for introducing a
Model::RemoteJellyfinPlaybackManager, to control other Jellyfin
instances.
2022-01-05 20:24:52 +00:00
|
|
|
void mediaPlayerItemChanged();
|
2020-09-25 12:46:39 +00:00
|
|
|
private:
|
2021-05-21 13:46:30 +00:00
|
|
|
/// Factor to multiply with when converting from milliseconds to ticks.
|
|
|
|
const static int MS_TICK_FACTOR = 10000;
|
2021-09-09 23:36:30 +00:00
|
|
|
|
2021-02-20 22:20:39 +00:00
|
|
|
|
2021-08-22 00:33:04 +00:00
|
|
|
|
core: Split PlaybackManager up into smaller parts
The PlaybackManager was a giant class that handled UI bindings, fetching
stream URLS, playback logic.
It now has been split up into:
- ViewModel::PlaybackManager, which handles UI interfacing and allowing
to swap out the Model::Playback implementation on the fly.
- Model::PlaybackManager, which is an interface for what a
PlaybackManager must do, handling queues/playlists, and controlling a
player.
- Model::LocalPlaybackManager, which is an Model::PlaybackManager
implementation for playing back Jellyfin media within the application.
- Model::PlaybackReporter, which reports the current playback state to
the Jellyfin server, for keeping track of played items.
- Model::Player, which handles playing back media from an URL and
the usual play/pause et cetera.
In a future commit, this would allow for introducing a
Model::RemoteJellyfinPlaybackManager, to control other Jellyfin
instances.
2022-01-05 20:24:52 +00:00
|
|
|
QMediaPlayer::Error m_error = QMediaPlayer::NoError;
|
2021-02-20 22:20:39 +00:00
|
|
|
|
2021-05-21 13:46:30 +00:00
|
|
|
// QQmlParserListener interface
|
|
|
|
void classBegin() override { m_qmlIsParsingComponent = true; }
|
2021-02-13 23:21:49 +00:00
|
|
|
void componentComplete() override;
|
2021-05-21 13:46:30 +00:00
|
|
|
bool m_qmlIsParsingComponent = false;
|
2021-07-31 13:06:17 +00:00
|
|
|
|
core: Split PlaybackManager up into smaller parts
The PlaybackManager was a giant class that handled UI bindings, fetching
stream URLS, playback logic.
It now has been split up into:
- ViewModel::PlaybackManager, which handles UI interfacing and allowing
to swap out the Model::Playback implementation on the fly.
- Model::PlaybackManager, which is an interface for what a
PlaybackManager must do, handling queues/playlists, and controlling a
player.
- Model::LocalPlaybackManager, which is an Model::PlaybackManager
implementation for playing back Jellyfin media within the application.
- Model::PlaybackReporter, which reports the current playback state to
the Jellyfin server, for keeping track of played items.
- Model::Player, which handles playing back media from an URL and
the usual play/pause et cetera.
In a future commit, this would allow for introducing a
Model::RemoteJellyfinPlaybackManager, to control other Jellyfin
instances.
2022-01-05 20:24:52 +00:00
|
|
|
QScopedPointer<PlaybackManagerPrivate> d_ptr;
|
2021-07-31 13:06:17 +00:00
|
|
|
};
|
|
|
|
|
2021-03-24 19:04:03 +00:00
|
|
|
} // NS ViewModel
|
|
|
|
} // NS Jellyfin
|
2020-09-25 12:46:39 +00:00
|
|
|
|
2021-03-24 19:04:03 +00:00
|
|
|
#endif // JELLYFIN_VIEWMODEL_PLAYBACKMANAGER_H
|