From e38a221858d932aab81e04c5a95188a3e705ed12 Mon Sep 17 00:00:00 2001 From: Arno Date: Sat, 26 Aug 2017 08:04:07 +0200 Subject: Play the doubleClicked url Shit, it worked on the first attempt! --- playerwidget.cpp | 10 ++++++++++ playerwidget.h | 1 + 2 files changed, 11 insertions(+) diff --git a/playerwidget.cpp b/playerwidget.cpp index 37c6d5c..3dd8b87 100644 --- a/playerwidget.cpp +++ b/playerwidget.cpp @@ -811,6 +811,11 @@ void PlayerWidget::viewDoubleClicked(const QModelIndex &idx){ addToPlayList(); return; } + if(model == mWebRadioModel){ + QString url(idx.data(UrlRole).toString()); + playUrl(url); + return; + } QString fp(idx.data(FullPathRole).toString()); QFileInfo fi(fp); if(fi.isDir()){ @@ -1391,6 +1396,11 @@ void PlayerWidget::play(const QString &fullPath){ emit playModeChanged(tr("Playing")); } +void PlayerWidget::playUrl(const QString &url){ + mPlayer->setMedia(QUrl(url)); + mPlayer->play(); +} + void PlayerWidget::volumeChanged(int volume){ QString s = QString("%1 %").arg(volume, 3, 10, QChar('0')); mVolumePos->setText(s); diff --git a/playerwidget.h b/playerwidget.h index 2087311..2fb218a 100644 --- a/playerwidget.h +++ b/playerwidget.h @@ -107,6 +107,7 @@ class PlayerWidget : public QWidget { void recurse(const QModelIndex &parent); void addSong(const QModelIndex &idx); void play(const QString &fullPath); + void playUrl(const QString &url); void advance(int numSongs); void expandRecursive(const QModelIndex &idx); void adjustVolume(int by); -- cgit v1.2.3-70-g09d2