Restore last playing track on startup

This commit is contained in:
Bart De Vries 2021-04-11 21:08:25 +02:00
parent f5c20a92e2
commit 7e39d83f90
1 changed files with 10 additions and 1 deletions

View File

@ -6,12 +6,15 @@
*/
#include "audiomanager.h"
#include "powermanagementinterface.h"
#include <QTimer>
#include <QAudio>
#include <QEventLoop>
#include "powermanagementinterface.h"
#include "datamanager.h"
#include "settingsmanager.h"
class AudioManagerPrivate
{
@ -43,6 +46,12 @@ AudioManager::AudioManager(QObject *parent) : QObject(parent), d(std::make_uniqu
connect(&d->m_player, &QMediaPlayer::positionChanged, this, &AudioManager::positionChanged);
connect(&d->m_player, &QMediaPlayer::positionChanged, this, &AudioManager::savePlayPosition);
connect(&d->m_player, &QMediaPlayer::seekableChanged, this, &AudioManager::seekableChanged);
// Check if an entry was playing when the program was shut down and restore it
if (SettingsManager::self()->lastPlayingEntry() != QStringLiteral("none"))
setEntry(DataManager::instance().getEntry(SettingsManager::self()->lastPlayingEntry()));
//SettingsManager.lastPlayingEntry !== "none" ? DataManager.getEntry(SettingsManager.lastPlayingEntry) : undefined
}
AudioManager::~AudioManager()