QString MprisPlugin::loopStatus() const { Tomahawk::playlistinterface_ptr p = AudioEngine::instance()->playlist(); if ( p.isNull() ) return "None"; PlaylistModes::RepeatMode mode = p->repeatMode(); switch( mode ) { case PlaylistModes::RepeatOne: return "Track"; break; case PlaylistModes::RepeatAll: return "Playlist"; break; case PlaylistModes::NoRepeat: return "None"; break; default: return "None"; break; } return QString( "None" ); }
bool MprisPlugin::canPlay() const { // If there is a currently playing track, or if there is a playlist with at least 1 track, you can hit play Tomahawk::playlistinterface_ptr p = AudioEngine::instance()->playlist(); return AudioEngine::instance()->currentTrack() || ( !p.isNull() && p->trackCount() ); }
void AudioEngine::setPlaylist( Tomahawk::playlistinterface_ptr playlist ) { if ( m_playlist == playlist ) return; if ( !m_playlist.isNull() ) { if ( m_playlist.data() && m_playlist.data()->retryMode() == PlaylistModes::Retry ) disconnect( m_playlist.data(), SIGNAL( nextTrackReady() ) ); m_playlist.data()->reset(); } if ( playlist.isNull() ) { m_playlist.clear(); emit playlistChanged( playlist ); return; } m_playlist = playlist; m_stopAfterTrack.clear(); if ( !m_playlist.isNull() && m_playlist.data() && m_playlist.data()->retryMode() == PlaylistModes::Retry ) connect( m_playlist.data(), SIGNAL( nextTrackReady() ), SLOT( onPlaylistNextTrackReady() ) ); emit playlistChanged( playlist ); }
void AudioEngine::playItem( Tomahawk::playlistinterface_ptr playlist, const Tomahawk::result_ptr& result, const Tomahawk::query_ptr& fromQuery ) { tDebug( LOGEXTRA ) << Q_FUNC_INFO << ( result.isNull() ? QString() : result->url() ); if ( !m_playlist.isNull() ) m_playlist.data()->reset(); setPlaylist( playlist ); if ( playlist.isNull() && !fromQuery.isNull() ) m_currentTrackPlaylist = playlistinterface_ptr( new SingleTrackPlaylistInterface( fromQuery ) ); else m_currentTrackPlaylist = playlist; if ( !result.isNull() ) { loadTrack( result ); } else if ( !m_playlist.isNull() && m_playlist.data()->retryMode() == PlaylistModes::Retry ) { m_waitingOnNewTrack = true; if ( isStopped() ) emit sendWaitingNotification(); else stop(); } }
void MprisPlugin::setShuffle( bool value ) { Tomahawk::playlistinterface_ptr p = AudioEngine::instance()->playlist(); if ( p.isNull() ) return; return p->setShuffled( value ); }
bool MprisPlugin::shuffle() const { Tomahawk::playlistinterface_ptr p = AudioEngine::instance()->playlist(); if ( p.isNull() ) return false; return p->shuffled(); }
bool MprisPlugin::canSeek() const { Tomahawk::playlistinterface_ptr p = AudioEngine::instance()->playlist(); if ( p.isNull() ) return false; return p->seekRestrictions() != PlaylistModes::NoSeek; }
void MprisPlugin::setLoopStatus( const QString& value ) { Tomahawk::playlistinterface_ptr p = AudioEngine::instance()->playlist(); if ( p.isNull() ) return; if ( value == "Track" ) p->setRepeatMode( PlaylistModes::RepeatOne ); else if ( value == "Playlist" ) p->setRepeatMode( PlaylistModes::RepeatAll ); else if ( value == "None" ) p->setRepeatMode( PlaylistModes::NoRepeat ); }
void AudioEngine::setPlaylist( Tomahawk::playlistinterface_ptr playlist ) { if ( m_playlist == playlist ) return; if ( !m_playlist.isNull() ) { if ( m_playlist.data() ) { disconnect( m_playlist.data(), SIGNAL( previousTrackAvailable() ) ); disconnect( m_playlist.data(), SIGNAL( nextTrackAvailable() ) ); } m_playlist.data()->reset(); } if ( playlist.isNull() ) { m_playlist.clear(); emit playlistChanged( playlist ); return; } m_playlist = playlist; m_stopAfterTrack.clear(); if ( !m_playlist.isNull() ) { 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 ); }