From e33b15c0bd75c1a115bf4d9f4159839368cceb13 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 22 Jan 2010 11:11:24 +0100 Subject: Make qtspotify work with latest version of despotify MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add ALSA backend written by Jørgen Lind --- qtspotifymain.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'qtspotifymain.cpp') 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(data); QtSpotifyMain *qsm = reinterpret_cast(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(); 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"), -- cgit v1.2.3