diff --git a/src/libtomahawk/audio/audioengine.cpp b/src/libtomahawk/audio/audioengine.cpp index cfba7c05a..3008e6723 100644 --- a/src/libtomahawk/audio/audioengine.cpp +++ b/src/libtomahawk/audio/audioengine.cpp @@ -73,13 +73,17 @@ AudioEngine::AudioEngine() // Since it's indendent, we'll set it to 75% since that's nicer setVolume( 75 ); #endif + + m_retryTimer.setInterval( 10000 ); + m_retryTimer.setSingleShot( false ); + connect( &m_retryTimer, SIGNAL( timeout() ), SLOT( loadNextTrack() ) ); } AudioEngine::~AudioEngine() { qDebug() << Q_FUNC_INFO; - + m_retryTimer.stop(); m_mediaObject->stop(); // stop(); @@ -210,6 +214,9 @@ bool AudioEngine::loadTrack( const Tomahawk::result_ptr& result ) { qDebug() << Q_FUNC_INFO << thread() << result; + + m_retryTimer.stop(); + bool err = false; { @@ -294,7 +301,9 @@ void AudioEngine::loadPreviousTrack() { qDebug() << Q_FUNC_INFO; - + + m_retryTimer.stop(); + if ( !m_playlist ) { stop(); @@ -314,6 +323,8 @@ AudioEngine::loadNextTrack() { qDebug() << Q_FUNC_INFO; + m_retryTimer.stop(); + Tomahawk::result_ptr result; if ( m_queue && m_queue->trackCount() ) @@ -329,7 +340,14 @@ AudioEngine::loadNextTrack() if ( !result.isNull() ) loadTrack( result ); else + { stop(); + if ( m_playlist->retryMode() == Tomahawk::PlaylistInterface::Retry ) + { + m_retryTimer.setInterval( m_playlist->retryInterval() ); + m_retryTimer.start(); + } + } } @@ -341,7 +359,13 @@ AudioEngine::playItem( Tomahawk::PlaylistInterface* playlist, const Tomahawk::re setPlaylist( playlist ); m_currentTrackPlaylist = playlist; - loadTrack( result ); + if ( result.isNull() ) + { + m_retryTimer.setInterval( playlist->retryInterval() ); + m_retryTimer.start(); + } + else + loadTrack( result ); } diff --git a/src/libtomahawk/audio/audioengine.h b/src/libtomahawk/audio/audioengine.h index d401e7b03..f9b63e457 100644 --- a/src/libtomahawk/audio/audioengine.h +++ b/src/libtomahawk/audio/audioengine.h @@ -20,6 +20,7 @@ #define AUDIOENGINE_H #include +#include #include #include @@ -128,6 +129,8 @@ private: unsigned int m_timeElapsed; bool m_expectStop; + QTimer m_retryTimer; + static AudioEngine* s_instance; }; diff --git a/src/libtomahawk/playlistinterface.h b/src/libtomahawk/playlistinterface.h index 3064089b5..daf5d2406 100644 --- a/src/libtomahawk/playlistinterface.h +++ b/src/libtomahawk/playlistinterface.h @@ -36,6 +36,7 @@ public: enum RepeatMode { NoRepeat, RepeatOne, RepeatAll }; enum ViewMode { Unknown, Tree, Flat, Album }; enum SkipSeekRestrictions { NoRestrictions, NoSkip, NoSeek, NoSkipSeek }; + enum RetryMode { NoRetry, Retry }; PlaylistInterface( QObject* parent = 0 ) : m_object( parent ) {} virtual ~PlaylistInterface() {} @@ -54,6 +55,9 @@ public: virtual PlaylistInterface::ViewMode viewMode() const { return Unknown; } virtual PlaylistInterface::SkipSeekRestrictions skipSeekRestrictions() const { return NoRestrictions; } + virtual PlaylistInterface::RetryMode retryMode() const { return NoRetry; } + virtual quint32 retryInterval() const { return 30000; } + virtual QString filter() const { return m_filter; } virtual void setFilter( const QString& pattern ) { m_filter = pattern; } diff --git a/src/libtomahawk/sourceplaylistinterface.h b/src/libtomahawk/sourceplaylistinterface.h index 3a32a285b..649bcf5d7 100644 --- a/src/libtomahawk/sourceplaylistinterface.h +++ b/src/libtomahawk/sourceplaylistinterface.h @@ -48,6 +48,8 @@ public: virtual PlaylistInterface::RepeatMode repeatMode() const { return PlaylistInterface::NoRepeat; } virtual PlaylistInterface::SkipSeekRestrictions skipSeekRestrictions() const { return PlaylistInterface::NoSkipSeek; } + virtual PlaylistInterface::RetryMode retryMode() const { return Retry; } + virtual quint32 retryInterval() const { return 5000; } virtual bool shuffled() const { return false; } virtual void setFilter( const QString& /*pattern*/ ) {}