mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 11:20:22 +02:00
* AudioEngine now emits a signal when the previous / next control state changes.
This commit is contained in:
@@ -223,7 +223,7 @@ AudioEngine::canGoNext()
|
|||||||
m_playlist.data()->skipRestrictions() == PlaylistModes::NoSkipForwards )
|
m_playlist.data()->skipRestrictions() == PlaylistModes::NoSkipForwards )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ( !m_currentTrack.isNull() && !m_playlist->hasNextItem() &&
|
if ( !m_currentTrack.isNull() && !m_playlist->hasNextResult() &&
|
||||||
( m_playlist->currentItem().isNull() || ( m_currentTrack->id() == m_playlist->currentItem()->id() ) ) )
|
( m_playlist->currentItem().isNull() || ( m_currentTrack->id() == m_playlist->currentItem()->id() ) ) )
|
||||||
{
|
{
|
||||||
//For instance, when doing a catch-up while listening along, but the person
|
//For instance, when doing a catch-up while listening along, but the person
|
||||||
@@ -232,7 +232,7 @@ AudioEngine::canGoNext()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_playlist.data()->hasNextItem();
|
return m_playlist.data()->hasNextResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -246,7 +246,7 @@ AudioEngine::canGoPrevious()
|
|||||||
m_playlist.data()->skipRestrictions() == PlaylistModes::NoSkipBackwards )
|
m_playlist.data()->skipRestrictions() == PlaylistModes::NoSkipBackwards )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return m_playlist.data()->hasPreviousResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -327,7 +327,7 @@ AudioEngine::sendWaitingNotification() const
|
|||||||
{
|
{
|
||||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
|
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
|
||||||
//since it's async, after this is triggered our result could come in, so don't show the popup in that case
|
//since it's async, after this is triggered our result could come in, so don't show the popup in that case
|
||||||
if ( !m_playlist.isNull() && m_playlist->hasNextItem() )
|
if ( !m_playlist.isNull() && m_playlist->hasNextResult() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Tomahawk::InfoSystem::InfoPushData pushData (
|
Tomahawk::InfoSystem::InfoPushData pushData (
|
||||||
@@ -519,7 +519,13 @@ AudioEngine::loadPreviousTrack()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Tomahawk::result_ptr result = m_playlist.data()->previousItem();
|
Tomahawk::result_ptr result;
|
||||||
|
if ( m_playlist.data()->hasPreviousResult() )
|
||||||
|
{
|
||||||
|
result = m_playlist.data()->previousResult();
|
||||||
|
m_currentTrackPlaylist = m_playlist;
|
||||||
|
}
|
||||||
|
|
||||||
if ( !result.isNull() )
|
if ( !result.isNull() )
|
||||||
loadTrack( result );
|
loadTrack( result );
|
||||||
else
|
else
|
||||||
@@ -546,14 +552,19 @@ AudioEngine::loadNextTrack()
|
|||||||
|
|
||||||
if ( m_queue && m_queue->trackCount() )
|
if ( m_queue && m_queue->trackCount() )
|
||||||
{
|
{
|
||||||
result = m_queue->nextItem();
|
result = m_queue->nextResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !m_playlist.isNull() && result.isNull() )
|
if ( !m_playlist.isNull() && result.isNull() )
|
||||||
{
|
{
|
||||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Loading playlist's next item" << m_playlist.data() << m_playlist->shuffled();
|
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Loading playlist's next item" << m_playlist.data() << m_playlist->shuffled();
|
||||||
result = m_playlist.data()->nextItem();
|
|
||||||
m_currentTrackPlaylist = m_playlist;
|
if ( m_playlist.data()->hasNextResult() )
|
||||||
|
{
|
||||||
|
result = m_playlist.data()->nextResult();
|
||||||
|
tDebug() << Q_FUNC_INFO << result->toString();
|
||||||
|
m_currentTrackPlaylist = m_playlist;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !result.isNull() )
|
if ( !result.isNull() )
|
||||||
@@ -681,21 +692,25 @@ AudioEngine::playItem( const Tomahawk::album_ptr& album )
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AudioEngine::onPlaylistNextTrackReady()
|
AudioEngine::onPlaylistNextTrackAvailable()
|
||||||
{
|
{
|
||||||
// If in real-time and you have a few seconds left, you're probably lagging -- finish it up
|
tDebug() << Q_FUNC_INFO;
|
||||||
if ( m_playlist && m_playlist->latchMode() == PlaylistModes::RealTime && ( m_waitingOnNewTrack || m_currentTrack.isNull() || m_currentTrack->id() == 0 || ( currentTrackTotalTime() - currentTime() > 6000 ) ) )
|
|
||||||
{
|
{
|
||||||
|
// If in real-time and you have a few seconds left, you're probably lagging -- finish it up
|
||||||
|
if ( m_playlist && m_playlist->latchMode() == PlaylistModes::RealTime && ( m_waitingOnNewTrack || m_currentTrack.isNull() || m_currentTrack->id() == 0 || ( currentTrackTotalTime() - currentTime() > 6000 ) ) )
|
||||||
|
{
|
||||||
|
m_waitingOnNewTrack = false;
|
||||||
|
loadNextTrack();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !m_waitingOnNewTrack )
|
||||||
|
return;
|
||||||
|
|
||||||
m_waitingOnNewTrack = false;
|
m_waitingOnNewTrack = false;
|
||||||
loadNextTrack();
|
loadNextTrack();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !m_waitingOnNewTrack )
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_waitingOnNewTrack = false;
|
|
||||||
loadNextTrack();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -815,8 +830,12 @@ AudioEngine::setPlaylist( Tomahawk::playlistinterface_ptr playlist )
|
|||||||
|
|
||||||
if ( !m_playlist.isNull() )
|
if ( !m_playlist.isNull() )
|
||||||
{
|
{
|
||||||
if ( m_playlist.data() && m_playlist.data()->retryMode() == PlaylistModes::Retry )
|
if ( m_playlist.data() )
|
||||||
disconnect( m_playlist.data(), SIGNAL( nextTrackReady() ) );
|
{
|
||||||
|
disconnect( m_playlist.data(), SIGNAL( previousTrackAvailable( bool ) ) );
|
||||||
|
disconnect( m_playlist.data(), SIGNAL( nextTrackAvailable( bool ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
m_playlist.data()->reset();
|
m_playlist.data()->reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -830,8 +849,13 @@ AudioEngine::setPlaylist( Tomahawk::playlistinterface_ptr playlist )
|
|||||||
m_playlist = playlist;
|
m_playlist = playlist;
|
||||||
m_stopAfterTrack.clear();
|
m_stopAfterTrack.clear();
|
||||||
|
|
||||||
if ( !m_playlist.isNull() && m_playlist.data() && m_playlist.data()->retryMode() == PlaylistModes::Retry )
|
if ( !m_playlist.isNull() )
|
||||||
connect( m_playlist.data(), SIGNAL( nextTrackReady() ), SLOT( onPlaylistNextTrackReady() ) );
|
{
|
||||||
|
connect( m_playlist.data(), SIGNAL( nextTrackAvailable() ), SLOT( onPlaylistNextTrackAvailable() ) );
|
||||||
|
|
||||||
|
connect( m_playlist.data(), SIGNAL( previousTrackAvailable() ), SIGNAL( controlStateChanged() ) );
|
||||||
|
connect( m_playlist.data(), SIGNAL( nextTrackAvailable() ), SIGNAL( controlStateChanged() ) );
|
||||||
|
}
|
||||||
|
|
||||||
emit playlistChanged( playlist );
|
emit playlistChanged( playlist );
|
||||||
}
|
}
|
||||||
@@ -863,6 +887,14 @@ AudioEngine::setCurrentTrack( const Tomahawk::result_ptr& result )
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_currentTrack = result;
|
m_currentTrack = result;
|
||||||
|
|
||||||
|
if ( result )
|
||||||
|
{
|
||||||
|
if ( m_playlist )
|
||||||
|
{
|
||||||
|
m_playlist.data()->setCurrentIndex( m_playlist.data()->indexOfResult( result ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -64,7 +64,6 @@ public:
|
|||||||
Tomahawk::playlistinterface_ptr playlist() const { return m_playlist; }
|
Tomahawk::playlistinterface_ptr playlist() const { return m_playlist; }
|
||||||
|
|
||||||
Tomahawk::result_ptr currentTrack() const { return m_currentTrack; }
|
Tomahawk::result_ptr currentTrack() const { return m_currentTrack; }
|
||||||
|
|
||||||
Tomahawk::query_ptr stopAfterTrack() const { return m_stopAfterTrack; }
|
Tomahawk::query_ptr stopAfterTrack() const { return m_stopAfterTrack; }
|
||||||
|
|
||||||
qint64 currentTime() const { return m_mediaObject->currentTime(); }
|
qint64 currentTime() const { return m_mediaObject->currentTime(); }
|
||||||
@@ -111,6 +110,7 @@ signals:
|
|||||||
|
|
||||||
void seeked( qint64 ms );
|
void seeked( qint64 ms );
|
||||||
|
|
||||||
|
void controlStateChanged();
|
||||||
void stateChanged( AudioState newState, AudioState oldState );
|
void stateChanged( AudioState newState, AudioState oldState );
|
||||||
void volumeChanged( int volume /* in percent */ );
|
void volumeChanged( int volume /* in percent */ );
|
||||||
|
|
||||||
@@ -134,7 +134,7 @@ private slots:
|
|||||||
|
|
||||||
void setCurrentTrack( const Tomahawk::result_ptr& result );
|
void setCurrentTrack( const Tomahawk::result_ptr& result );
|
||||||
void onNowPlayingInfoReady( const Tomahawk::InfoSystem::InfoType type );
|
void onNowPlayingInfoReady( const Tomahawk::InfoSystem::InfoType type );
|
||||||
void onPlaylistNextTrackReady();
|
void onPlaylistNextTrackAvailable();
|
||||||
|
|
||||||
void sendNowPlayingNotification( const Tomahawk::InfoSystem::InfoType type );
|
void sendNowPlayingNotification( const Tomahawk::InfoSystem::InfoType type );
|
||||||
void sendWaitingNotification() const;
|
void sendWaitingNotification() const;
|
||||||
|
Reference in New Issue
Block a user