修改初始歌曲,修改音量控制内容

This commit is contained in:
flykhan 2023-08-31 15:03:28 +08:00
parent cc43a876f5
commit 42a4be7a34
1 changed files with 6 additions and 6 deletions

View File

@ -85,7 +85,7 @@ void MainWindow::mplayerInit()
dup2(fd[1], 1);
// 使用 exec 启动 mplayer
// execlp("mplayer","mplayer","-idle","-slave","-quiet","/home/flykhan/qtmplayer/song/StopLove.mp3",NULL);
execlp("/usr/bin/mplayer","mplayer","-idle","-slave","-quiet","-input","file=fifo_cmd","/home/flykhan/qtmplayer/song/StopLove.mp3",NULL);
execlp("/usr/bin/mplayer","mplayer","-idle","-slave","-quiet","-input","file=fifo_cmd","/home/flykhan/qtmplayer/song/Diamonds.mp3",NULL);
_exit(-1); // 异常退出
}
else if(pid>0) // 父进程
@ -307,7 +307,7 @@ void MainWindow::player_rewind_or_forward(int seconds)
void MainWindow::volume_control(int value)
{
char changeSongBuf[128] = "";
int len = sprintf(changeSongBuf, "volume %d 1\n", value); // 音量调整到 value 大小
int len = sprintf(changeSongBuf, "volume %d\n", value); // 音量调整到 value 大小
write(this->fifo_fd, changeSongBuf, len); // 将音量控制指令写入到有名管道中
}
@ -332,24 +332,24 @@ void MainWindow::on_mute_btn_clicked()
{
if(mute_flag == 0) // 没静音则按下后设置静音
{
ui->play_btn->setIcon(QIcon(":/icon/mute2"));
ui->mute_btn->setIcon(QIcon(":/icon/mute1"));
// volume_mute_switch(1);
// mute_flag = 1;
volume_mute_switch(++mute_flag);
}
else if (mute_flag == 1) // 已静音则按下后取消静音
{
ui->play_btn->setIcon(QIcon(":/icon/mute1"));
ui->mute_btn->setIcon(QIcon(":/icon/mute2"));
volume_mute_switch(--mute_flag);
}
}
void MainWindow::on_volume_down_btn_clicked()
{
volume_control(-5); // 减 5 音量
volume_control(-10); // 减 10 音量
}
void MainWindow::on_volume_up_btn_clicked()
{
volume_control(5); // 加 5 音量
volume_control(10); // 加 10 音量
}