添加快退快进槽函数

This commit is contained in:
flykhan 2023-08-31 14:07:01 +08:00
parent 32c85bbe1f
commit 51eed417f5
2 changed files with 22 additions and 0 deletions

View File

@ -260,12 +260,14 @@ void *readPipeMSG(void *arg)
void MainWindow::setSongList()
{
// 将 vector 内容转存入 QStringList
QStringList strList;
for(vector<string>::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 秒
}

View File

@ -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); // 设置当前进度条