diff --git a/src/libtomahawk/audio/audioengine.cpp b/src/libtomahawk/audio/audioengine.cpp index 657c38c7a..dd11b622b 100644 --- a/src/libtomahawk/audio/audioengine.cpp +++ b/src/libtomahawk/audio/audioengine.cpp @@ -38,6 +38,7 @@ AudioEngine::instance() AudioEngine::AudioEngine() : QObject() + , m_isPlayingHttp( false ) , m_playlist( 0 ) , m_currentTrackPlaylist( 0 ) , m_queue( 0 ) @@ -173,13 +174,18 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result ) else { setCurrentTrack( result ); - io = Servent::instance()->getIODeviceForUrl( m_currentTrack ); - if ( !io || io.isNull() ) + if ( !isHttpResult( m_currentTrack->url() ) ) { - qDebug() << "Error getting iodevice for item"; - err = true; + io = Servent::instance()->getIODeviceForUrl( m_currentTrack ); + + if ( !io || io.isNull() ) + { + qDebug() << "Error getting iodevice for item"; + err = true; + } } + } if ( !err ) @@ -187,14 +193,18 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result ) qDebug() << "Starting new song from url:" << m_currentTrack->url(); emit loading( m_currentTrack ); - if ( !m_input.isNull() ) + if ( !m_input.isNull() || m_isPlayingHttp ) { m_expectStop = true; } - if ( !m_currentTrack->url().startsWith( "http://" ) ) + + m_mediaObject->currentSource().setAutoDelete( true ); + + if ( !isHttpResult( m_currentTrack->url() ) ) { m_mediaObject->setCurrentSource( io.data() ); + m_isPlayingHttp = false; } else { @@ -206,13 +216,11 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result ) qDebug() << Q_FUNC_INFO << furl; } m_mediaObject->setCurrentSource( furl ); + m_isPlayingHttp = true; } m_input = io; - - m_mediaObject->currentSource().setAutoDelete( true ); m_mediaObject->play(); - emit started( m_currentTrack ); DatabaseCommand_LogPlayback* cmd = new DatabaseCommand_LogPlayback( m_currentTrack, DatabaseCommand_LogPlayback::Started ); @@ -229,7 +237,6 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result ) return true; } - void AudioEngine::loadPreviousTrack() { @@ -346,3 +353,9 @@ AudioEngine::setCurrentTrack( const Tomahawk::result_ptr& result ) m_currentTrack = result; } + +bool +AudioEngine::isHttpResult( const QString& url ) const +{ + return url.startsWith( "http://" ); +} diff --git a/src/libtomahawk/audio/audioengine.h b/src/libtomahawk/audio/audioengine.h index b43ca7f19..580f9e044 100644 --- a/src/libtomahawk/audio/audioengine.h +++ b/src/libtomahawk/audio/audioengine.h @@ -105,6 +105,9 @@ private slots: void setCurrentTrack( const Tomahawk::result_ptr& result ); private: + bool isHttpResult( const QString& ) const; + + bool m_isPlayingHttp; QSharedPointer m_input; Tomahawk::result_ptr m_currentTrack;