mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-14 21:27:07 +02:00
Start video from required timestamp.
This commit is contained in:
parent
cb03d5a9d3
commit
141a291523
5 changed files with 54 additions and 31 deletions
|
@ -1206,6 +1206,8 @@ PRIVATE
|
||||||
media/streaming/media_streaming_video_track.h
|
media/streaming/media_streaming_video_track.h
|
||||||
media/view/media_view_group_thumbs.cpp
|
media/view/media_view_group_thumbs.cpp
|
||||||
media/view/media_view_group_thumbs.h
|
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.cpp
|
||||||
media/view/media_view_overlay_opengl.h
|
media/view/media_view_overlay_opengl.h
|
||||||
media/view/media_view_overlay_raster.cpp
|
media/view/media_view_overlay_raster.cpp
|
||||||
|
@ -1224,7 +1226,6 @@ PRIVATE
|
||||||
media/view/media_view_playback_controls.h
|
media/view/media_view_playback_controls.h
|
||||||
media/view/media_view_playback_progress.cpp
|
media/view/media_view_playback_progress.cpp
|
||||||
media/view/media_view_playback_progress.h
|
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.h
|
||||||
media/system_media_controls_manager.cpp
|
media/system_media_controls_manager.cpp
|
||||||
menu/menu_antispam_validator.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_instance.h"
|
||||||
#include "media/streaming/media_streaming_player.h"
|
#include "media/streaming/media_streaming_player.h"
|
||||||
#include "media/streaming/media_streaming_utility.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 "media/view/media_view_playback_progress.h"
|
||||||
#include "ui/boxes/confirm_box.h"
|
#include "ui/boxes/confirm_box.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
|
@ -135,18 +136,6 @@ Gif::Streamed::Streamed(
|
||||||
&& parent->data()->media()->ttlSeconds();
|
&& 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(
|
Gif::Gif(
|
||||||
not_null<Element*> parent,
|
not_null<Element*> parent,
|
||||||
not_null<HistoryItem*> realParent,
|
not_null<HistoryItem*> realParent,
|
||||||
|
@ -163,7 +152,7 @@ Gif::Gif(
|
||||||
? std::make_unique<MediaSpoiler>()
|
? std::make_unique<MediaSpoiler>()
|
||||||
: nullptr)
|
: nullptr)
|
||||||
, _downloadSize(Ui::FormatSizeText(_data->size))
|
, _downloadSize(Ui::FormatSizeText(_data->size))
|
||||||
, _videoTimestamp(ExtractVideoTimestamp(realParent))
|
, _videoTimestamp(::Media::View::ExtractVideoTimestamp(realParent))
|
||||||
, _sensitiveSpoiler(realParent->isMediaSensitive())
|
, _sensitiveSpoiler(realParent->isMediaSensitive())
|
||||||
, _hasVideoCover(realParent->media() && realParent->media()->videoCover()) {
|
, _hasVideoCover(realParent->media() && realParent->media()->videoCover()) {
|
||||||
if (_data->isVideoMessage() && _parent->data()->media()->ttlSeconds()) {
|
if (_data->isVideoMessage() && _parent->data()->media()->ttlSeconds()) {
|
||||||
|
@ -889,21 +878,19 @@ void Gif::paintTimestampMark(
|
||||||
if (_videoTimestamp <= 0) {
|
if (_videoTimestamp <= 0) {
|
||||||
return;
|
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) {
|
const auto convert = [](Ui::BubbleCornerRounding rounding) {
|
||||||
return (rounding == Ui::BubbleCornerRounding::Small)
|
return (rounding == Ui::BubbleCornerRounding::Small)
|
||||||
? st::roundRadiusSmall
|
? Ui::BubbleRadiusSmall()
|
||||||
: (rounding == Ui::BubbleCornerRounding::Large)
|
: (rounding == Ui::BubbleCornerRounding::Large)
|
||||||
? st::roundRadiusLarge
|
? Ui::BubbleRadiusLarge()
|
||||||
: 0;
|
: 0;
|
||||||
};
|
};
|
||||||
const auto radiusl = convert(roundingLeft);
|
const auto radiusl = rounding
|
||||||
const auto radiusr = convert(roundingRight);
|
? convert(rounding->bottomLeft)
|
||||||
|
: st::roundRadiusSmall;
|
||||||
|
const auto radiusr = rounding
|
||||||
|
? convert(rounding->bottomRight)
|
||||||
|
: st::roundRadiusSmall;
|
||||||
const auto line = st::historyVideoTimestampProgressLine;
|
const auto line = st::historyVideoTimestampProgressLine;
|
||||||
const auto duration = _data->duration() / 1000;
|
const auto duration = _data->duration() / 1000;
|
||||||
if (rthumb.height() <= line
|
if (rthumb.height() <= line
|
||||||
|
@ -924,9 +911,9 @@ void Gif::paintTimestampMark(
|
||||||
p.setClipRect(rthumb.x(), top, edge, line);
|
p.setClipRect(rthumb.x(), top, edge, line);
|
||||||
p.drawRoundedRect(
|
p.drawRoundedRect(
|
||||||
rthumb.x(),
|
rthumb.x(),
|
||||||
top - radiusl,
|
top - 2 * radiusl,
|
||||||
edge + radiusl,
|
edge + radiusl,
|
||||||
line + radiusl,
|
line + 2 * radiusl,
|
||||||
radiusl,
|
radiusl,
|
||||||
radiusl);
|
radiusl);
|
||||||
}
|
}
|
||||||
|
@ -936,10 +923,11 @@ void Gif::paintTimestampMark(
|
||||||
p.setClipRect(left, top, width, line);
|
p.setClipRect(left, top, width, line);
|
||||||
p.drawRoundedRect(
|
p.drawRoundedRect(
|
||||||
left - radiusr,
|
left - radiusr,
|
||||||
top - radiusr,
|
top - 2 * radiusr,
|
||||||
width + radiusr,
|
width + radiusr,
|
||||||
line + radiusr,
|
line + 2 * radiusr,
|
||||||
radiusr, radiusr);
|
radiusr,
|
||||||
|
radiusr);
|
||||||
}
|
}
|
||||||
p.restore();
|
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
|
} // namespace Media::View
|
||||||
|
|
|
@ -49,6 +49,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_chat_filters.h"
|
#include "data/data_chat_filters.h"
|
||||||
#include "data/data_replies_list.h"
|
#include "data/data_replies_list.h"
|
||||||
#include "data/data_peer_values.h"
|
#include "data/data_peer_values.h"
|
||||||
|
#include "data/data_web_page.h"
|
||||||
#include "passport/passport_form_controller.h"
|
#include "passport/passport_form_controller.h"
|
||||||
#include "chat_helpers/tabbed_selector.h"
|
#include "chat_helpers/tabbed_selector.h"
|
||||||
#include "chat_helpers/emoji_interactions.h"
|
#include "chat_helpers/emoji_interactions.h"
|
||||||
|
@ -2784,11 +2785,14 @@ void SessionController::openDocument(
|
||||||
if (openSharedStory(item) || openFakeItemStory(message.id, stories)) {
|
if (openSharedStory(item) || openFakeItemStory(message.id, stories)) {
|
||||||
return;
|
return;
|
||||||
} else if (showInMediaView) {
|
} else if (showInMediaView) {
|
||||||
_window->openInMediaView(Media::View::OpenRequest(
|
using namespace Media::View;
|
||||||
|
_window->openInMediaView(OpenRequest(
|
||||||
this,
|
this,
|
||||||
document,
|
document,
|
||||||
item,
|
item,
|
||||||
message.topicRootId));
|
message.topicRootId,
|
||||||
|
false,
|
||||||
|
(item ? ExtractVideoTimestamp(item) : 0) * crl::time(1000)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Data::ResolveDocument(this, document, item, message.topicRootId);
|
Data::ResolveDocument(this, document, item, message.topicRootId);
|
||||||
|
|
Loading…
Add table
Reference in a new issue