Also stop audio player

This commit is contained in:
Nicolas Werner 2022-03-21 01:32:31 +01:00
parent 3beed3508a
commit 3aeeed49a9
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9

View file

@ -850,11 +850,15 @@ MediaUpload::MediaUpload(std::unique_ptr<QIODevice> source_,
} }
}); });
connect(mediaPlayer, &QMediaPlayer::durationChanged, [this, mediaPlayer](qint64 duration) { connect(mediaPlayer, &QMediaPlayer::durationChanged, [this, mediaPlayer](qint64 duration) {
if (duration > 0) if (duration > 0) {
this->duration_ = mediaPlayer->duration(); this->duration_ = mediaPlayer->duration();
if (mimeClass_ == u"audio")
mediaPlayer->stop();
}
nhlog::ui()->debug("Duration changed {}", duration); nhlog::ui()->debug("Duration changed {}", duration);
}); });
mediaPlayer->setMedia(QMediaContent(originalFilename_), source.get()); mediaPlayer->setMedia(QMediaContent(originalFilename_), source.get());
mediaPlayer->play(); mediaPlayer->play();
} }
} }