mirror of https://github.com/procxx/kepka.git
Lock inline HistoryView::Gif when playing fullscreen.
This commit is contained in:
parent
51dac66998
commit
10c810ff03
|
@ -314,9 +314,18 @@ void Gif::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms
|
||||||
request.resize = QSize(_thumbw, _thumbh) * cIntRetinaFactor();
|
request.resize = QSize(_thumbw, _thumbh) * cIntRetinaFactor();
|
||||||
request.corners = roundCorners;
|
request.corners = roundCorners;
|
||||||
request.radius = roundRadius;
|
request.radius = roundRadius;
|
||||||
p.drawImage(rthumb, streamed->frame(request));
|
if (streamed->playerLocked() && !activeRoundPlaying) {
|
||||||
if (!paused) {
|
if (_lockedFrameRequest != request || _lockedFrame.isNull()) {
|
||||||
streamed->markFrameShown();
|
_lockedFrameRequest = request;
|
||||||
|
_lockedFrame = streamed->frame(request);
|
||||||
|
}
|
||||||
|
p.drawImage(rthumb, _lockedFrame);
|
||||||
|
} else {
|
||||||
|
_lockedFrame = QImage();
|
||||||
|
p.drawImage(rthumb, streamed->frame(request));
|
||||||
|
if (!paused) {
|
||||||
|
streamed->markFrameShown();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (const auto playback = videoPlayback()) {
|
if (const auto playback = videoPlayback()) {
|
||||||
|
|
|
@ -8,7 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "history/view/media/history_view_file.h"
|
#include "history/view/media/history_view_file.h"
|
||||||
#include "media/clip/media_clip_reader.h"
|
#include "media/streaming/media_streaming_common.h"
|
||||||
|
|
||||||
struct HistoryMessageVia;
|
struct HistoryMessageVia;
|
||||||
struct HistoryMessageReply;
|
struct HistoryMessageReply;
|
||||||
|
@ -154,6 +154,8 @@ private:
|
||||||
Ui::Text::String _caption;
|
Ui::Text::String _caption;
|
||||||
std::unique_ptr<::Media::Streaming::Instance> _streamed;
|
std::unique_ptr<::Media::Streaming::Instance> _streamed;
|
||||||
|
|
||||||
|
mutable ::Media::Streaming::FrameRequest _lockedFrameRequest;
|
||||||
|
mutable QImage _lockedFrame;
|
||||||
QString _downloadSize;
|
QString _downloadSize;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -36,6 +36,7 @@ Instance::Instance(
|
||||||
|
|
||||||
Instance::~Instance() {
|
Instance::~Instance() {
|
||||||
if (_shared) {
|
if (_shared) {
|
||||||
|
unlockPlayer();
|
||||||
_shared->unregisterInstance(this);
|
_shared->unregisterInstance(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -147,9 +148,35 @@ QImage Instance::frame(const FrameRequest &request) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Instance::markFrameShown() {
|
bool Instance::markFrameShown() {
|
||||||
|
Expects(_shared != nullptr);
|
||||||
|
|
||||||
return _shared->player().markFrameShown();
|
return _shared->player().markFrameShown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Instance::lockPlayer() {
|
||||||
|
Expects(_shared != nullptr);
|
||||||
|
|
||||||
|
if (!_playerLocked) {
|
||||||
|
_playerLocked = true;
|
||||||
|
_shared->player().lock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Instance::unlockPlayer() {
|
||||||
|
Expects(_shared != nullptr);
|
||||||
|
|
||||||
|
if (_playerLocked) {
|
||||||
|
_playerLocked = false;
|
||||||
|
_shared->player().unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Instance::playerLocked() const {
|
||||||
|
Expects(_shared != nullptr);
|
||||||
|
|
||||||
|
return _shared->player().locked();
|
||||||
|
}
|
||||||
|
|
||||||
rpl::lifetime &Instance::lifetime() {
|
rpl::lifetime &Instance::lifetime() {
|
||||||
return _lifetime;
|
return _lifetime;
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,11 +63,16 @@ public:
|
||||||
[[nodiscard]] QImage frame(const FrameRequest &request) const;
|
[[nodiscard]] QImage frame(const FrameRequest &request) const;
|
||||||
bool markFrameShown();
|
bool markFrameShown();
|
||||||
|
|
||||||
|
void lockPlayer();
|
||||||
|
void unlockPlayer();
|
||||||
|
[[nodiscard]] bool playerLocked() const;
|
||||||
|
|
||||||
[[nodiscard]] rpl::lifetime &lifetime();
|
[[nodiscard]] rpl::lifetime &lifetime();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const std::shared_ptr<Document> _shared;
|
const std::shared_ptr<Document> _shared;
|
||||||
Fn<void()> _waitingCallback;
|
Fn<void()> _waitingCallback;
|
||||||
|
bool _playerLocked = false;
|
||||||
rpl::lifetime _lifetime;
|
rpl::lifetime _lifetime;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -883,6 +883,20 @@ crl::time Player::getCurrentReceivedTill(crl::time duration) const {
|
||||||
: result;
|
: result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Player::lock() {
|
||||||
|
++_locks;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::unlock() {
|
||||||
|
Expects(_locks > 0);
|
||||||
|
|
||||||
|
--_locks;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Player::locked() const {
|
||||||
|
return (_locks > 0);
|
||||||
|
}
|
||||||
|
|
||||||
rpl::lifetime &Player::lifetime() {
|
rpl::lifetime &Player::lifetime() {
|
||||||
return _lifetime;
|
return _lifetime;
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,6 +69,10 @@ public:
|
||||||
|
|
||||||
[[nodiscard]] Media::Player::TrackState prepareLegacyState() const;
|
[[nodiscard]] Media::Player::TrackState prepareLegacyState() const;
|
||||||
|
|
||||||
|
void lock();
|
||||||
|
void unlock();
|
||||||
|
[[nodiscard]] bool locked() const;
|
||||||
|
|
||||||
[[nodiscard]] rpl::lifetime &lifetime();
|
[[nodiscard]] rpl::lifetime &lifetime();
|
||||||
|
|
||||||
~Player();
|
~Player();
|
||||||
|
@ -194,6 +198,8 @@ private:
|
||||||
int _durationByLastAudioPacket = 0;
|
int _durationByLastAudioPacket = 0;
|
||||||
int _durationByLastVideoPacket = 0;
|
int _durationByLastVideoPacket = 0;
|
||||||
|
|
||||||
|
int _locks = 0;
|
||||||
|
|
||||||
rpl::lifetime _lifetime;
|
rpl::lifetime _lifetime;
|
||||||
rpl::lifetime _sessionLifetime;
|
rpl::lifetime _sessionLifetime;
|
||||||
|
|
||||||
|
|
|
@ -436,6 +436,7 @@ void OverlayWidget::clearStreaming() {
|
||||||
_fullScreenVideo = false;
|
_fullScreenVideo = false;
|
||||||
if (_streamed) {
|
if (_streamed) {
|
||||||
_streamed->instance.stop();
|
_streamed->instance.stop();
|
||||||
|
_streamed->instance.unlockPlayer();
|
||||||
_streamed = nullptr;
|
_streamed = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2077,6 +2078,7 @@ void OverlayWidget::createStreamingObjects() {
|
||||||
this,
|
this,
|
||||||
static_cast<PlaybackControls::Delegate*>(this),
|
static_cast<PlaybackControls::Delegate*>(this),
|
||||||
[=] { waitingAnimationCallback(); });
|
[=] { waitingAnimationCallback(); });
|
||||||
|
_streamed->instance.lockPlayer();
|
||||||
_streamed->withSound = _doc->isAudioFile()
|
_streamed->withSound = _doc->isAudioFile()
|
||||||
|| _doc->isVideoFile()
|
|| _doc->isVideoFile()
|
||||||
|| _doc->isVoiceMessage()
|
|| _doc->isVoiceMessage()
|
||||||
|
|
Loading…
Reference in New Issue