1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-01-17 14:28:24 +01:00

Wait for the first playable track when starting playback of a PlaylistInterface.

This commit is contained in:
Christian Muehlhaeuser 2014-11-12 09:25:07 +01:00
parent cf7ce9aa0e
commit 7c3d7303a3
2 changed files with 27 additions and 2 deletions

View File

@ -952,7 +952,7 @@ AudioEngine::playItem( const Tomahawk::artist_ptr& artist )
emit stopped(); // we do this so the original caller knows we couldn't find this track
}
else
playItem( pli, pli->tracks().first() );
playPlaylistInterface( pli );
}
else
{
@ -978,7 +978,7 @@ AudioEngine::playItem( const Tomahawk::album_ptr& album )
emit stopped(); // we do this so the original caller knows we couldn't find this track
}
else
playItem( pli, pli->tracks().first() );
playPlaylistInterface( pli );
}
else
{
@ -989,6 +989,30 @@ AudioEngine::playItem( const Tomahawk::album_ptr& album )
}
void
AudioEngine::playPlaylistInterface( const Tomahawk::playlistinterface_ptr& playlist )
{
if ( !playlist->hasFirstPlayableTrack() )
{
NewClosure( playlist.data(), SIGNAL( foundFirstPlayableTrack() ),
const_cast<AudioEngine*>(this), SLOT( playPlaylistInterface( Tomahawk::playlistinterface_ptr ) ), playlist );
return;
}
foreach ( const Tomahawk::query_ptr& query, playlist->tracks() )
{
if ( query->playable() )
{
playItem( playlist, query );
return;
}
}
// No playable track found
JobStatusView::instance()->model()->addJob( new ErrorStatusMessage( tr( "Sorry, couldn't find any playable tracks" ), 15 ) );
}
void
AudioEngine::onPlaylistNextTrackAvailable()
{

View File

@ -138,6 +138,7 @@ public slots:
void playItem( Tomahawk::playlistinterface_ptr playlist, const Tomahawk::query_ptr& query );
void playItem( const Tomahawk::artist_ptr& artist );
void playItem( const Tomahawk::album_ptr& album );
void playPlaylistInterface( const Tomahawk::playlistinterface_ptr& playlist );
void setPlaylist( Tomahawk::playlistinterface_ptr playlist );
void setQueue( const Tomahawk::playlistinterface_ptr& queue );