2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 22:46:10 +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

@@ -39,6 +39,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "auth_session.h"
#include "messenger.h"
#include "storage/file_download.h"
#include "calls/calls_instance.h"
namespace {
@@ -90,19 +91,24 @@ MediaView::MediaView(QWidget*) : TWidget(nullptr)
connect(QApplication::desktop(), SIGNAL(resized(int)), this, SLOT(onScreenResized(int)));
// While we have one mediaview for all authsessions we have to do this.
auto subscribeToDownloadFinished = [this] {
auto handleAuthSessionChange = [this] {
if (AuthSession::Exists()) {
subscribe(AuthSession::CurrentDownloaderTaskFinished(), [this] {
if (!isHidden()) {
updateControls();
}
});
subscribe(AuthSession::Current().calls().currentCallChanged(), [this](Calls::Call *call) {
if (call && _clipController && !_videoPaused) {
onVideoPauseResume();
}
});
}
};
subscribe(Messenger::Instance().authSessionChanged(), [subscribeToDownloadFinished] {
subscribeToDownloadFinished();
subscribe(Messenger::Instance().authSessionChanged(), [handleAuthSessionChange] {
handleAuthSessionChange();
});
subscribeToDownloadFinished();
handleAuthSessionChange();
auto observeEvents = Notify::PeerUpdate::Flag::SharedMediaChanged;
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(observeEvents, [this](const Notify::PeerUpdate &update) {