From 51eed417f5fad2d208ab370a134021481531d790 Mon Sep 17 00:00:00 2001 From: flykhan Date: Thu, 31 Aug 2023 14:07:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=BF=AB=E9=80=80=E5=BF=AB?= =?UTF-8?q?=E8=BF=9B=E6=A7=BD=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mainwindow.cpp | 21 +++++++++++++++++++++ mainwindow.h | 1 + 2 files changed, 22 insertions(+) diff --git a/mainwindow.cpp b/mainwindow.cpp index 768d2e2..9db2498 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -260,12 +260,14 @@ void *readPipeMSG(void *arg) void MainWindow::setSongList() { + // 将 vector 内容转存入 QStringList QStringList strList; for(vector::const_iterator it = vectorSong.begin(); it != vectorSong.end(); ++it) { strList.append(QString::fromStdString(*it)); } ui->song_list_widget->addItems(strList); +// ui->song_list_widget->setCurrentRow(2); } void MainWindow::on_play_btn_clicked() @@ -293,3 +295,22 @@ void MainWindow::on_front_btn_clicked() { playNextSong(); // 切换下一首歌 } + + +void MainWindow::player_rewind_or_forward(int seconds) +{ + char changeSongBuf[128] = ""; + int len = sprintf(changeSongBuf, "seek %d\n", seconds); // 快进快退 seconds 秒 (seconds 为正->进,为负->退) + write(this->fifo_fd, changeSongBuf, len); // 将获取的下一首歌曲名写入到有名管道中 +} + + +void MainWindow::on_last_btn_clicked() +{ + player_rewind_or_forward(-10); // 快退 10 秒 +} + +void MainWindow::on_next_btn_clicked() +{ + player_rewind_or_forward(10); // 快退 10 秒 +} diff --git a/mainwindow.h b/mainwindow.h index 22f976b..40fafc7 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -47,6 +47,7 @@ public: public slots: void playNextSong(); // 切换歌曲槽函数I void playLastSong(); + void player_rewind_or_forward(int seconds); // 快进快退函数 void setCurrentTimeLabel(int time); // 设置当前时间标签槽函数 void setCurrentSlider(int currentProgress); // 设置当前进度条