void playlist::freeMemory(int position)
{
pList->at(position)->downloaded = false;
+ pList->at(position)->bufferready = false;
delete pList->at(position)->buffer;
pList->at(position)->buffer = new QBuffer();
}
bool playlist::existAt(int position)
{
+ if(position < 0)
+ return false;
return (pList->size() > position);
}
}
bool playlist::setCurrentPlaying(int position)
{
- if(pList->size() > position)
+ if(this->existAt(position))
{
this->currentplayingitem = position;
if(!pList->at(position)->downloaded && this->currentdownloaditem != this->currentplayingitem)
return true;
}
else
+ {
+ if(position = -1)
+ {
+ this->currentplayingitem = -1;
+ }
+ else
return false;
+ }
}
QIODevice * playlist::getBuffer(int position)
{
void playlist::getNError(QNetworkReply::NetworkError error)
{
qDebug() << "Network Error (if this is 99 then it will retry" << error;
- if(error == QNetworkReply::UnknownNetworkError)
+ if(error == QNetworkReply::UnknownNetworkError && this->currentdownloaditem != -1)
beginDownload(this->currentdownloaditem);
}
void playlist::downloadDone(int position)
{
- if(this->existAt(position+1) && this->currentSkeyItem == -1)
+ if(this->existAt(position+1) && this->currentSkeyItem == -1 && !pList->at(position+1)->downloaded && this->currentdownloaditem != position+1)
beginDownload(position+1);
else
this->currentdownloaditem = -1;