From e58cc703f370b394fdd5662042b7638f4ab5fed7 Mon Sep 17 00:00:00 2001 From: Gary Wang Date: Thu, 6 Jul 2023 00:02:06 +0800 Subject: [PATCH] fix: adapt api change, ensure volumn slider work --- mainwindow.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index cf4bebe..f131867 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -301,7 +301,7 @@ void MainWindow::on_playBtn_clicked() loadFile(); m_mediaPlayer->play(); } else if (m_mediaPlayer->mediaStatus() == QMediaPlayer::InvalidMedia) { - ui->propLabel->setText("Error: InvalidMedia"); + ui->propLabel->setText("Error: InvalidMedia" + m_mediaPlayer->errorString()); } else { if (QList {QMediaPlayer::PausedState, QMediaPlayer::StoppedState} .contains(m_mediaPlayer->playbackState())) { @@ -340,7 +340,7 @@ void MainWindow::on_volumeSlider_valueChanged(int value) if (m_audioOutput->isMuted()) { m_audioOutput->setMuted(false); } - m_audioOutput->setVolume(value); + m_audioOutput->setVolume(value / 100.0); } void MainWindow::on_stopBtn_clicked() @@ -501,8 +501,8 @@ void MainWindow::initConnections() } }); - connect(m_audioOutput, &QAudioOutput::volumeChanged, this, [=](int vol) { - ui->volumeSlider->setValue(vol); + connect(m_audioOutput, &QAudioOutput::volumeChanged, this, [=](float vol) { + ui->volumeSlider->setValue(vol * 100); }); // connect(m_mediaPlayer, static_cast(&QMediaPlayer::error),