1
0
Fork 0
mirror of https://github.com/HenkKalkwater/harbour-sailfin.git synced 2025-09-04 01:42:44 +00:00

Add support for handling playstate commands

This commit is contained in:
Chris Josten 2021-09-10 01:36:30 +02:00
parent 7c21eb425d
commit 2a3bd51def
No known key found for this signature in database
GPG key ID: A69C050E9FD9FF6A
6 changed files with 112 additions and 15 deletions

View file

@ -25,6 +25,7 @@
namespace Jellyfin {
namespace DTO {
class UserItemDataDto;
class PlaystateRequest;
}
/**
@ -50,6 +51,8 @@ signals:
* @param timeout Timeout in MS to show the message. -1: no timeout supplied.
*/
void displayMessage(const QString &header, const QString &message, int timeout = -1);
void playstateCommandReceived(const Jellyfin::DTO::PlaystateRequest &request);
};
}

View file

@ -196,6 +196,7 @@ private slots:
void onPositionChanged(qint64 position);
void onSeekableChanged(bool seekable);
void onPlaybackManagerChanged(ViewModel::PlaybackManager *newPlaybackManager);
void onSeeked(qint64 newPosition);
};
} // NS FreeDesktop

View file

@ -22,6 +22,7 @@
#include <QAbstractItemModel>
#include <QJsonArray>
#include <QJsonObject>
#include <QLoggingCategory>
#include <QFuture>
#include <QObject>
#include <QtGlobal>
@ -51,9 +52,13 @@ namespace Jellyfin {
// Forward declaration of Jellyfin::ApiClient found in jellyfinapiclient.h
class ApiClient;
class ItemModel;
class RemoteItem;
namespace DTO {
class PlaystateRequest;
}
namespace ViewModel {
Q_DECLARE_LOGGING_CATEGORY(playbackManager);
// Later defined in this file
class ItemUrlFetcherThread;
@ -99,6 +104,8 @@ public:
Q_PROPERTY(qint64 position READ position NOTIFY positionChanged)
Q_PROPERTY(bool hasNext READ hasNext NOTIFY hasNextChanged)
Q_PROPERTY(bool hasPrevious READ hasPrevious NOTIFY hasPreviousChanged)
/// Whether playstate commands received over the websocket should be handled
Q_PROPERTY(bool handlePlaystateCommands READ handlePlaystateCommands WRITE setHandlePlaystateCommands NOTIFY handlePlaystateCommandsChanged)
ViewModel::Item *item() const { return m_displayItem; }
QSharedPointer<Model::Item> dataItem() const { return m_item; }
@ -122,6 +129,9 @@ public:
bool seekable() const { return m_mediaPlayer->isSeekable(); }
QMediaPlayer::Error error () const;
QString errorString() const;
bool handlePlaystateCommands() const { return m_handlePlaystateCommands; }
void setHandlePlaystateCommands(bool newHandlePlaystateCommands) { m_handlePlaystateCommands = newHandlePlaystateCommands; emit handlePlaystateCommandsChanged(m_handlePlaystateCommands); }
signals:
void itemChanged(ViewModel::Item *newItemId);
void streamUrlChanged(const QString &newStreamUrl);
@ -132,6 +142,9 @@ signals:
void resumePlaybackChanged(bool newResumePlayback);
void playMethodChanged(PlayMethod newPlayMethod);
// Emitted when seek has been called.
void seeked(qint64 newPosition);
// Current media player related property signals
void mediaObjectChanged(QObject *newMediaObject);
void positionChanged(qint64 newPosition);
@ -146,6 +159,7 @@ signals:
void errorStringChanged(const QString &newErrorString);
void hasNextChanged(bool newHasNext);
void hasPreviousChanged(bool newHasPrevious);
void handlePlaystateCommandsChanged(bool newHandlePlaystateCommands);
public slots:
/**
* @brief playItem Replaces the current queue and plays the given item.
@ -187,6 +201,8 @@ public slots:
*/
void next();
void handlePlaystateRequest(const DTO::PlaystateRequest &request);
private slots:
void mediaPlayerStateChanged(QMediaPlayer::State newState);
void mediaPlayerPositionChanged(qint64 position);
@ -260,6 +276,8 @@ private:
int m_queueIndex = 0;
bool m_resumePlayback = true;
bool m_handlePlaystateCommands = true;
// Helper methods
void setItem(QSharedPointer<Model::Item> newItem);