示例#1
0
void Playlist::shiftPlaylist()
{
    if(!waitingItems->isEmpty())
    {
        currentItem = waitingItems->takeFirst();
        emitCurrentItemChanged();
        emitWaitingListChangedSignal();
    }
    else
    {
        currentItem = NULL;
        emit playlistIsEmpty();
    }
}
示例#2
0
void MusicPlayer::creatPlaylist()
{
  if(playlistIsEmpty())
  {
    if(newsd.traverseRootSong(spl.songIndex, spl.songTotalNum))
    {
      for(unsigned char i = 0;i < spl.songTotalNum;i ++)
      {
        if(_currentSongIndex == spl.songIndex[i]) spl.currentSongNum = i;
        else spl.currentSongNum = 0;
      }
    }
  }
  else
  {
    addToNewPlaylist();
  }
}
示例#3
0
void MusicPlayer::playList()
{
  if(!playlistIsEmpty())
  {
    while(1)
    {
      playOrPause = 1;
      playingState = PS_PLAY;
      unsigned int songindex = spl.songIndex[spl.currentSongNum];
      playSong(songindex);
      switch(playingState)
      {
        case PS_STOP:         playOrPause = 0;GREEN_LED_OFF();return;
        case PS_NEXT_SONG:    if(_playmode == MODE_SHUFFLE) spl.currentSongNum = random(0,spl.songTotalNum);
                              else if(spl.currentSongNum == spl.songTotalNum - 1)   spl.currentSongNum = 0;
                              else ++ spl.currentSongNum;
                              playOrPause = 1;
                              break;
        case PS_PREVIOUS_SONG:if(_playmode == MODE_SHUFFLE) spl.currentSongNum = random(0,spl.songTotalNum);
                              else if(spl.currentSongNum == 0)  spl.currentSongNum = spl.songTotalNum - 1;
                              else -- spl.currentSongNum;
                              playOrPause = 1;
                              break;
        default:              if(_playmode == MODE_SHUFFLE) spl.currentSongNum = random(0,spl.songTotalNum);
                              else if(_playmode == MODE_NORMAL)
                              {
                                if(spl.currentSongNum == spl.songTotalNum - 1)
                                {
                                  playingState = PS_STOP;
                                  return;
                                }
                                else spl.currentSongNum ++;
                              }
                              else if(_playmode == MODE_REPEAT_LIST)
                              {
                                if(spl.currentSongNum == spl.songTotalNum - 1)   spl.currentSongNum = 0;
                                else spl.currentSongNum++;
                              }
                              break;
      }
    }
  }
}