2022-12-28 20:20:04 +00:00
|
|
|
/*
|
|
|
|
* Sailfin: a Jellyfin client written using Qt
|
|
|
|
* Copyright (C) 2023 Chris Josten and the Sailfin Contributors.
|
|
|
|
*
|
|
|
|
* 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_MODEL_REMOTEJELLYFINPLAYBACK_H
|
|
|
|
#define JELLYFIN_MODEL_REMOTEJELLYFINPLAYBACK_H
|
|
|
|
|
|
|
|
#include <JellyfinQt/dto/generalcommandtype.h>
|
2023-01-04 20:32:27 +00:00
|
|
|
#include <JellyfinQt/dto/playcommand.h>
|
|
|
|
#include <JellyfinQt/dto/playstatecommand.h>
|
|
|
|
#include <JellyfinQt/dto/sessioninfo.h>
|
2022-12-28 20:20:04 +00:00
|
|
|
#include <JellyfinQt/model/playbackmanager.h>
|
2023-01-04 20:32:27 +00:00
|
|
|
#include <JellyfinQt/support/loader.h>
|
2022-12-28 20:20:04 +00:00
|
|
|
|
|
|
|
#include <QJsonObject>
|
|
|
|
#include <QSharedPointer>
|
2023-01-04 20:32:27 +00:00
|
|
|
#include <QTimer>
|
|
|
|
|
|
|
|
#include <optional>
|
2022-12-28 20:20:04 +00:00
|
|
|
|
|
|
|
namespace Jellyfin {
|
|
|
|
|
|
|
|
class ApiClient;
|
|
|
|
|
|
|
|
namespace Model {
|
|
|
|
|
|
|
|
class RemoteJellyfinPlayback : public PlaybackManager {
|
|
|
|
public:
|
2023-01-04 20:32:27 +00:00
|
|
|
RemoteJellyfinPlayback(ApiClient &apiClient, QString sessionId, QObject *parent = nullptr);
|
|
|
|
virtual ~RemoteJellyfinPlayback();
|
2022-12-28 20:20:04 +00:00
|
|
|
|
|
|
|
// PlaybackManager
|
|
|
|
PlayerState playbackState() const override;
|
|
|
|
MediaStatus mediaStatus() const override;
|
|
|
|
bool hasNext() const override;
|
|
|
|
bool hasPrevious() const override;
|
|
|
|
PlaybackManagerError error() const override;
|
|
|
|
const QString &errorString() const override;
|
|
|
|
qint64 position() const override;
|
|
|
|
qint64 duration() const override;
|
|
|
|
bool seekable() const override;
|
|
|
|
bool hasAudio() const override;
|
|
|
|
bool hasVideo() const override;
|
|
|
|
void playItem(QSharedPointer<Item> item) override;
|
|
|
|
void playItemInList(const QList<QSharedPointer<Item> > &items, int index) override;
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void pause() override;
|
|
|
|
void play() override;
|
|
|
|
void playItemId(const QString &id) override;
|
|
|
|
void previous() override;
|
|
|
|
void next() override;
|
|
|
|
void goTo(int index) override;
|
|
|
|
void stop() override;
|
|
|
|
void seek(qint64 pos) override;
|
2023-01-04 20:32:27 +00:00
|
|
|
private slots:
|
|
|
|
void onPositionTimerFired();
|
|
|
|
void onSessionInfoUpdated(const QString &sessionId, const DTO::SessionInfo &sessionInfo);
|
2022-12-28 20:20:04 +00:00
|
|
|
private:
|
2023-01-04 20:32:27 +00:00
|
|
|
void sendPlaystateCommand(DTO::PlaystateCommand command, qint64 seekTicks = -1);
|
2022-12-28 20:20:04 +00:00
|
|
|
void sendGeneralCommand(DTO::GeneralCommandType command, QJsonObject arguments = QJsonObject());
|
2023-01-04 20:32:27 +00:00
|
|
|
void sendCommand(Support::LoaderBase *loader);
|
|
|
|
void playItemInList(const QStringList &items, int index, qint64 resumeTicks = -1);
|
2024-01-01 23:19:13 +00:00
|
|
|
/**
|
|
|
|
* @brief isQueueSame Checks if the items in the list are the same as in the queue
|
|
|
|
* @param items The item ids to compare to the queue
|
|
|
|
* @return True if the same, otherwise false
|
|
|
|
*/
|
|
|
|
bool isQueueSame(QList<QueueItem> itemIds);
|
|
|
|
/**
|
|
|
|
* Updates the now playing queue, with the given items
|
|
|
|
* @param itemIds The item ids to load
|
|
|
|
*/
|
|
|
|
void updateQueue(QList<QueueItem> itemIds);
|
2022-12-28 20:20:04 +00:00
|
|
|
ApiClient &m_apiClient;
|
2023-01-04 20:32:27 +00:00
|
|
|
QString m_sessionId;
|
|
|
|
std::optional<DTO::SessionInfo> m_lastSessionInfo;
|
|
|
|
QTimer *m_positionTimer;
|
|
|
|
qint64 m_position = 0;
|
2022-12-28 20:20:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // NS Model
|
|
|
|
} // NS Jellyfin
|
|
|
|
|
|
|
|
|
|
|
|
#endif // JELLYFIN_MODEL_REMOTEJELLYFINPLAYBACK_H
|