summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArno <arno@disconnect.de>2017-02-27 02:38:49 +0100
committerArno <arno@disconnect.de>2017-02-27 02:38:49 +0100
commit7e8cf45e8fde4170ed2df97ecb487dd31dfa1092 (patch)
tree6063431cebc68e4c606743a0b3c516ebdd879ee9
parentbfe075c2c75d00155c7f3e92e2a16c25eed8d005 (diff)
downloadBeetPlayer-7e8cf45e8fde4170ed2df97ecb487dd31dfa1092.tar.gz
BeetPlayer-7e8cf45e8fde4170ed2df97ecb487dd31dfa1092.tar.bz2
BeetPlayer-7e8cf45e8fde4170ed2df97ecb487dd31dfa1092.zip
Finally play something!
Far from there, but it finally, actually plays songs!
-rw-r--r--playerwidget.cpp16
-rw-r--r--playerwidget.h2
2 files changed, 18 insertions, 0 deletions
diff --git a/playerwidget.cpp b/playerwidget.cpp
index 6e6cb76..40294db 100644
--- a/playerwidget.cpp
+++ b/playerwidget.cpp
@@ -14,6 +14,7 @@
#include <QSqlQuery>
#include <QAction>
#include <QToolBar>
+#include <QMediaPlayer>
#include <algorithm>
@@ -92,6 +93,7 @@ void PlayerWidget::setupGui(){
mPlayListView->setModel(mPlayListModel);
mPlayListView->setRootIsDecorated(false);
mPlayListView->setSelectionMode(QAbstractItemView::ExtendedSelection);
+ connect(mPlayListView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(playCurrent(QModelIndex)));
QGroupBox *playListGB = new QGroupBox(tr("Playlist"));
QVBoxLayout *playListL = new QVBoxLayout;
playListL->addWidget(mPlayListView);
@@ -103,6 +105,9 @@ void PlayerWidget::setupGui(){
rightWidgetL->addWidget(playListGB);
rightWidget->setLayout(rightWidgetL);
+ //the Player
+ mPlayer = new QMediaPlayer(this);
+
//put it all together
QSplitter *splitter = new QSplitter;
splitter->addWidget(leftWidget);
@@ -394,9 +399,20 @@ void PlayerWidget::randomPlay(){
while(randomQ.next()){
QString display = QString(tr("%1 - %2 - %3 - %4")).arg(QChar(0x266C)).arg(randomQ.value(4).toString()).arg(randomQ.value(1).toString()).arg(randomQ.value(5).toString());
QStandardItem *item = new QStandardItem;
+ item->setEditable(false);
item->setFont(QFont("courier"));
item->setText(display);
item->setData(randomQ.value(2), FullPathRole);
root->appendRow(item);
}
}
+
+void PlayerWidget::playCurrent(const QModelIndex &index){
+ QString fullPath = index.data(FullPathRole).toString();
+ play(fullPath);
+}
+
+void PlayerWidget::play(const QString &fullPath){
+ mPlayer->setMedia(QUrl::fromLocalFile(fullPath));
+ mPlayer->play();
+}
diff --git a/playerwidget.h b/playerwidget.h
index 2837688..a321e4a 100644
--- a/playerwidget.h
+++ b/playerwidget.h
@@ -31,6 +31,7 @@ class PlayerWidget : public QWidget {
void clearPlayList();
void shufflePlayList();
void randomPlay();
+ void playCurrent(const QModelIndex &index);
private:
void setupGui();
@@ -40,6 +41,7 @@ class PlayerWidget : public QWidget {
void populateByGenre(QStandardItem *parent, const QString &filter);
void recurse(const QModelIndex &parent);
void addSong(const QModelIndex &idx);
+ void play(const QString &fullPath);
QLineEdit *mFilter;
QMediaPlayer *mPlayer;
BeetView *mView;