From 0e75ad42e21095c3c4e8bc64fc000f6608e682e3 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 16 Dec 2019 16:58:19 +0300 Subject: [PATCH] Fix playback state display in round videos. --- .../history/view/media/history_view_gif.cpp | 89 +++---------------- .../media/view/media_view_overlay_widget.cpp | 4 +- 2 files changed, 17 insertions(+), 76 deletions(-) diff --git a/Telegram/SourceFiles/history/view/media/history_view_gif.cpp b/Telegram/SourceFiles/history/view/media/history_view_gif.cpp index 0e8e496c9..98e6cf08d 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_gif.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_gif.cpp @@ -151,32 +151,6 @@ QSize Gif::countCurrentSize(int newWidth) { auto newHeight = qMax(th, st::minPhotoSize); accumulate_max(newWidth, _parent->infoWidth() + 2 * st::msgDateImgDelta + st::msgDateImgPadding.x()); if (!activeCurrentStreamed()) { - //const auto own = (reader->mode() == ::Media::Clip::Reader::Mode::Gif); - //if (own && !reader->started()) { - // auto isRound = _data->isVideoMessage(); - // auto inWebPage = (_parent->media() != this); - // auto roundRadius = isRound - // ? ImageRoundRadius::Ellipse - // : inWebPage - // ? ImageRoundRadius::Small - // : ImageRoundRadius::Large; - // auto roundCorners = (isRound || inWebPage) - // ? RectPart::AllCorners - // : ((isBubbleTop() - // ? (RectPart::TopLeft | RectPart::TopRight) - // : RectPart::None) - // | ((isBubbleBottom() && _caption.isEmpty()) - // ? (RectPart::BottomLeft | RectPart::BottomRight) - // : RectPart::None)); - // reader->start( - // _thumbw, - // _thumbh, - // newWidth, - // newHeight, - // roundRadius, - // roundCorners); - //} - // #TODO video accumulate_max(newWidth, gifMaxStatusWidth(_data) + 2 * (st::msgDateImgDelta + st::msgDateImgPadding.x())); } if (_parent->hasBubble()) { @@ -307,8 +281,6 @@ void Gif::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms displayMute = true; } } - // #TODO video - // paused?.. auto request = ::Media::Streaming::FrameRequest(); request.outer = QSize(usew, painth) * cIntRetinaFactor(); request.resize = QSize(_thumbw, _thumbh) * cIntRetinaFactor(); @@ -778,23 +750,23 @@ void Gif::updateStatusText() const { statusSize = _data->loadOffset(); } else if (_data->loaded()) { statusSize = FileStatusSizeLoaded; - if (const auto streamed = activeRoundStreamed()) { - const auto state = streamed->player().prepareLegacyState(); - if (state.length) { - auto position = int64(0); - if (::Media::Player::IsStoppedAtEnd(state.state)) { - position = state.length; - } else if (!::Media::Player::IsStoppedOrStopping(state.state)) { - position = state.position; - } - statusSize = -1 - int((state.length - position) / state.frequency + 1); - } else { - statusSize = -1 - _data->getDuration(); - } - } } else { statusSize = FileStatusSizeReady; } + if (const auto streamed = activeRoundStreamed()) { + const auto state = streamed->player().prepareLegacyState(); + if (state.length) { + auto position = int64(0); + if (::Media::Player::IsStoppedAtEnd(state.state)) { + position = state.length; + } else if (!::Media::Player::IsStoppedOrStopping(state.state)) { + position = state.position; + } + statusSize = -1 - int((state.length - position) / state.frequency + 1); + } else { + statusSize = -1 - _data->getDuration(); + } + } if (statusSize != _statusSize) { setStatusSize(statusSize); } @@ -854,39 +826,6 @@ int Gif::additionalWidth(const HistoryMessageVia *via, const HistoryMessageReply ::Media::View::PlaybackProgress *Gif::videoPlayback() const { return ::Media::Player::instance()->roundVideoPlayback(_parent->data()); } -// #TODO video -//void Gif::clipCallback(::Media::Clip::Notification notification) { -// using namespace ::Media::Clip; -// -// const auto reader = _gif.get(); -// if (!reader) { -// return; -// } -// switch (notification) { -// case NotificationReinit: { -// auto stopped = false; -// if (reader->autoPausedGif()) { -// auto amVisible = false; -// history()->owner().queryItemVisibility().notify( -// { _parent->data(), &amVisible }, -// true); -// if (!amVisible) { // Stop animation if it is not visible. -// stopAnimation(); -// stopped = true; -// } -// } -// if (!stopped) { -// history()->owner().requestViewResize(_parent); -// } -// } break; -// -// case NotificationRepaint: { -// if (!reader->currentDisplayed()) { -// history()->owner().requestViewRepaint(_parent); -// } -// } break; -// } -//} void Gif::playAnimation(bool autoplay) { if (_data->isVideoMessage() && !autoplay) { diff --git a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp index da38dd32f..d0c03a195 100644 --- a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp +++ b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp @@ -2755,7 +2755,9 @@ void OverlayWidget::paintTransformedVideoFrame(Painter &p) { if (rotation) { p.restore(); } - _streamed->instance.markFrameShown(); + if (_streamed->instance.player().ready()) { + _streamed->instance.markFrameShown(); + } //} }