Mostly reimplement Player, begin implementing ViewPlayer UI design
This commit is contained in:
46
player.h
46
player.h
@@ -3,25 +3,27 @@
|
||||
#include <QtMultimedia>
|
||||
#include <QDebug>
|
||||
#include <QObject>
|
||||
#include <QList>
|
||||
#include <QTimer>
|
||||
#include <QtQmlIntegration/qqmlintegration.h>
|
||||
|
||||
constexpr int metadataFetchTimeout = 10000;
|
||||
constexpr std::string_view metadataEndpoint = "https://youradio.nonamesoft.xyz/youradio/api/status-json.xsl";
|
||||
constexpr std::string_view streamPrefix = "https://youradio.nonamesoft.xyz/youradio/api/";
|
||||
|
||||
struct Station
|
||||
{
|
||||
const char name[16];
|
||||
const char slug[16];
|
||||
QString* songTitle;
|
||||
u_int8_t listeners;
|
||||
};
|
||||
Q_GADGET
|
||||
|
||||
constexpr u_int8_t maxStations = 3;
|
||||
Q_PROPERTY(QString name MEMBER m_name);
|
||||
Q_PROPERTY(QString slug MEMBER m_slug);
|
||||
Q_PROPERTY(QString songTitle MEMBER m_songTitle);
|
||||
Q_PROPERTY(int listeners MEMBER m_listeners);
|
||||
|
||||
const Station stations[maxStations] = {
|
||||
{ "Autoradio", "autoradio" , nullptr, 0 },
|
||||
{ "Live Mix", "livemix" , nullptr, 0 },
|
||||
{ "Deep Bass", "bassboosted", nullptr, 0 }
|
||||
public:
|
||||
QString m_name;
|
||||
QString m_slug;
|
||||
QString m_songTitle;
|
||||
int m_listeners;
|
||||
};
|
||||
|
||||
class Player : public QObject
|
||||
@@ -30,17 +32,26 @@ class Player : public QObject
|
||||
QML_SINGLETON
|
||||
QML_ELEMENT
|
||||
|
||||
Q_PROPERTY(bool playing READ playing NOTIFY playingChanged)
|
||||
Q_PROPERTY(float volume READ volume WRITE setVolume NOTIFY volumeChanged)
|
||||
|
||||
Q_PROPERTY(bool playing READ playing NOTIFY playingChanged FINAL)
|
||||
Q_PROPERTY(float volume READ volume WRITE setVolume NOTIFY volumeChanged FINAL)
|
||||
Q_PROPERTY(const QList<Station> stations READ stations NOTIFY stationsChanged FINAL)
|
||||
Q_PROPERTY(int currentIndex READ currentIndex NOTIFY currentIndexChanged FINAL)
|
||||
Q_PROPERTY(const Station* currentStation READ currentStation NOTIFY currentStationChanged FINAL)
|
||||
|
||||
public:
|
||||
Player(QObject *parent = nullptr);
|
||||
~Player();
|
||||
|
||||
bool playing() const;
|
||||
|
||||
float volume() const;
|
||||
void setVolume(float newVolume);
|
||||
|
||||
const QList<Station> stations() const;
|
||||
|
||||
const int currentIndex() const;
|
||||
const Station* currentStation() const;
|
||||
|
||||
public slots:
|
||||
void startPlaying(u_int8_t index);
|
||||
void stopPlaying();
|
||||
@@ -48,8 +59,15 @@ public slots:
|
||||
signals:
|
||||
void playingChanged();
|
||||
void volumeChanged();
|
||||
void stationsChanged();
|
||||
void currentIndexChanged();
|
||||
void currentStationChanged();
|
||||
|
||||
private:
|
||||
QMediaPlayer player;
|
||||
QAudioOutput output;
|
||||
QTimer timer;
|
||||
|
||||
int m_currentIndex;
|
||||
QList<Station> m_stations;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user