diff --git a/Telegram/SourceFiles/media/audio/media_audio_track.cpp b/Telegram/SourceFiles/media/audio/media_audio_track.cpp index bbf2ea5bd7..ab6f33d17c 100644 --- a/Telegram/SourceFiles/media/audio/media_audio_track.cpp +++ b/Telegram/SourceFiles/media/audio/media_audio_track.cpp @@ -142,7 +142,7 @@ void Track::fillFromFile(const QString &filePath) { } } -void Track::playWithLooping(bool looping) { +void Track::playWithLooping(bool looping, float64 volumeOverride) { _active = true; if (failed() || _samples.empty()) { finish(); @@ -152,7 +152,12 @@ void Track::playWithLooping(bool looping) { alSourceStop(_alSource); _looping = looping; alSourcei(_alSource, AL_LOOPING, _looping ? 1 : 0); - alSourcef(_alSource, AL_GAIN, _volume); + alSourcef( + _alSource, + AL_GAIN, + (volumeOverride > 0) + ? volumeOverride + : _volume); alSourcePlay(_alSource); _instance->trackStarted(this); } diff --git a/Telegram/SourceFiles/media/audio/media_audio_track.h b/Telegram/SourceFiles/media/audio/media_audio_track.h index 5016a19c93..5b37fb5e9f 100644 --- a/Telegram/SourceFiles/media/audio/media_audio_track.h +++ b/Telegram/SourceFiles/media/audio/media_audio_track.h @@ -30,11 +30,11 @@ public: void fillFromFile(const Core::FileLocation &location); void fillFromFile(const QString &filePath); - void playOnce() { - playWithLooping(false); + void playOnce(float64 volumeOverride = -1) { + playWithLooping(false, volumeOverride); } - void playInLoop() { - playWithLooping(true); + void playInLoop(float64 volumeOverride = -1) { + playWithLooping(true, volumeOverride); } bool isLooping() const { @@ -61,7 +61,7 @@ public: private: void finish(); void ensureSourceCreated(); - void playWithLooping(bool looping); + void playWithLooping(bool looping, float64 volumeOverride); not_null _instance; diff --git a/Telegram/SourceFiles/window/notifications_manager.cpp b/Telegram/SourceFiles/window/notifications_manager.cpp index dddc7a54c7..bad3f2182d 100644 --- a/Telegram/SourceFiles/window/notifications_manager.cpp +++ b/Telegram/SourceFiles/window/notifications_manager.cpp @@ -967,8 +967,11 @@ void System::notifySettingsChanged(ChangeType type) { return _settingsChanged.fire(std::move(type)); } -void System::playSound(not_null session, DocumentId id) { - lookupSound(&session->data(), id)->playOnce(); +void System::playSound( + not_null session, + DocumentId id, + float64 volumeOverride) { + lookupSound(&session->data(), id)->playOnce(volumeOverride); } Manager::DisplayOptions Manager::getNotificationOptions( diff --git a/Telegram/SourceFiles/window/notifications_manager.h b/Telegram/SourceFiles/window/notifications_manager.h index b91afcfca0..5ff22fe249 100644 --- a/Telegram/SourceFiles/window/notifications_manager.h +++ b/Telegram/SourceFiles/window/notifications_manager.h @@ -124,7 +124,10 @@ public: [[nodiscard]] rpl::producer settingsChanged() const; void notifySettingsChanged(ChangeType type); - void playSound(not_null session, DocumentId id); + void playSound( + not_null session, + DocumentId id, + float64 volumeOverride = -1); [[nodiscard]] QByteArray lookupSoundBytes( not_null owner, DocumentId id);