Commit 5b53a342 authored by Carlos Jose Mazieri's avatar Carlos Jose Mazieri Committed by Kempe
Browse files

[DEATURE] Add 'station' property to 'AudioPlayer'

parent cc379b90
......@@ -87,12 +87,10 @@ void AudioPlayer::bufferStatusChanged(const int progress)
void AudioPlayer::metaDataChanged()
{
qDebug() << "metaDataChanged";
QString tmp_title = getMetaDataValueOrEmptyByKey("Title").toString();
if (tmp_title != m_title) {
qDebug() << "Setting title to: " << tmp_title;
m_title = tmp_title;
emit titleChanged();
setTitle(tmp_title);
}
QString tmp_genre = getMetaDataValueOrEmptyByKey("Genre").toString();
if (tmp_genre != m_genre) {
......@@ -109,3 +107,15 @@ QVariant AudioPlayer::getMetaDataValueOrEmptyByKey(QString key) {
return "";
}
void AudioPlayer::setStation(const QString& name)
{
m_station = name;
emit stationChanged();
}
void AudioPlayer::setTitle(const QString &title)
{
m_title = title + QLatin1String(" ");
emit titleChanged();
}
......@@ -13,8 +13,9 @@ class AudioPlayer : public QMediaPlayer {
Q_PROPERTY(bool isBuffering READ isBuffering NOTIFY playbackStatusChanged)
Q_PROPERTY(bool isPlayable READ isPlayable)
Q_PROPERTY(double bufferProgress READ bufferProgress NOTIFY bufferProgressChanged)
Q_PROPERTY(QString title READ title NOTIFY titleChanged)
Q_PROPERTY(QString genre READ genre NOTIFY genreChanged)
Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged)
Q_PROPERTY(QString genre READ genre NOTIFY genreChanged)
Q_PROPERTY(QString station READ station WRITE setStation NOTIFY stationChanged)
public:
......@@ -28,6 +29,7 @@ public:
double bufferProgress() const { return m_buffer_progress; }
QString title() const { return m_title; }
QString genre() const { return m_genre; }
QString station() const { return m_station; }
signals:
void playbackStateChanged();
......@@ -36,6 +38,7 @@ signals:
void bufferProgressChanged();
void titleChanged();
void genreChanged();
void stationChanged();
public slots:
void loadUrl(QString url);
......@@ -43,6 +46,8 @@ public slots:
void startPlayback();
void pauseOrStopPlayback();
void stopPlayback();
void setStation(const QString& name);
void setTitle(const QString& title);
private slots:
void bufferStatusChanged(const int);
......@@ -52,8 +57,9 @@ private:
// States
QUrl m_current_url;
double m_buffer_progress;
QString m_title;
QString m_title;
QString m_genre;
QString m_station;
QVariant getMetaDataValueOrEmptyByKey(QString);
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment