2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Allow float video player across accounts.

This commit is contained in:
John Preston
2020-06-25 18:17:37 +04:00
parent 8171ed6c12
commit bf7aae5fc6
38 changed files with 257 additions and 176 deletions

View File

@@ -46,6 +46,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "media/audio/media_audio.h"
#include "media/audio/media_audio_track.h"
#include "media/player/media_player_instance.h"
#include "media/player/media_player_float.h"
#include "media/clip/media_clip_reader.h" // For Media::Clip::Finish().
#include "window/notifications_manager.h"
#include "window/themes/window_theme.h"
@@ -512,6 +513,44 @@ void Application::startEmojiImageLoader() {
}, _lifetime);
}
void Application::setDefaultFloatPlayerDelegate(
not_null<Media::Player::FloatDelegate*> delegate) {
Expects(!_defaultFloatPlayerDelegate == !_floatPlayers);
_defaultFloatPlayerDelegate = delegate;
_replacementFloatPlayerDelegate = nullptr;
if (_floatPlayers) {
_floatPlayers->replaceDelegate(delegate);
} else {
_floatPlayers = std::make_unique<Media::Player::FloatController>(
delegate);
}
}
void Application::replaceFloatPlayerDelegate(
not_null<Media::Player::FloatDelegate*> replacement) {
Expects(_floatPlayers != nullptr);
_replacementFloatPlayerDelegate = replacement;
_floatPlayers->replaceDelegate(replacement);
}
void Application::restoreFloatPlayerDelegate(
not_null<Media::Player::FloatDelegate*> replacement) {
Expects(_floatPlayers != nullptr);
if (_replacementFloatPlayerDelegate == replacement) {
_replacementFloatPlayerDelegate = nullptr;
_floatPlayers->replaceDelegate(_defaultFloatPlayerDelegate);
}
}
rpl::producer<FullMsgId> Application::floatPlayerClosed() const {
Expects(_floatPlayers != nullptr);
return _floatPlayers->closeEvents();
}
void Application::logout(Main::Account *account) {
if (account) {
account->logOut();