diff --git a/src/libtomahawk/audio/AudioEngine.cpp b/src/libtomahawk/audio/AudioEngine.cpp index 75266df98..5d01d65c7 100644 --- a/src/libtomahawk/audio/AudioEngine.cpp +++ b/src/libtomahawk/audio/AudioEngine.cpp @@ -37,6 +37,9 @@ #include "infosystem/InfoSystem.h" #include "Album.h" #include "Pipeline.h" +#include "jobview/JobStatusView.h" +#include "jobview/JobStatusModel.h" +#include "jobview/ErrorStatusMessage.h" #include "utils/Logger.h" @@ -94,12 +97,9 @@ AudioEngine::AudioEngine() AudioEngine::~AudioEngine() { tDebug() << Q_FUNC_INFO; - + m_mediaObject->stop(); TomahawkSettings::instance()->setVolume( volume() ); - - delete m_audioOutput; - delete m_mediaObject; } @@ -604,8 +604,20 @@ AudioEngine::playItem( Tomahawk::playlistinterface_ptr playlist, const Tomahawk: { if ( query->resolvingFinished() ) { - if ( query->numResults() ) - playItem( playlist, query->results().first() ); + foreach ( const result_ptr& result, query->results() ) + { + if ( result->isOnline() ) + { + playItem( playlist, result ); + return; + } + } + + JobStatusView::instance()->model()->addJob( + new ErrorStatusMessage( tr( "Sorry, Tomahawk couldn't find the track '%1' by %2" ).arg( query->track() ).arg( query->artist() ), 15 ) ); + + if ( isStopped() ) + emit stopped(); // we do this so the original caller knows we couldn't find this track } else { @@ -621,9 +633,18 @@ void AudioEngine::playItem( const Tomahawk::artist_ptr& artist ) { playlistinterface_ptr pli = artist->playlistInterface( Mixed ); - if ( pli->trackCount() ) + if ( pli->isFinished() ) { - playItem( pli, pli->tracks().first() ); + if ( !pli->tracks().count() ) + { + JobStatusView::instance()->model()->addJob( + new ErrorStatusMessage( tr( "Sorry, Tomahawk couldn't find the artist '%1'" ).arg( artist->name() ), 15 ) ); + + if ( isStopped() ) + emit stopped(); // we do this so the original caller knows we couldn't find this track + } + else + playItem( pli, pli->tracks().first() ); } else { @@ -638,9 +659,18 @@ void AudioEngine::playItem( const Tomahawk::album_ptr& album ) { playlistinterface_ptr pli = album->playlistInterface( Mixed ); - if ( pli->trackCount() ) + if ( pli->isFinished() ) { - playItem( pli, pli->tracks().first() ); + if ( !pli->tracks().count() ) + { + JobStatusView::instance()->model()->addJob( + new ErrorStatusMessage( tr( "Sorry, Tomahawk couldn't find the album '%1' by %2" ).arg( album->name() ).arg( album->artist()->name() ), 15 ) ); + + if ( isStopped() ) + emit stopped(); // we do this so the original caller knows we couldn't find this track + } + else + playItem( pli, pli->tracks().first() ); } else { diff --git a/src/libtomahawk/audio/AudioEngine.h b/src/libtomahawk/audio/AudioEngine.h index d8a56aed8..e5183ea40 100644 --- a/src/libtomahawk/audio/AudioEngine.h +++ b/src/libtomahawk/audio/AudioEngine.h @@ -138,7 +138,7 @@ private slots: void sendNowPlayingNotification( const Tomahawk::InfoSystem::InfoType type ); void sendWaitingNotification() const; - + void queueStateSafety(); private: