forked from ghostfox/qyouradio
56 lines
1.2 KiB
C++
56 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include <QtMultimedia>
|
|
#include <QDebug>
|
|
#include <QObject>
|
|
#include <QtQmlIntegration/qqmlintegration.h>
|
|
|
|
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;
|
|
};
|
|
|
|
constexpr u_int8_t maxStations = 3;
|
|
|
|
const Station stations[maxStations] = {
|
|
{ "Autoradio", "autoradio" , nullptr, 0 },
|
|
{ "Live Mix", "livemix" , nullptr, 0 },
|
|
{ "Deep Bass", "bassboosted", nullptr, 0 }
|
|
};
|
|
|
|
class Player : public QObject
|
|
{
|
|
Q_OBJECT
|
|
QML_SINGLETON
|
|
QML_ELEMENT
|
|
|
|
Q_PROPERTY(bool playing READ playing NOTIFY playingChanged)
|
|
Q_PROPERTY(float volume READ volume WRITE setVolume NOTIFY volumeChanged)
|
|
|
|
public:
|
|
Player(QObject *parent = nullptr);
|
|
~Player();
|
|
|
|
bool playing() const;
|
|
float volume() const;
|
|
void setVolume(float newVolume);
|
|
|
|
public slots:
|
|
void startPlaying(u_int8_t index);
|
|
void stopPlaying();
|
|
|
|
signals:
|
|
void playingChanged();
|
|
void volumeChanged();
|
|
|
|
private:
|
|
QMediaPlayer player;
|
|
QAudioOutput output;
|
|
};
|