diff options
Diffstat (limited to 'qtspotifymain.cpp')
-rw-r--r-- | qtspotifymain.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/qtspotifymain.cpp b/qtspotifymain.cpp index deb9546..9a06b1b 100644 --- a/qtspotifymain.cpp +++ b/qtspotifymain.cpp @@ -68,7 +68,7 @@ static void callback(despotify_session *session, int signal, void *data, void *c return; switch (signal) { - case DESPOTIFY_TRACK_CHANGE: + case DESPOTIFY_NEW_TRACK: { track *t = reinterpret_cast<track *>(data); QtSpotifyMain *qsm = reinterpret_cast<QtSpotifyMain*>(session->client_callback_data); @@ -81,7 +81,7 @@ QtSpotifyMain::QtSpotifyMain(QWidget *parent) : QMainWindow(parent), m_session(0), m_machine(new QStateMachine), m_debugging(false), m_authenticationWatcher(0), m_retrievingPlayListWatcher(0) { - m_session = despotify_init_client(callback, this, true); + m_session = despotify_init_client(callback, this, true, true); if (m_session != 0) { initUi(); @@ -297,39 +297,39 @@ void QtSpotifyMain::search() void QtSpotifyMain::stop() { debug(tr("Stopping")); + m_audio.pause(); despotify_stop(m_session); } void QtSpotifyMain::pause() { debug(tr("Pausing")); - if (!despotify_pause(m_session)) { - QMessageBox::warning(this, tr("Error when pausing track"), - tr("Despotify error: %1").arg(QString::fromUtf8(m_session->last_error))); - } + m_audio.pause(); } void QtSpotifyMain::resume() { debug(tr("Resuming")); - despotify_resume(m_session); + m_audio.play(); } void QtSpotifyMain::play() { if (m_ui.playList->currentItem() == 0) { qWarning("Nothing to play"); - return ; + return; } QVariant data = m_ui.playList->currentItem()->data(0, Qt::UserRole); track *t = data.value<track *>(); if (t != 0) { + m_audio.pause(); debug(tr("Playing '%1'").arg(t->title)); if (!despotify_play(m_session, t, true)) { QMessageBox::information(this, tr("Error when playing track"), tr("Despotify error: %1").arg(QString::fromUtf8(m_session->last_error))); } else { + m_audio.play(); setNewTrack(t); } } else { @@ -362,6 +362,7 @@ void QtSpotifyMain::decideLoginResult() { if (m_authenticationWatcher->result()) { debug(tr("Login succeeded")); + m_audio.setDespotifySession(m_session); emit loggedIn(); } else { QMessageBox::warning(this, tr("Failed to log in"), |