Reimplement streaming
This commit is contained in:
41
player.h
41
player.h
@@ -1,18 +1,55 @@
|
||||
#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();
|
||||
|
||||
Q_INVOKABLE void startPlaying(int index);
|
||||
Q_INVOKABLE void stopPlaying();
|
||||
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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user