media_view_open_common.cpp 759 B

12345678910111213141516171819202122232425262728
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #include "media/view/media_view_open_common.h"
  8. #include "history/history_item.h"
  9. #include "data/data_media_types.h"
  10. #include "data/data_web_page.h"
  11. namespace Media::View {
  12. TimeId ExtractVideoTimestamp(not_null<HistoryItem*> item) {
  13. const auto media = item->media();
  14. if (!media) {
  15. return 0;
  16. } else if (const auto timestamp = media->videoTimestamp()) {
  17. return timestamp;
  18. } else if (const auto webpage = media->webpage()) {
  19. return webpage->extractVideoTimestamp();
  20. }
  21. return 0;
  22. }
  23. } // namespace Media::View