mirror of
https://github.com/strawberrymusicplayer/strawberry
synced 2024-12-14 01:26:00 +01:00
Delay resume playback on startup to make sure Tidal login is refreshed
This commit is contained in:
parent
facf49b2b7
commit
fab1d94d34
@ -1431,7 +1431,9 @@ void MainWindow::LoadPlaybackStatus() {
|
||||
s.endGroup();
|
||||
|
||||
if (resume_playback && playback_state != Engine::Empty && playback_state != Engine::Idle) {
|
||||
QObject::connect(app_->playlist_manager(), &PlaylistManager::AllPlaylistsLoaded, this, &MainWindow::ResumePlayback);
|
||||
QObject::connect(app_->playlist_manager(), &PlaylistManager::AllPlaylistsLoaded, this, [this]() {
|
||||
QTimer::singleShot(400, this, &MainWindow::ResumePlayback);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
#include <chrono>
|
||||
|
||||
#include <QObject>
|
||||
#include <QDesktopServices>
|
||||
@ -80,6 +81,8 @@ const char *TidalService::kArtistsSongsFtsTable = "tidal_artists_songs_fts";
|
||||
const char *TidalService::kAlbumsSongsFtsTable = "tidal_albums_songs_fts";
|
||||
const char *TidalService::kSongsFtsTable = "tidal_songs_fts";
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
TidalService::TidalService(Application *app, QObject *parent)
|
||||
: InternetService(Song::Source_Tidal, "Tidal", "tidal", TidalSettingsPage::kSettingsGroup, SettingsDialog::Page_Tidal, app, parent),
|
||||
app_(app),
|
||||
@ -258,8 +261,12 @@ void TidalService::LoadSession() {
|
||||
|
||||
if (!refresh_token_.isEmpty()) {
|
||||
qint64 time = expires_in_ - (QDateTime::currentDateTime().toSecsSinceEpoch() - login_time_);
|
||||
if (time < 6) time = 6;
|
||||
timer_refresh_login_->setInterval(static_cast<int>(time * kMsecPerSec));
|
||||
if (time <= 0) {
|
||||
timer_refresh_login_->setInterval(200ms);
|
||||
}
|
||||
else {
|
||||
timer_refresh_login_->setInterval(static_cast<int>(time * kMsecPerSec));
|
||||
}
|
||||
timer_refresh_login_->start();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user