ping sound media doesn't get recreated on every message

This commit is contained in:
fourtf 2017-12-18 17:57:56 +01:00
parent cca065f0f9
commit 625e33d654

View file

@ -364,6 +364,7 @@ void TwitchMessageBuilder::appendUsername()
void TwitchMessageBuilder::parseHighlights()
{
static auto player = new QMediaPlayer;
static QUrl currentPlayerUrl;
SettingsManager &settings = SettingsManager::getInstance();
static pajlada::Settings::Setting<std::string> currentUser("/accounts/current");
@ -374,10 +375,18 @@ void TwitchMessageBuilder::parseHighlights()
return;
}
// update the media player url if necessary
QUrl highlightSoundUrl;
if (settings.customHighlightSound) {
player->setMedia(QUrl(settings.pathHighlightSound.get()));
highlightSoundUrl = QUrl(settings.pathHighlightSound.get());
} else {
player->setMedia(QUrl("qrc:/sounds/ping2.wav"));
highlightSoundUrl = QUrl("qrc:/sounds/ping2.wav");
}
if (currentPlayerUrl != highlightSoundUrl) {
player->setMedia(highlightSoundUrl);
currentPlayerUrl = highlightSoundUrl;
}
struct Highlight {