From 5480a63bebfb6ec4eebd6825c5685c4d2e2c16a6 Mon Sep 17 00:00:00 2001 From: John Preston Date: Sun, 2 Apr 2017 19:42:18 +0300 Subject: [PATCH] Support round video inline playback with sound. --- Telegram/Resources/icons/volume_mute.png | Bin 0 -> 147 bytes Telegram/Resources/icons/volume_mute@2x.png | Bin 0 -> 206 bytes Telegram/SourceFiles/history/history.style | 4 + Telegram/SourceFiles/history/history_item.cpp | 9 +- .../history/history_media_types.cpp | 80 +++++++++++++----- .../SourceFiles/history/history_media_types.h | 8 ++ .../SourceFiles/history/history_message.cpp | 5 +- .../inline_bot_layout_internal.cpp | 4 +- Telegram/SourceFiles/mediaview.cpp | 48 +++++++---- Telegram/SourceFiles/mediaview.h | 1 + Telegram/SourceFiles/structs.cpp | 8 +- Telegram/SourceFiles/ui/animation.h | 5 ++ 12 files changed, 122 insertions(+), 50 deletions(-) create mode 100644 Telegram/Resources/icons/volume_mute.png create mode 100644 Telegram/Resources/icons/volume_mute@2x.png diff --git a/Telegram/Resources/icons/volume_mute.png b/Telegram/Resources/icons/volume_mute.png new file mode 100644 index 0000000000000000000000000000000000000000..ed5e60219c8a756b10b39f7a6ef4a029d34be042 GIT binary patch literal 147 zcmeAS@N?(olHy`uVBq!ia0vp^{2(?58;~rMGjRk`QJyZ2AsQ3cUW(>ApuppDarb}I zGe&>s*Liqv*y`)SDrj>22S-DBZBOFu+ok&wB;6wpY1bUxexjYt*k=->_pHy6HBA=F wKJIdSd1LJv!^fr1uVw%Lb^a~a>1*E@gV&$2Z_nSm5NHd7r>mdKI;Vst0J;h~3;+NC literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/volume_mute@2x.png b/Telegram/Resources/icons/volume_mute@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..b918f694c6b7589846dea5473f27e2cdf7b9bb65 GIT binary patch literal 206 zcmV;<05SiGP)&Ihz<#)n8gK6XZdd~Vx^>%O?_9iDV89k$r~Z;t!PxPUR3AHB z4Um1E+y_KATAictMEU6_5yfe+hg0DZPKPZ#1@7T#u*PS{-l%z|#TAZK;{X5v07*qo IM6N<$g2BmBaR2}S literal 0 HcmV?d00001 diff --git a/Telegram/SourceFiles/history/history.style b/Telegram/SourceFiles/history/history.style index 1f82cc9c7e..e3305cc9df 100644 --- a/Telegram/SourceFiles/history/history.style +++ b/Telegram/SourceFiles/history/history.style @@ -418,3 +418,7 @@ msgWaveformBar: 2px; msgWaveformSkip: 1px; msgWaveformMin: 2px; msgWaveformMax: 20px; + +historyVideoMessageMute: icon {{ "volume_mute", historyFileThumbIconFg }}; +historyVideoMessageMuteSelected: icon {{ "volume_mute", historyFileThumbIconFgSelected }}; +historyVideoMessageMuteSize: 25px; diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index 2cfb69462d..3cc255e10a 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -892,17 +892,20 @@ void HistoryItem::clipCallback(Media::Clip::Notification notification) { switch (notification) { case NotificationReinit: { - bool stopped = false; + auto stopped = false; if (reader->autoPausedGif()) { - if (MainWidget *m = App::main()) { + if (auto m = App::main()) { if (!m->isItemVisible(this)) { // stop animation if it is not visible media->stopInline(); - if (DocumentData *document = media->getDocument()) { // forget data from memory + if (auto document = media->getDocument()) { // forget data from memory document->forget(); } stopped = true; } } + } else if (reader->mode() == Media::Clip::Reader::Mode::Video && reader->state() == Media::Clip::State::Finished) { + // Stop finished video message. + media->stopInline(); } if (!stopped) { setPendingInitDimensions(); diff --git a/Telegram/SourceFiles/history/history_media_types.cpp b/Telegram/SourceFiles/history/history_media_types.cpp index 1e8d7352b8..55531f6c10 100644 --- a/Telegram/SourceFiles/history/history_media_types.cpp +++ b/Telegram/SourceFiles/history/history_media_types.cpp @@ -1653,7 +1653,7 @@ HistoryGif::HistoryGif(HistoryItem *parent, DocumentData *document, const QStrin setStatusSize(FileStatusSizeReady); - if (!caption.isEmpty()) { + if (!caption.isEmpty() && !_data->isRoundVideo()) { _caption.setText(st::messageTextStyle, caption + _parent->skipBlock(), itemTextNoMonoOptions(_parent)); } @@ -1681,8 +1681,7 @@ void HistoryGif::initDimensions() { if (!_gif->autoplay()) { Ui::show(Box(lang(lng_gif_error))); } - App::unregGifItem(_gif.get()); - _gif.setBad(); + setClipReader(Media::Clip::ReaderPointer::Bad()); } if (_gif && _gif->ready()) { @@ -1797,10 +1796,12 @@ void HistoryGif::draw(Painter &p, const QRect &r, TextSelection selection, TimeM if (_width < st::msgPadding.left() + st::msgPadding.right() + 1) return; _data->automaticLoad(_parent); - bool loaded = _data->loaded(), displayLoading = (_parent->id < 0) || _data->displayLoading(); - bool selected = (selection == FullSelection); + auto loaded = _data->loaded(); + auto displayLoading = (_parent->id < 0) || _data->displayLoading(); + auto selected = (selection == FullSelection); - if (loaded && !_gif && !_gif.isBad() && cAutoPlayGif()) { + auto videoFinished = _gif && (_gif->mode() == Media::Clip::Reader::Mode::Video) && (_gif->state() == Media::Clip::State::Finished); + if (loaded && cAutoPlayGif() && ((!_gif && !_gif.isBad()) || videoFinished)) { Ui::autoplayMediaInlineAsync(_parent->fullId()); } @@ -1811,6 +1812,7 @@ void HistoryGif::draw(Painter &p, const QRect &r, TextSelection selection, TimeM auto captionw = width - st::msgPadding.left() - st::msgPadding.right(); auto isRound = _data->isRoundVideo(); + auto displayMute = false; auto animating = (_gif && _gif->started()); if (!animating || _parent->id < 0) { @@ -1848,6 +1850,13 @@ void HistoryGif::draw(Painter &p, const QRect &r, TextSelection selection, TimeM | ((isBubbleBottom() && _caption.isEmpty()) ? (ImageRoundCorner::BottomLeft | ImageRoundCorner::BottomRight) : ImageRoundCorner::None)); if (animating) { auto paused = App::wnd()->controller()->isGifPausedAtLeastFor(Window::GifPauseReason::Any); + if (isRound) { + if (_gif->mode() == Media::Clip::Reader::Mode::Video) { + paused = false; + } else { + displayMute = true; + } + } p.drawPixmap(rthumb.topLeft(), _gif->current(_thumbw, _thumbh, width, height, roundRadius, roundCorners, paused ? 0 : ms)); } else { p.drawPixmap(rthumb.topLeft(), _data->thumb->pixBlurredSingle(_thumbw, _thumbh, width, height, roundRadius, roundCorners)); @@ -1857,8 +1866,8 @@ void HistoryGif::draw(Painter &p, const QRect &r, TextSelection selection, TimeM } if (radial || _gif.isBad() || (!_gif && ((!loaded && !_data->loading()) || !cAutoPlayGif()))) { - float64 radialOpacity = (radial && loaded && _parent->id > 0) ? _animation->radial.opacity() : 1; - QRect inner(rthumb.x() + (rthumb.width() - st::msgFileSize) / 2, rthumb.y() + (rthumb.height() - st::msgFileSize) / 2, st::msgFileSize, st::msgFileSize); + auto radialOpacity = (radial && loaded && _parent->id > 0) ? _animation->radial.opacity() : 1.; + auto inner = QRect(rthumb.x() + (rthumb.width() - st::msgFileSize) / 2, rthumb.y() + (rthumb.height() - st::msgFileSize) / 2, st::msgFileSize, st::msgFileSize); p.setPen(Qt::NoPen); if (selected) { p.setBrush(st::msgDateImgBgSelected); @@ -1908,13 +1917,21 @@ void HistoryGif::draw(Painter &p, const QRect &r, TextSelection selection, TimeM p.drawTextLeft(statusX, statusY, _width, _statusText, statusW - 2 * st::msgDateImgPadding.x()); } } + if (displayMute) { + auto muteRect = rtlrect(rthumb.x() + (rthumb.width() - st::historyVideoMessageMuteSize) / 2, rthumb.y() + rthumb.height() - st::msgDateImgDelta - st::historyVideoMessageMuteSize, st::historyVideoMessageMuteSize, st::historyVideoMessageMuteSize, _width); + p.setPen(Qt::NoPen); + p.setBrush(selected ? st::msgDateImgBgSelected : st::msgDateImgBg); + PainterHighQualityEnabler hq(p); + p.drawEllipse(muteRect); + (selected ? st::historyVideoMessageMuteSelected : st::historyVideoMessageMute).paintInCenter(p, muteRect); + } if (isRound) { auto mediaUnread = _parent->isMediaUnread(); auto statusW = st::normalFont->width(_statusText) + 2 * st::msgDateImgPadding.x(); auto statusH = st::normalFont->height + 2 * st::msgDateImgPadding.y(); auto statusX = skipx + st::msgDateImgDelta + st::msgDateImgPadding.x(); - auto statusY = skipy + height - st::msgDateImgDelta - statusH; + auto statusY = skipy + height - st::msgDateImgDelta - statusH + st::msgDateImgPadding.y(); if (_parent->isMediaUnread()) { statusW += st::mediaUnreadSkip + st::mediaUnreadSize; } @@ -1970,7 +1987,7 @@ HistoryTextState HistoryGif::getState(int x, int y, HistoryStateRequest request) if (x >= skipx && y >= skipy && x < skipx + width && y < skipy + height) { if (_data->uploading()) { result.link = _cancell; - } else if (!_gif || !cAutoPlayGif()) { + } else if (!_gif || !cAutoPlayGif() || _data->isRoundVideo()) { result.link = _data->loaded() ? _openl : (_data->loading() ? _cancell : _savel); } if (_parent->getMedia() == this) { @@ -2047,35 +2064,56 @@ ImagePtr HistoryGif::replyPreview() { } bool HistoryGif::playInline(bool autoplay) { + using Mode = Media::Clip::Reader::Mode; + if (_data->isRoundVideo() && _gif) { + // Stop autoplayed silent video when we start playback by click. + // Stop finished video message when autoplay starts. + if ((!autoplay && _gif->mode() == Mode::Gif) + || (autoplay && _gif->mode() == Mode::Video && _gif->state() == Media::Clip::State::Finished)) { + stopInline(); + } + } if (_gif) { stopInline(); } else if (_data->loaded(DocumentData::FilePathResolveChecked)) { if (!cAutoPlayGif()) { App::stopGifItems(); } - _gif = Media::Clip::MakeReader(_data->location(), _data->data(), [this](Media::Clip::Notification notification) { + auto mode = (!autoplay && _data->isRoundVideo()) ? Mode::Video : Mode::Gif; + setClipReader(Media::Clip::MakeReader(_data->location(), _data->data(), [this](Media::Clip::Notification notification) { _parent->clipCallback(notification); - }); - App::regGifItem(_gif.get(), _parent); - if (_gif) _gif->setAutoplay(); + }, mode)); + if (mode == Mode::Video) { + if (App::main()) { + App::main()->mediaMarkRead(_data); + } + } + if (_gif && autoplay) { + _gif->setAutoplay(); + } } return true; } void HistoryGif::stopInline() { - if (_gif) { - App::unregGifItem(_gif.get()); - } - _gif.reset(); + clearClipReader(); _parent->setPendingInitDimensions(); Notify::historyItemLayoutChanged(_parent); } -HistoryGif::~HistoryGif() { +void HistoryGif::setClipReader(Media::Clip::ReaderPointer gif) { if (_gif) { App::unregGifItem(_gif.get()); } + _gif = std::move(gif); + if (_gif) { + App::regGifItem(_gif.get(), _parent); + } +} + +HistoryGif::~HistoryGif() { + clearClipReader(); } float64 HistoryGif::dataProgress() const { @@ -2099,10 +2137,6 @@ HistorySticker::HistorySticker(HistoryItem *parent, DocumentData *document) : Hi } } -class TestClickHandler : public ClickHandler { - -}; - void HistorySticker::initDimensions() { auto sticker = _data->sticker(); diff --git a/Telegram/SourceFiles/history/history_media_types.h b/Telegram/SourceFiles/history/history_media_types.h index 3339aaf264..d680201f61 100644 --- a/Telegram/SourceFiles/history/history_media_types.h +++ b/Telegram/SourceFiles/history/history_media_types.h @@ -515,6 +515,9 @@ public: return _caption.originalTextWithEntities(); } bool needsBubble() const override { + if (_data->isRoundVideo()) { + return false; + } if (!_caption.isEmpty()) { return true; } @@ -546,6 +549,11 @@ protected: bool dataFinished() const override; bool dataLoaded() const override; + void setClipReader(Media::Clip::ReaderPointer gif); + void clearClipReader() { + setClipReader(Media::Clip::ReaderPointer()); + } + private: gsl::not_null _data; int32 _thumbw = 1; diff --git a/Telegram/SourceFiles/history/history_message.cpp b/Telegram/SourceFiles/history/history_message.cpp index c2d2be925f..e2d44b2183 100644 --- a/Telegram/SourceFiles/history/history_message.cpp +++ b/Telegram/SourceFiles/history/history_message.cpp @@ -54,7 +54,10 @@ MediaOverviewType messageMediaToOverviewType(HistoryMedia *media) { case MediaTypeFile: return OverviewFiles; case MediaTypeMusicFile: return media->getDocument()->isMusic() ? OverviewMusicFiles : OverviewCount; case MediaTypeVoiceFile: return OverviewVoiceFiles; - case MediaTypeGif: return media->getDocument()->isGifv() ? OverviewCount : OverviewFiles; + case MediaTypeGif: { + auto document = media->getDocument(); + return (document->isGifv() || document->isRoundVideo()) ? OverviewCount : OverviewFiles; + } break; default: break; } return OverviewCount; diff --git a/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.cpp b/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.cpp index ce8e5107bd..89bf26fa3b 100644 --- a/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.cpp +++ b/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.cpp @@ -338,8 +338,8 @@ void Gif::clipCallback(Media::Clip::Notification notification) { _gif.setBad(); getShownDocument()->forget(); } else if (_gif->ready() && !_gif->started()) { - int32 height = st::inlineMediaHeight; - QSize frame = countFrameSize(); + auto height = st::inlineMediaHeight; + auto frame = countFrameSize(); _gif->start(frame.width(), frame.height(), _width, height, ImageRoundRadius::None, ImageRoundCorner::None); } else if (_gif->autoPausedGif() && !context()->inlineItemVisible(this)) { _gif.reset(); diff --git a/Telegram/SourceFiles/mediaview.cpp b/Telegram/SourceFiles/mediaview.cpp index 0a77752375..6f06a1eb77 100644 --- a/Telegram/SourceFiles/mediaview.cpp +++ b/Telegram/SourceFiles/mediaview.cpp @@ -222,11 +222,12 @@ bool MediaView::fileBubbleShown() const { bool MediaView::gifShown() const { if (_gif && _gif->ready()) { if (!_gif->started()) { - if (_doc->isVideo() && _autoplayVideoDocument != _doc && !_gif->videoPaused()) { + if ((_doc->isVideo() || _doc->isRoundVideo()) && _autoplayVideoDocument != _doc && !_gif->videoPaused()) { _gif->pauseResumeVideo(); const_cast(this)->_videoPaused = _gif->videoPaused(); } - _gif->start(_gif->width() / cIntRetinaFactor(), _gif->height() / cIntRetinaFactor(), _gif->width() / cIntRetinaFactor(), _gif->height() / cIntRetinaFactor(), ImageRoundRadius::None, ImageRoundCorner::None); + auto rounding = _doc->isRoundVideo() ? ImageRoundRadius::Ellipse : ImageRoundRadius::None; + _gif->start(_gif->width() / cIntRetinaFactor(), _gif->height() / cIntRetinaFactor(), _gif->width() / cIntRetinaFactor(), _gif->height() / cIntRetinaFactor(), rounding, ImageRoundCorner::All); const_cast(this)->_current = QPixmap(); } return true;// _gif->state() != Media::Clip::State::Error; @@ -522,7 +523,7 @@ void MediaView::step_radial(TimeMs ms, bool timer) { update(radialRect()); } if (_doc && _doc->loaded() && _doc->size < App::kImageSizeLimit && (!_radial.animating() || _doc->isAnimation() || _doc->isVideo())) { - if (_doc->isVideo()) { + if (_doc->isVideo() || _doc->isRoundVideo()) { _autoplayVideoDocument = _doc; } if (!_doc->data().isEmpty() && (_doc->isAnimation() || _doc->isVideo())) { @@ -828,7 +829,7 @@ void MediaView::clipCallback(Media::Clip::Notification notification) { _videoStopped = true; updateSilentVideoPlaybackState(); } else { - _videoIsSilent = _doc->isVideo() && !_gif->hasAudio(); + _videoIsSilent = (_doc->isVideo() || _doc->isRoundVideo()) && !_gif->hasAudio(); _videoDurationMs = _gif->getDurationMs(); _videoPositionMs = _gif->getPositionMs(); if (_videoIsSilent) { @@ -1140,7 +1141,7 @@ void MediaView::showDocument(DocumentData *doc, HistoryItem *context) { _overview = doc->isVideo() ? OverviewVideos : OverviewFiles; findCurrent(); } - if (doc->isVideo()) { + if (doc->isVideo() || doc->isRoundVideo()) { _autoplayVideoDocument = doc; } displayDocument(doc, context); @@ -1383,6 +1384,14 @@ void MediaView::displayFinished() { } } +Images::Options MediaView::videoThumbOptions() const { + auto options = Images::Option::Smooth | Images::Option::Blurred; + if (_doc->isRoundVideo()) { + options |= Images::Option::Circled; + } + return options; +} + void MediaView::initAnimation() { Expects(_doc != nullptr); Expects(_doc->isAnimation() || _doc->isVideo()); @@ -1394,12 +1403,12 @@ void MediaView::initAnimation() { createClipReader(); location.accessDisable(); } else if (_doc->dimensions.width() && _doc->dimensions.height()) { - int w = _doc->dimensions.width(); - int h = _doc->dimensions.height(); - _current = _doc->thumb->pixNoCache(w, h, Images::Option::Smooth | Images::Option::Blurred, w / cIntRetinaFactor(), h / cIntRetinaFactor()); + auto w = _doc->dimensions.width(); + auto h = _doc->dimensions.height(); + _current = _doc->thumb->pixNoCache(w, h, videoThumbOptions(), w / cIntRetinaFactor(), h / cIntRetinaFactor()); if (cRetina()) _current.setDevicePixelRatio(cRetinaFactor()); } else { - _current = _doc->thumb->pixNoCache(_doc->thumb->width(), _doc->thumb->height(), Images::Option::Smooth | Images::Option::Blurred, st::mediaviewFileIconSize, st::mediaviewFileIconSize); + _current = _doc->thumb->pixNoCache(_doc->thumb->width(), _doc->thumb->height(), videoThumbOptions(), st::mediaviewFileIconSize, st::mediaviewFileIconSize); } } @@ -1412,12 +1421,12 @@ void MediaView::createClipReader() { if (_doc->dimensions.width() && _doc->dimensions.height()) { int w = _doc->dimensions.width(); int h = _doc->dimensions.height(); - _current = _doc->thumb->pixNoCache(w, h, Images::Option::Smooth | Images::Option::Blurred, w / cIntRetinaFactor(), h / cIntRetinaFactor()); + _current = _doc->thumb->pixNoCache(w, h, videoThumbOptions(), w / cIntRetinaFactor(), h / cIntRetinaFactor()); if (cRetina()) _current.setDevicePixelRatio(cRetinaFactor()); } else { - _current = _doc->thumb->pixNoCache(_doc->thumb->width(), _doc->thumb->height(), Images::Option::Smooth | Images::Option::Blurred, st::mediaviewFileIconSize, st::mediaviewFileIconSize); + _current = _doc->thumb->pixNoCache(_doc->thumb->width(), _doc->thumb->height(), videoThumbOptions(), st::mediaviewFileIconSize, st::mediaviewFileIconSize); } - auto mode = _doc->isVideo() ? Media::Clip::Reader::Mode::Video : Media::Clip::Reader::Mode::Gif; + auto mode = (_doc->isVideo() || _doc->isRoundVideo()) ? Media::Clip::Reader::Mode::Video : Media::Clip::Reader::Mode::Gif; _gif = std::make_unique(_doc->location(), _doc->data(), [this](Media::Clip::Notification notification) { clipCallback(notification); }, mode); @@ -1475,7 +1484,7 @@ void MediaView::initThemePreview() { } void MediaView::createClipController() { - if (!_doc->isVideo()) return; + if (!_doc->isVideo() && !_doc->isRoundVideo()) return; _clipController.create(this); setClipControllerGeometry(); @@ -1530,7 +1539,8 @@ void MediaView::restartVideoAtSeekPosition(TimeMs positionMs) { _autoplayVideoDocument = _doc; if (_current.isNull()) { - _current = _gif->current(_gif->width() / cIntRetinaFactor(), _gif->height() / cIntRetinaFactor(), _gif->width() / cIntRetinaFactor(), _gif->height() / cIntRetinaFactor(), ImageRoundRadius::None, ImageRoundCorner::None, getms()); + auto rounding = _doc->isRoundVideo() ? ImageRoundRadius::Ellipse : ImageRoundRadius::None; + _current = _gif->current(_gif->width() / cIntRetinaFactor(), _gif->height() / cIntRetinaFactor(), _gif->width() / cIntRetinaFactor(), _gif->height() / cIntRetinaFactor(), rounding, ImageRoundCorner::All, getms()); } _gif = std::make_unique(_doc->location(), _doc->data(), [this](Media::Clip::Notification notification) { clipCallback(notification); @@ -1638,6 +1648,9 @@ void MediaView::paintEvent(QPaintEvent *e) { for (int i = 0, l = region.rectCount(); i < l; ++i) { p.fillRect(rs.at(i), st::mediaviewVideoBg); } + if (_doc->isRoundVideo()) { + p.setCompositionMode(m); + } } else { for (int i = 0, l = region.rectCount(); i < l; ++i) { p.fillRect(rs.at(i), st::mediaviewBg); @@ -1670,7 +1683,8 @@ void MediaView::paintEvent(QPaintEvent *e) { if (_photo || fileShown()) { QRect imgRect(_x, _y, _w, _h); if (imgRect.intersects(r)) { - auto toDraw = _current.isNull() ? _gif->current(_gif->width() / cIntRetinaFactor(), _gif->height() / cIntRetinaFactor(), _gif->width() / cIntRetinaFactor(), _gif->height() / cIntRetinaFactor(), ImageRoundRadius::None, ImageRoundCorner::None, ms) : _current; + auto rounding = _doc->isRoundVideo() ? ImageRoundRadius::Ellipse : ImageRoundRadius::None; + auto toDraw = _current.isNull() ? _gif->current(_gif->width() / cIntRetinaFactor(), _gif->height() / cIntRetinaFactor(), _gif->width() / cIntRetinaFactor(), _gif->height() / cIntRetinaFactor(), rounding, ImageRoundCorner::None, ms) : _current; if (!_gif && (!_doc || !_doc->sticker() || _doc->sticker()->img->isNull()) && toDraw.hasAlpha()) { p.fillRect(imgRect, _transparentBrush); } @@ -2011,7 +2025,7 @@ void MediaView::keyPressEvent(QKeyEvent *e) { } else if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return || e->key() == Qt::Key_Space) { if (_doc && !_doc->loading() && (fileBubbleShown() || !_doc->loaded())) { onDocClick(); - } else if (_doc && _doc->isVideo()) { + } else if (_doc && (_doc->isVideo() || _doc->isRoundVideo())) { onVideoPauseResume(); } } else if (e->key() == Qt::Key_Left) { @@ -2463,7 +2477,7 @@ void MediaView::updateOver(QPoint pos) { } else if (_closeNav.contains(pos)) { updateOverState(OverClose); } else if (_doc && fileShown() && QRect(_x, _y, _w, _h).contains(pos)) { - if (_doc->isVideo() && _gif) { + if ((_doc->isVideo() || _doc->isRoundVideo()) && _gif) { updateOverState(OverVideo); } else if (!_doc->loaded()) { updateOverState(OverIcon); diff --git a/Telegram/SourceFiles/mediaview.h b/Telegram/SourceFiles/mediaview.h index fd5249c84f..a8532a6d77 100644 --- a/Telegram/SourceFiles/mediaview.h +++ b/Telegram/SourceFiles/mediaview.h @@ -178,6 +178,7 @@ private: void initAnimation(); void createClipReader(); + Images::Options videoThumbOptions() const; void initThemePreview(); void destroyThemePreview(); diff --git a/Telegram/SourceFiles/structs.cpp b/Telegram/SourceFiles/structs.cpp index 2e06681fbe..b5669b0daa 100644 --- a/Telegram/SourceFiles/structs.cpp +++ b/Telegram/SourceFiles/structs.cpp @@ -1205,14 +1205,14 @@ void DocumentOpenClickHandler::doOpen(DocumentData *data, HistoryItem *context, } else if (data->size < App::kImageSizeLimit) { if (!data->data().isEmpty() && playAnimation) { if (action == ActionOnLoadPlayInline && context && context->getMedia()) { - context->getMedia()->playInline(context); + context->getMedia()->playInline(); } else { App::wnd()->showDocument(data, context); } } else if (location.accessEnable()) { if (data->isAnimation() || QImageReader(location.name()).canRead()) { if (action == ActionOnLoadPlayInline && context && context->getMedia()) { - context->getMedia()->playInline(context); + context->getMedia()->playInline(); } else { App::wnd()->showDocument(data, context); } @@ -1485,7 +1485,7 @@ void DocumentData::performActionOnLoad() { } else if (playAnimation) { if (loaded()) { if (_actionOnLoad == ActionOnLoadPlayInline && item->getMedia()) { - item->getMedia()->playInline(item); + item->getMedia()->playInline(); } else { App::wnd()->showDocument(this, item); } @@ -1504,7 +1504,7 @@ void DocumentData::performActionOnLoad() { } else if (loc.accessEnable()) { if (showImage && QImageReader(loc.name()).canRead()) { if (_actionOnLoad == ActionOnLoadPlayInline && item && item->getMedia()) { - item->getMedia()->playInline(item); + item->getMedia()->playInline(); } else { App::wnd()->showDocument(this, item); } diff --git a/Telegram/SourceFiles/ui/animation.h b/Telegram/SourceFiles/ui/animation.h index 5daf405606..39aafc8043 100644 --- a/Telegram/SourceFiles/ui/animation.h +++ b/Telegram/SourceFiles/ui/animation.h @@ -68,6 +68,11 @@ public: explicit operator bool() const { return valid(); } + static inline ReaderPointer Bad() { + ReaderPointer result; + result.setBad(); + return result; + } ~ReaderPointer(); private: