mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
fixed pingsound not playing sometimes
This commit is contained in:
parent
4f356f80cf
commit
e1a9a437f1
|
@ -143,9 +143,21 @@ bool TwitchMessageBuilder::isIgnored() const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline QMediaPlayer *getPlayer()
|
||||||
|
{
|
||||||
|
if (isGuiThread())
|
||||||
|
{
|
||||||
|
static auto player = new QMediaPlayer;
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TwitchMessageBuilder::triggerHighlights()
|
void TwitchMessageBuilder::triggerHighlights()
|
||||||
{
|
{
|
||||||
static auto player = new QMediaPlayer;
|
|
||||||
static QUrl currentPlayerUrl;
|
static QUrl currentPlayerUrl;
|
||||||
|
|
||||||
if (this->historicalMessage_)
|
if (this->historicalMessage_)
|
||||||
|
@ -165,21 +177,24 @@ void TwitchMessageBuilder::triggerHighlights()
|
||||||
|
|
||||||
if (this->highlightSound_ && resolveFocus)
|
if (this->highlightSound_ && resolveFocus)
|
||||||
{
|
{
|
||||||
// update the media player url if necessary
|
if (auto player = getPlayer())
|
||||||
QUrl highlightSoundUrl =
|
|
||||||
getSettings()->customHighlightSound
|
|
||||||
? QUrl::fromLocalFile(
|
|
||||||
getSettings()->pathHighlightSound.getValue())
|
|
||||||
: QUrl("qrc:/sounds/ping2.wav");
|
|
||||||
|
|
||||||
if (currentPlayerUrl != highlightSoundUrl)
|
|
||||||
{
|
{
|
||||||
player->setMedia(highlightSoundUrl);
|
// update the media player url if necessary
|
||||||
|
QUrl highlightSoundUrl =
|
||||||
|
getSettings()->customHighlightSound
|
||||||
|
? QUrl::fromLocalFile(
|
||||||
|
getSettings()->pathHighlightSound.getValue())
|
||||||
|
: QUrl("qrc:/sounds/ping2.wav");
|
||||||
|
|
||||||
currentPlayerUrl = highlightSoundUrl;
|
if (currentPlayerUrl != highlightSoundUrl)
|
||||||
|
{
|
||||||
|
player->setMedia(highlightSoundUrl);
|
||||||
|
|
||||||
|
currentPlayerUrl = highlightSoundUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
player->play();
|
||||||
}
|
}
|
||||||
|
|
||||||
player->play();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->highlightAlert_)
|
if (this->highlightAlert_)
|
||||||
|
|
Loading…
Reference in a new issue