mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
When you are latched onto someone, if there is a track you can't resolve, keep trying to play the next track periodically, so that you'll pick back up with their stream when they next play a track that you can resolve. I can't test this now due to
firewall but I believe the code should be safe.
This commit is contained in:
@@ -73,13 +73,17 @@ AudioEngine::AudioEngine()
|
|||||||
// Since it's indendent, we'll set it to 75% since that's nicer
|
// Since it's indendent, we'll set it to 75% since that's nicer
|
||||||
setVolume( 75 );
|
setVolume( 75 );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
m_retryTimer.setInterval( 10000 );
|
||||||
|
m_retryTimer.setSingleShot( false );
|
||||||
|
connect( &m_retryTimer, SIGNAL( timeout() ), SLOT( loadNextTrack() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
AudioEngine::~AudioEngine()
|
AudioEngine::~AudioEngine()
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
m_retryTimer.stop();
|
||||||
m_mediaObject->stop();
|
m_mediaObject->stop();
|
||||||
// stop();
|
// stop();
|
||||||
|
|
||||||
@@ -210,6 +214,9 @@ bool
|
|||||||
AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
|
AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << thread() << result;
|
qDebug() << Q_FUNC_INFO << thread() << result;
|
||||||
|
|
||||||
|
m_retryTimer.stop();
|
||||||
|
|
||||||
bool err = false;
|
bool err = false;
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -295,6 +302,8 @@ AudioEngine::loadPreviousTrack()
|
|||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
|
||||||
|
m_retryTimer.stop();
|
||||||
|
|
||||||
if ( !m_playlist )
|
if ( !m_playlist )
|
||||||
{
|
{
|
||||||
stop();
|
stop();
|
||||||
@@ -314,6 +323,8 @@ AudioEngine::loadNextTrack()
|
|||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
|
||||||
|
m_retryTimer.stop();
|
||||||
|
|
||||||
Tomahawk::result_ptr result;
|
Tomahawk::result_ptr result;
|
||||||
|
|
||||||
if ( m_queue && m_queue->trackCount() )
|
if ( m_queue && m_queue->trackCount() )
|
||||||
@@ -329,7 +340,14 @@ AudioEngine::loadNextTrack()
|
|||||||
if ( !result.isNull() )
|
if ( !result.isNull() )
|
||||||
loadTrack( result );
|
loadTrack( result );
|
||||||
else
|
else
|
||||||
|
{
|
||||||
stop();
|
stop();
|
||||||
|
if ( m_playlist->retryMode() == Tomahawk::PlaylistInterface::Retry )
|
||||||
|
{
|
||||||
|
m_retryTimer.setInterval( m_playlist->retryInterval() );
|
||||||
|
m_retryTimer.start();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -341,6 +359,12 @@ AudioEngine::playItem( Tomahawk::PlaylistInterface* playlist, const Tomahawk::re
|
|||||||
setPlaylist( playlist );
|
setPlaylist( playlist );
|
||||||
m_currentTrackPlaylist = playlist;
|
m_currentTrackPlaylist = playlist;
|
||||||
|
|
||||||
|
if ( result.isNull() )
|
||||||
|
{
|
||||||
|
m_retryTimer.setInterval( playlist->retryInterval() );
|
||||||
|
m_retryTimer.start();
|
||||||
|
}
|
||||||
|
else
|
||||||
loadTrack( result );
|
loadTrack( result );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
#define AUDIOENGINE_H
|
#define AUDIOENGINE_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
#include <phonon/MediaObject>
|
#include <phonon/MediaObject>
|
||||||
#include <phonon/AudioOutput>
|
#include <phonon/AudioOutput>
|
||||||
@@ -128,6 +129,8 @@ private:
|
|||||||
unsigned int m_timeElapsed;
|
unsigned int m_timeElapsed;
|
||||||
bool m_expectStop;
|
bool m_expectStop;
|
||||||
|
|
||||||
|
QTimer m_retryTimer;
|
||||||
|
|
||||||
static AudioEngine* s_instance;
|
static AudioEngine* s_instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -36,6 +36,7 @@ public:
|
|||||||
enum RepeatMode { NoRepeat, RepeatOne, RepeatAll };
|
enum RepeatMode { NoRepeat, RepeatOne, RepeatAll };
|
||||||
enum ViewMode { Unknown, Tree, Flat, Album };
|
enum ViewMode { Unknown, Tree, Flat, Album };
|
||||||
enum SkipSeekRestrictions { NoRestrictions, NoSkip, NoSeek, NoSkipSeek };
|
enum SkipSeekRestrictions { NoRestrictions, NoSkip, NoSeek, NoSkipSeek };
|
||||||
|
enum RetryMode { NoRetry, Retry };
|
||||||
|
|
||||||
PlaylistInterface( QObject* parent = 0 ) : m_object( parent ) {}
|
PlaylistInterface( QObject* parent = 0 ) : m_object( parent ) {}
|
||||||
virtual ~PlaylistInterface() {}
|
virtual ~PlaylistInterface() {}
|
||||||
@@ -54,6 +55,9 @@ public:
|
|||||||
virtual PlaylistInterface::ViewMode viewMode() const { return Unknown; }
|
virtual PlaylistInterface::ViewMode viewMode() const { return Unknown; }
|
||||||
virtual PlaylistInterface::SkipSeekRestrictions skipSeekRestrictions() const { return NoRestrictions; }
|
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 QString filter() const { return m_filter; }
|
||||||
virtual void setFilter( const QString& pattern ) { m_filter = pattern; }
|
virtual void setFilter( const QString& pattern ) { m_filter = pattern; }
|
||||||
|
|
||||||
|
@@ -48,6 +48,8 @@ public:
|
|||||||
|
|
||||||
virtual PlaylistInterface::RepeatMode repeatMode() const { return PlaylistInterface::NoRepeat; }
|
virtual PlaylistInterface::RepeatMode repeatMode() const { return PlaylistInterface::NoRepeat; }
|
||||||
virtual PlaylistInterface::SkipSeekRestrictions skipSeekRestrictions() const { return PlaylistInterface::NoSkipSeek; }
|
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 bool shuffled() const { return false; }
|
||||||
virtual void setFilter( const QString& /*pattern*/ ) {}
|
virtual void setFilter( const QString& /*pattern*/ ) {}
|
||||||
|
Reference in New Issue
Block a user