MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / createPlayer

Method createPlayer

Telegram/SourceFiles/mainwidget.cpp:899–957  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

897}
898
899void MainWidget::createPlayer() {
900 if (!_player) {
901 _player.create(
902 this,
903 object_ptr<Media::Player::Widget>(this, this, _controller),
904 _controller->adaptive().oneColumnValue());
905 rpl::merge(
906 _player->heightValue() | rpl::map_to(true),
907 _player->shownValue()
908 ) | rpl::on_next(
909 [this] { playerHeightUpdated(); },
910 _player->lifetime());
911 _player->entity()->setCloseCallback([=] {
912 Media::Player::instance()->stopAndClose();
913 });
914 _player->entity()->setShowItemCallback([=](
915 not_null<const HistoryItem*> item) {
916 const auto peer = item->history()->peer;
917 if (const auto window = Core::App().windowFor(peer)) {
918 if (const auto controller = window->sessionController()) {
919 controller->showMessage(item);
920 return;
921 }
922 }
923 _controller->showMessage(item);
924 });
925
926 _player->entity()->togglePlaylistRequests(
927 ) | rpl::on_next([=](bool shown) {
928 if (!shown) {
929 _playerPlaylist->hideFromOther();
930 return;
931 } else if (_playerPlaylist->isHidden()) {
932 auto position = mapFromGlobal(QCursor::pos()).x();
933 auto bestPosition = _playerPlaylist->bestPositionFor(position);
934 if (rtl()) bestPosition = position + 2 * (position - bestPosition) - _playerPlaylist->width();
935 updateMediaPlaylistPosition(bestPosition);
936 }
937 _playerPlaylist->showFromOther();
938 }, _player->lifetime());
939
940 orderWidgets();
941 if (_showAnimation) {
942 _player->show(anim::type::instant);
943 _player->setVisible(false);
944 Shortcuts::ToggleMediaShortcuts(true);
945 } else {
946 _player->hide(anim::type::instant);
947 }
948 }
949 if (_player && !_player->toggled()) {
950 if (!_showAnimation) {
951 _player->show(anim::type::normal);
952 _playerHeight = _contentScrollAddToY = _player->contentHeight();
953 updateControlsGeometry();
954 Shortcuts::ToggleMediaShortcuts(true);
955 }
956 }

Callers

nothing calls this directly

Calls 15

AppClass · 0.85
rtlFunction · 0.85
ToggleMediaShortcutsFunction · 0.85
oneColumnValueMethod · 0.80
setShowItemCallbackMethod · 0.80
windowForMethod · 0.80
hideFromOtherMethod · 0.80
bestPositionForMethod · 0.80
showFromOtherMethod · 0.80
instanceFunction · 0.50
createMethod · 0.45

Tested by

no test coverage detected