2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Keep track of fully cached media files.

This commit is contained in:
John Preston
2019-05-31 19:45:03 +03:00
parent 2255eb2c68
commit 04e3b250e7
20 changed files with 342 additions and 54 deletions

View File

@@ -174,7 +174,7 @@ void Player::trackSendReceivedTill(
Expects(state.duration != kTimeUnknown);
Expects(state.receivedTill != kTimeUnknown);
if (!_remoteLoader) {
if (!_remoteLoader || _fullInCacheSinceStart.value_or(false)) {
return;
}
const auto receivedTill = std::max(
@@ -302,6 +302,15 @@ void Player::fileError(Error error) {
});
}
void Player::fileFullInCache(bool fullInCache) {
crl::on_main(&_sessionGuard, [=] {
if (!_fullInCacheSinceStart.has_value()) {
_fullInCacheSinceStart = fullInCache;
}
_fullInCache.fire_copy(fullInCache);
});
}
void Player::fileWaitingForData() {
if (_waitingForData) {
return;
@@ -736,6 +745,10 @@ bool Player::finished() const {
&& (!_video || _videoFinished);
}
float64 Player::speed() const {
return _options.speed;
}
void Player::setSpeed(float64 speed) {
Expects(active());
Expects(speed >= 0.5 && speed <= 2.);
@@ -767,6 +780,10 @@ rpl::producer<Update, Error> Player::updates() const {
return _updates.events();
}
rpl::producer<bool> Player::fullInCache() const {
return _fullInCache.events();
}
QSize Player::videoSize() const {
return _information.video.size;
}
@@ -803,7 +820,8 @@ Media::Player::TrackState Player::prepareLegacyState() const {
} else if (_options.loop && result.length > 0) {
result.position %= result.length;
}
result.receivedTill = _remoteLoader
result.receivedTill = (_remoteLoader
&& !_fullInCacheSinceStart.value_or(false))
? getCurrentReceivedTill(result.length)
: 0;
result.frequency = kMsFrequency;