mirror of https://github.com/procxx/kepka.git
Fix saving of playback position for long videos.
This commit is contained in:
parent
ac48ec5969
commit
79870600d9
|
@ -123,7 +123,14 @@ Application::Application(not_null<Launcher*> launcher)
|
|||
|
||||
Application::~Application() {
|
||||
_window.reset();
|
||||
_mediaView.reset();
|
||||
if (_mediaView) {
|
||||
_mediaView->clearData();
|
||||
_mediaView = nullptr;
|
||||
}
|
||||
|
||||
if (activeAccount().sessionExists()) {
|
||||
activeAccount().session().saveSettingsNowIfNeeded();
|
||||
}
|
||||
|
||||
// This can call writeMap() that serializes Main::Session.
|
||||
// In case it gets called after destroySession() we get missing data.
|
||||
|
|
|
@ -203,6 +203,13 @@ Support::Templates& Session::supportTemplates() const {
|
|||
return supportHelper().templates();
|
||||
}
|
||||
|
||||
void Session::saveSettingsNowIfNeeded() {
|
||||
if (_saveSettingsTimer.isActive()) {
|
||||
_saveSettingsTimer.cancel();
|
||||
Local::writeUserSettings();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Main
|
||||
|
||||
Main::Session &Auth() {
|
||||
|
|
|
@ -106,6 +106,7 @@ public:
|
|||
return _settings;
|
||||
}
|
||||
void saveSettingsDelayed(crl::time delay = kDefaultSaveDelay);
|
||||
void saveSettingsNowIfNeeded();
|
||||
|
||||
[[nodiscard]] not_null<MTP::Instance*> mtp();
|
||||
[[nodiscard]] ApiWrap &api() {
|
||||
|
|
|
@ -439,9 +439,12 @@ bool OverlayWidget::documentBubbleShown() const {
|
|||
|
||||
void OverlayWidget::clearStreaming(bool savePosition) {
|
||||
if (_streamed && _doc && savePosition) {
|
||||
using State = Media::Player::State;
|
||||
const auto state = _streamed->instance.player().prepareLegacyState();
|
||||
const auto time = (state.position == kTimeUnknown
|
||||
|| state.length == kTimeUnknown)
|
||||
|| state.length == kTimeUnknown
|
||||
|| state.state == State::PausedAtEnd
|
||||
|| Media::Player::IsStopped(state.state))
|
||||
? TimeId(0)
|
||||
: (state.length >= kMinLengthForSavePosition * state.frequency)
|
||||
? (state.position / state.frequency) * crl::time(1000)
|
||||
|
|
Loading…
Reference in New Issue