Delay resume playback on startup to make sure Tidal login is refreshed
This commit is contained in:
@@ -1431,7 +1431,9 @@ void MainWindow::LoadPlaybackStatus() {
|
|||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
|
||||||
if (resume_playback && playback_state != Engine::Empty && playback_state != Engine::Idle) {
|
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 "config.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QDesktopServices>
|
#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::kAlbumsSongsFtsTable = "tidal_albums_songs_fts";
|
||||||
const char *TidalService::kSongsFtsTable = "tidal_songs_fts";
|
const char *TidalService::kSongsFtsTable = "tidal_songs_fts";
|
||||||
|
|
||||||
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
TidalService::TidalService(Application *app, QObject *parent)
|
TidalService::TidalService(Application *app, QObject *parent)
|
||||||
: InternetService(Song::Source_Tidal, "Tidal", "tidal", TidalSettingsPage::kSettingsGroup, SettingsDialog::Page_Tidal, app, parent),
|
: InternetService(Song::Source_Tidal, "Tidal", "tidal", TidalSettingsPage::kSettingsGroup, SettingsDialog::Page_Tidal, app, parent),
|
||||||
app_(app),
|
app_(app),
|
||||||
@@ -258,8 +261,12 @@ void TidalService::LoadSession() {
|
|||||||
|
|
||||||
if (!refresh_token_.isEmpty()) {
|
if (!refresh_token_.isEmpty()) {
|
||||||
qint64 time = expires_in_ - (QDateTime::currentDateTime().toSecsSinceEpoch() - login_time_);
|
qint64 time = expires_in_ - (QDateTime::currentDateTime().toSecsSinceEpoch() - login_time_);
|
||||||
if (time < 6) time = 6;
|
if (time <= 0) {
|
||||||
timer_refresh_login_->setInterval(static_cast<int>(time * kMsecPerSec));
|
timer_refresh_login_->setInterval(200ms);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
timer_refresh_login_->setInterval(static_cast<int>(time * kMsecPerSec));
|
||||||
|
}
|
||||||
timer_refresh_login_->start();
|
timer_refresh_login_->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user