mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Show first frame of webm in photo editor.
This commit is contained in:
parent
b4eb25de58
commit
a6621233d0
2 changed files with 27 additions and 3 deletions
|
@ -34,9 +34,9 @@ ItemSticker::ItemSticker(
|
||||||
}
|
}
|
||||||
const auto updateThumbnail = [=] {
|
const auto updateThumbnail = [=] {
|
||||||
const auto guard = gsl::finally([&] {
|
const auto guard = gsl::finally([&] {
|
||||||
setAspectRatio(_pixmap.isNull()
|
if (_pixmap.isNull()) {
|
||||||
? 1.0
|
setAspectRatio(1.);
|
||||||
: (_pixmap.height() / float64(_pixmap.width())));
|
}
|
||||||
});
|
});
|
||||||
if (stickerData->isLottie()) {
|
if (stickerData->isLottie()) {
|
||||||
_lottie.player = ChatHelpers::LottiePlayerFromDocument(
|
_lottie.player = ChatHelpers::LottiePlayerFromDocument(
|
||||||
|
@ -54,6 +54,25 @@ ItemSticker::ItemSticker(
|
||||||
update();
|
update();
|
||||||
}, _lottie.lifetime);
|
}, _lottie.lifetime);
|
||||||
return true;
|
return true;
|
||||||
|
} else if (stickerData->isWebm()
|
||||||
|
&& !_document->dimensions.isEmpty()) {
|
||||||
|
const auto callback = [=](::Media::Clip::Notification) {
|
||||||
|
const auto size = _document->dimensions;
|
||||||
|
if (_webm && _webm->ready() && !_webm->started()) {
|
||||||
|
_webm->start({ .frame = size, .keepAlpha = true });
|
||||||
|
}
|
||||||
|
if (_webm && _webm->started()) {
|
||||||
|
updatePixmap(_webm->current(
|
||||||
|
{ .frame = size, .keepAlpha = true },
|
||||||
|
0));
|
||||||
|
_webm = nullptr;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
_webm = ::Media::Clip::MakeReader(
|
||||||
|
_mediaView->owner()->location(),
|
||||||
|
_mediaView->bytes(),
|
||||||
|
callback);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
const auto sticker = _mediaView->getStickerLarge();
|
const auto sticker = _mediaView->getStickerLarge();
|
||||||
if (!sticker) {
|
if (!sticker) {
|
||||||
|
@ -83,6 +102,9 @@ void ItemSticker::updatePixmap(QPixmap &&pixmap) {
|
||||||
} else {
|
} else {
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
if (!_pixmap.isNull()) {
|
||||||
|
setAspectRatio(_pixmap.height() / float64(_pixmap.width()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemSticker::paint(
|
void ItemSticker::paint(
|
||||||
|
|
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "editor/scene/scene_item_base.h"
|
#include "editor/scene/scene_item_base.h"
|
||||||
|
#include "media/clip/media_clip_reader.h"
|
||||||
|
|
||||||
namespace Data {
|
namespace Data {
|
||||||
class DocumentMedia;
|
class DocumentMedia;
|
||||||
|
@ -47,6 +48,7 @@ private:
|
||||||
std::unique_ptr<Lottie::SinglePlayer> player;
|
std::unique_ptr<Lottie::SinglePlayer> player;
|
||||||
rpl::lifetime lifetime;
|
rpl::lifetime lifetime;
|
||||||
} _lottie;
|
} _lottie;
|
||||||
|
::Media::Clip::ReaderPointer _webm;
|
||||||
QPixmap _pixmap;
|
QPixmap _pixmap;
|
||||||
|
|
||||||
rpl::lifetime _loadingLifetime;
|
rpl::lifetime _loadingLifetime;
|
||||||
|
|
Loading…
Add table
Reference in a new issue