Logo Search packages:      
Sourcecode: bangarang version File versions  Download package

void Playlist::setMode ( Playlist::Mode  mode  ) 

Sets the Playlist queuing mode

Parameters:
mode mode to add MediaItems to the queue. Either Playlist::Normal or Playlist::Shuffle.

Definition at line 354 of file playlist.cpp.

References MediaItemModel::clearMediaListData(), MediaItemModel::mediaItemAt(), MediaItem::playlistIndex, and MediaItem::url.

{
    if (mode <= 1) {
        m_mode = mode;
        if (m_currentPlaylist->rowCount() > 0) {
            if (m_mediaObject->state() == Phonon::PlayingState || m_mediaObject->state() == Phonon::PausedState || m_mediaObject->state() == Phonon::LoadingState) {
                //Rebuild queue after currently playing item
                if (m_mode == Playlist::Normal) {
                    if (m_queue->rowCount() > 1) {
                        buildQueueFrom(m_queue->mediaItemAt(0).playlistIndex);
                    } else {
                        orderByPlaylist();
                    }
                } else {
                    MediaItem nowPlayingItem;
                    if (m_queue->rowCount() > 1) {
                        m_queue->removeRows(1, m_queue->rowCount() - 1);
                        nowPlayingItem = m_queue->mediaItemAt(0);
                    }
                    m_playlistIndices.clear();
                    m_playlistIndicesHistory.clear();
                    m_playlistUrlHistory.clear();
                    for (int i = 0; i < m_currentPlaylist->rowCount(); ++i) {
                        if (nowPlayingItem.url.isEmpty() || m_currentPlaylist->mediaItemAt(i).url != nowPlayingItem.url) {
                            m_playlistIndices.append(i);
                        }
                    }
                    shuffle();
                }
            } else {
                //Rebuild queue from scratch
                m_queue->clearMediaListData();
                if (m_mode == Playlist::Normal) {
                    orderByPlaylist();
                } else if (m_mode == Playlist::Shuffle) {
                    shuffle();
                }
            }
        }
    }
}


Generated by  Doxygen 1.6.0   Back to index