Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: #15 update QMediaPlayer handling #26

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions mpd-interface/httpstream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ void HttpStream::toggleMute()
#ifdef LIBVLC_FOUND
libvlc_audio_set_mute(player, muted);
#else
player->audioOutput()->setMuted(!muted);
player->audioOutput()->setMuted(muted);
#endif
emit update();
}
Expand Down Expand Up @@ -172,7 +172,7 @@ void HttpStream::streamUrl(const QString& url)
QAudioOutput* audioOutput = new QAudioOutput(this);
player->setAudioOutput(audioOutput);
player->setSource(qUrl);
connect(player, &QMediaPlayer::bufferProgressChanged, this, &HttpStream::bufferingProgress);
connect(player, &QMediaPlayer::mediaStatusChanged, this, &HttpStream::mediaStatus);
#endif
muted = false;
setVolume(Configuration(metaObject()->className()).get("volume", currentVolume));
Expand All @@ -188,16 +188,14 @@ void HttpStream::streamUrl(const QString& url)
}

#ifndef LIBVLC_FOUND
void HttpStream::bufferingProgress(int progress)
void HttpStream::mediaStatus(QMediaPlayer::MediaStatus status)
{
MPDStatus* const status = MPDStatus::self();
if (status->state() == MPDState_Playing) {
if (progress == 100) {
MPDStatus* const mpdstatus = MPDStatus::self();
DBUG << status;
if (mpdstatus->state() == MPDState_Playing) {
if (status == QMediaPlayer::BufferingMedia || status == QMediaPlayer::BufferedMedia) {
player->play();
}
else {
player->pause();
}
}
}
#endif
Expand All @@ -220,6 +218,7 @@ void HttpStream::updateStatus()
#endif

if (status->state() == state && !playerNeedsToStart) {
player->play();
return;
}

Expand Down
2 changes: 1 addition & 1 deletion mpd-interface/httpstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private Q_SLOTS:
void streamUrl(const QString& url);
void checkPlayer();
#ifndef LIBVLC_FOUND
void bufferingProgress(int progress);
void mediaStatus(QMediaPlayer::MediaStatus status);
#endif

private:
Expand Down
Loading