From c7b1683f6e17f11ef1aa9c373c0588faa3425209 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 4 Jun 2019 18:59:26 +0300 Subject: [PATCH] Beta version 1.7.4: Use loadedInMediaCache for songs. --- .../media/player/media_player_instance.cpp | 8 +++++++- .../media/view/media_view_overlay_widget.cpp | 1 + Telegram/SourceFiles/overview/overview_layout.cpp | 11 ++++++++--- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Telegram/SourceFiles/media/player/media_player_instance.cpp b/Telegram/SourceFiles/media/player/media_player_instance.cpp index 2a243e6c50..8be0b6e70b 100644 --- a/Telegram/SourceFiles/media/player/media_player_instance.cpp +++ b/Telegram/SourceFiles/media/player/media_player_instance.cpp @@ -395,10 +395,16 @@ void Instance::playStreamed( data->streamed->player.updates( ) | rpl::start_with_next_error([=](Streaming::Update &&update) { handleStreamingUpdate(data, std::move(update)); - }, [=](Streaming::Error && error) { + }, [=](Streaming::Error &&error) { handleStreamingError(data, std::move(error)); }, data->streamed->player.lifetime()); + data->streamed->player.fullInCache( + ) | rpl::start_with_next([=](bool fullInCache) { + const auto document = data->streamed->id.audio(); + document->setLoadedInMediaCache(fullInCache); + }, data->streamed->player.lifetime()); + data->streamed->player.play(streamingOptions(audioId)); emitUpdate(audioId.type()); diff --git a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp index 5a398f8a19..19d14e4fbd 100644 --- a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp +++ b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp @@ -1986,6 +1986,7 @@ void OverlayWidget::initStreaming() { createStreamingObjects(); Core::App().updateNonIdle(); + _streamed->player.updates( ) | rpl::start_with_next_error([=](Streaming::Update &&update) { handleStreamingUpdate(std::move(update)); diff --git a/Telegram/SourceFiles/overview/overview_layout.cpp b/Telegram/SourceFiles/overview/overview_layout.cpp index 1e7fca3177..24e20c0350 100644 --- a/Telegram/SourceFiles/overview/overview_layout.cpp +++ b/Telegram/SourceFiles/overview/overview_layout.cpp @@ -1088,7 +1088,9 @@ void Document::paint(Painter &p, const QRect &clip, TextSelection selection, con } void Document::drawCornerDownload(Painter &p, bool selected, const PaintContext *context) const { - if (_data->loaded() || !downloadInCorner()) { + if (_data->loaded() + || _data->loadedInMediaCache() + || !downloadInCorner()) { return; } const auto size = st::overviewSmallCheck.size; @@ -1124,7 +1126,9 @@ TextState Document::cornerDownloadTextState( QPoint point, StateRequest request) const { auto result = TextState(parent()); - if (!downloadInCorner() || _data->loaded()) { + if (!downloadInCorner() + || _data->loaded() + || _data->loadedInMediaCache()) { return result; } const auto size = st::overviewSmallCheck.size; @@ -1163,7 +1167,8 @@ TextState Document::getState( _st.songThumbSize, _width); if (inner.contains(point)) { - const auto link = (_data->loading() || _data->uploading()) + const auto link = (!downloadInCorner() + && (_data->loading() || _data->uploading())) ? _cancell : (loaded || _data->canBePlayed()) ? _openl