Beispiel #1
0
void QSpotifyPlayQueue::next()
{
    if (m_currentExplicitTrack) {
        m_currentExplicitTrack->release();
        m_currentExplicitTrack = 0;
    }

    if (m_explicitTracks.isEmpty()) {
        if (m_implicitTracks) {
            if (!m_implicitTracks->next()) {
                if (m_repeat) {
                    m_implicitTracks->setCurrentTrackToFirst();
                } else {
                    QSpotifySession::instance()->stop();
                    m_implicitTracks->release();
                    m_implicitTracks = 0;
                }
            }
        } else {
            QSpotifySession::instance()->stop();
        }
    } else {
        m_currentExplicitTrack = m_explicitTracks.dequeue();
        if (m_currentExplicitTrack->isLoaded())
            onTrackReady();
        else
            connect(m_currentExplicitTrack, SIGNAL(isLoadedChanged()), this, SLOT(onTrackReady()));
    }

    emit tracksChanged();
}
Beispiel #2
0
void QSpotifyPlayQueue::selectTrack(QSpotifyTrack *track)
{
    if (m_currentExplicitTrack == track || m_implicitTracks->m_currentTrack == track)
        return;

    if (m_currentExplicitTrack) {
        m_currentExplicitTrack->release();
        m_currentExplicitTrack = 0;
    }

    int explicitPos = m_explicitTracks.indexOf(track);
    if (explicitPos != -1) {
        m_explicitTracks.removeAt(explicitPos);
        m_currentExplicitTrack = track;
        if (m_currentExplicitTrack->isLoaded())
            onTrackReady();
        else
            connect(m_currentExplicitTrack, SIGNAL(isLoadedChanged()), this, SLOT(onTrackReady()));
    } else {
        m_implicitTracks->playTrackAtIndex(m_implicitTracks->m_tracks.indexOf(track));
    }

    emit tracksChanged();
}
void QSpotifyPlayQueue::playNext(bool repeat)
{
    if (repeat) {
        QSpotifySession::instance()->stop(true);
        QSpotifySession::instance()->play(m_currentExplicitTrack ? m_currentExplicitTrack : m_implicitTracks->m_currentTrack);
    } else {
        if (m_currentExplicitTrack) {
            m_currentExplicitTrack->release();
            m_currentExplicitTrack = nullptr;
        }

        if (m_explicitTracks.isEmpty()) {
            if (m_implicitTracks) {
                if (!m_implicitTracks->next()) {
                    if (m_repeat) {
                        m_implicitTracks->play();
                    } else {
                        QSpotifySession::instance()->stop();
                        m_implicitTracks->release();
                        m_implicitTracks = 0;
                    }
                }
            } else {
                QSpotifySession::instance()->stop();
            }
        } else {
            m_currentExplicitTrack = m_explicitTracks.dequeue();
            if (m_currentExplicitTrack->isLoaded())
                onTrackReady();
            else
                connect(m_currentExplicitTrack, SIGNAL(isLoadedChanged()), this, SLOT(onTrackReady()));
        }
    }

    emit tracksChanged();
}