mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-02-20 23:27:23 +00:00
Start video from required timestamp.
This commit is contained in:
parent
cb03d5a9d3
commit
141a291523
@ -1206,6 +1206,8 @@ PRIVATE
|
||||
media/streaming/media_streaming_video_track.h
|
||||
media/view/media_view_group_thumbs.cpp
|
||||
media/view/media_view_group_thumbs.h
|
||||
media/view/media_view_open_common.cpp
|
||||
media/view/media_view_open_common.h
|
||||
media/view/media_view_overlay_opengl.cpp
|
||||
media/view/media_view_overlay_opengl.h
|
||||
media/view/media_view_overlay_raster.cpp
|
||||
@ -1224,7 +1226,6 @@ PRIVATE
|
||||
media/view/media_view_playback_controls.h
|
||||
media/view/media_view_playback_progress.cpp
|
||||
media/view/media_view_playback_progress.h
|
||||
media/view/media_view_open_common.h
|
||||
media/system_media_controls_manager.h
|
||||
media/system_media_controls_manager.cpp
|
||||
menu/menu_antispam_validator.cpp
|
||||
|
@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "media/streaming/media_streaming_instance.h"
|
||||
#include "media/streaming/media_streaming_player.h"
|
||||
#include "media/streaming/media_streaming_utility.h"
|
||||
#include "media/view/media_view_open_common.h"
|
||||
#include "media/view/media_view_playback_progress.h"
|
||||
#include "ui/boxes/confirm_box.h"
|
||||
#include "ui/painter.h"
|
||||
@ -135,18 +136,6 @@ Gif::Streamed::Streamed(
|
||||
&& parent->data()->media()->ttlSeconds();
|
||||
}
|
||||
|
||||
[[nodiscard]] TimeId ExtractVideoTimestamp(not_null<HistoryItem*> item) {
|
||||
const auto media = item->media();
|
||||
if (!media) {
|
||||
return 0;
|
||||
} else if (const auto timestamp = media->videoTimestamp()) {
|
||||
return timestamp;
|
||||
} else if (const auto webpage = media->webpage()) {
|
||||
return webpage->extractVideoTimestamp();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Gif::Gif(
|
||||
not_null<Element*> parent,
|
||||
not_null<HistoryItem*> realParent,
|
||||
@ -163,7 +152,7 @@ Gif::Gif(
|
||||
? std::make_unique<MediaSpoiler>()
|
||||
: nullptr)
|
||||
, _downloadSize(Ui::FormatSizeText(_data->size))
|
||||
, _videoTimestamp(ExtractVideoTimestamp(realParent))
|
||||
, _videoTimestamp(::Media::View::ExtractVideoTimestamp(realParent))
|
||||
, _sensitiveSpoiler(realParent->isMediaSensitive())
|
||||
, _hasVideoCover(realParent->media() && realParent->media()->videoCover()) {
|
||||
if (_data->isVideoMessage() && _parent->data()->media()->ttlSeconds()) {
|
||||
@ -889,21 +878,19 @@ void Gif::paintTimestampMark(
|
||||
if (_videoTimestamp <= 0) {
|
||||
return;
|
||||
}
|
||||
const auto roundingLeft = rounding
|
||||
? rounding->bottomLeft
|
||||
: Ui::BubbleCornerRounding::Small;
|
||||
const auto roundingRight = rounding
|
||||
? rounding->bottomRight
|
||||
: Ui::BubbleCornerRounding::Small;
|
||||
const auto convert = [](Ui::BubbleCornerRounding rounding) {
|
||||
return (rounding == Ui::BubbleCornerRounding::Small)
|
||||
? st::roundRadiusSmall
|
||||
? Ui::BubbleRadiusSmall()
|
||||
: (rounding == Ui::BubbleCornerRounding::Large)
|
||||
? st::roundRadiusLarge
|
||||
? Ui::BubbleRadiusLarge()
|
||||
: 0;
|
||||
};
|
||||
const auto radiusl = convert(roundingLeft);
|
||||
const auto radiusr = convert(roundingRight);
|
||||
const auto radiusl = rounding
|
||||
? convert(rounding->bottomLeft)
|
||||
: st::roundRadiusSmall;
|
||||
const auto radiusr = rounding
|
||||
? convert(rounding->bottomRight)
|
||||
: st::roundRadiusSmall;
|
||||
const auto line = st::historyVideoTimestampProgressLine;
|
||||
const auto duration = _data->duration() / 1000;
|
||||
if (rthumb.height() <= line
|
||||
@ -924,9 +911,9 @@ void Gif::paintTimestampMark(
|
||||
p.setClipRect(rthumb.x(), top, edge, line);
|
||||
p.drawRoundedRect(
|
||||
rthumb.x(),
|
||||
top - radiusl,
|
||||
top - 2 * radiusl,
|
||||
edge + radiusl,
|
||||
line + radiusl,
|
||||
line + 2 * radiusl,
|
||||
radiusl,
|
||||
radiusl);
|
||||
}
|
||||
@ -936,10 +923,11 @@ void Gif::paintTimestampMark(
|
||||
p.setClipRect(left, top, width, line);
|
||||
p.drawRoundedRect(
|
||||
left - radiusr,
|
||||
top - radiusr,
|
||||
top - 2 * radiusr,
|
||||
width + radiusr,
|
||||
line + radiusr,
|
||||
radiusr, radiusr);
|
||||
line + 2 * radiusr,
|
||||
radiusr,
|
||||
radiusr);
|
||||
}
|
||||
p.restore();
|
||||
}
|
||||
|
28
Telegram/SourceFiles/media/view/media_view_open_common.cpp
Normal file
28
Telegram/SourceFiles/media/view/media_view_open_common.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#include "media/view/media_view_open_common.h"
|
||||
|
||||
#include "history/history_item.h"
|
||||
#include "data/data_media_types.h"
|
||||
#include "data/data_web_page.h"
|
||||
|
||||
namespace Media::View {
|
||||
|
||||
TimeId ExtractVideoTimestamp(not_null<HistoryItem*> item) {
|
||||
const auto media = item->media();
|
||||
if (!media) {
|
||||
return 0;
|
||||
} else if (const auto timestamp = media->videoTimestamp()) {
|
||||
return timestamp;
|
||||
} else if (const auto webpage = media->webpage()) {
|
||||
return webpage->extractVideoTimestamp();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace Media::View
|
@ -135,4 +135,6 @@ private:
|
||||
|
||||
};
|
||||
|
||||
[[nodiscard]] TimeId ExtractVideoTimestamp(not_null<HistoryItem*> item);
|
||||
|
||||
} // namespace Media::View
|
||||
|
@ -49,6 +49,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "data/data_chat_filters.h"
|
||||
#include "data/data_replies_list.h"
|
||||
#include "data/data_peer_values.h"
|
||||
#include "data/data_web_page.h"
|
||||
#include "passport/passport_form_controller.h"
|
||||
#include "chat_helpers/tabbed_selector.h"
|
||||
#include "chat_helpers/emoji_interactions.h"
|
||||
@ -2784,11 +2785,14 @@ void SessionController::openDocument(
|
||||
if (openSharedStory(item) || openFakeItemStory(message.id, stories)) {
|
||||
return;
|
||||
} else if (showInMediaView) {
|
||||
_window->openInMediaView(Media::View::OpenRequest(
|
||||
using namespace Media::View;
|
||||
_window->openInMediaView(OpenRequest(
|
||||
this,
|
||||
document,
|
||||
item,
|
||||
message.topicRootId));
|
||||
message.topicRootId,
|
||||
false,
|
||||
(item ? ExtractVideoTimestamp(item) : 0) * crl::time(1000)));
|
||||
return;
|
||||
}
|
||||
Data::ResolveDocument(this, document, item, message.topicRootId);
|
||||
|
Loading…
Reference in New Issue
Block a user