2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Pause all media if a call is created.

Pause video, voice messages, songs and stop video messages.
This commit is contained in:
John Preston
2017-05-12 20:44:18 +03:00
parent 040ee90aec
commit 565b56fb5f
9 changed files with 59 additions and 9 deletions

View File

@@ -23,6 +23,9 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "media/media_audio.h"
#include "media/media_audio_capture.h"
#include "observer_peer.h"
#include "messenger.h"
#include "auth_session.h"
#include "calls/calls_instance.h"
namespace Media {
namespace Player {
@@ -59,6 +62,22 @@ Instance::Instance() {
handleLogout();
}
});
// While we have one Media::Player::Instance for all authsessions we have to do this.
auto handleAuthSessionChange = [this] {
if (AuthSession::Exists()) {
subscribe(AuthSession::Current().calls().currentCallChanged(), [this](Calls::Call *call) {
if (call) {
pause(AudioMsgId::Type::Voice);
pause(AudioMsgId::Type::Song);
}
});
}
};
subscribe(Messenger::Instance().authSessionChanged(), [handleAuthSessionChange] {
handleAuthSessionChange();
});
handleAuthSessionChange();
}
void Instance::notifyPeerUpdated(const Notify::PeerUpdate &update) {