3 sPlayer::sPlayer(QObject *parent) :
6 manager = new QNetworkAccessManager();
7 buffer = new QBuffer();
8 audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory,this);
9 media = new Phonon::MediaObject(this);
10 Phonon::createPath(media, audioOutput);
12 //reply = new QNetworkReply();
14 //buffer->open(QIODevice::ReadWrite);
15 connect(media,SIGNAL(finished()),this,SLOT(markComplete()));
17 void sPlayer::setPlaylist(playlist *playList)
20 connect(pl,SIGNAL(bufferReady(int)),this,SLOT(start(int)));
21 connect(pl,SIGNAL(downloadProgress(int,qint64,qint64)),this,SLOT(putb(int,qint64,qint64)));
22 //connect(pl,SIGNAL(downloadComplete(int)),this,SLOT(start(int)));
25 void sPlayer::markComplete()
27 pl->markPlayed(pl->currentplaying());
28 if(pl->existAt(pl->currentplaying()+1))
30 pl->setCurrentPlaying(pl->currentplaying()+1);
31 if(pl->bReady(pl->currentplaying()))
32 this->start(pl->currentplaying());
35 pl->setCurrentPlaying(-1);
40 manager->~QNetworkAccessManager();
41 //reply->~QIODevice();
44 void sPlayer::abortDownload()
50 void sPlayer::start(int p)
52 qDebug() << "got start play";
53 if(p == pl->currentplaying())
56 media->setCurrentSource(Phonon::MediaSource(pl->getBuffer(p)));
58 qDebug() << "Playing";
64 if(pl->currentplaying() != -1)
66 //pl->setCurrentPlaying(pl->findFirstNotPlayed());
71 void sPlayer::play(int p)
73 if(pl->currentplaying() != -1)
74 pl->freeMemory(pl->currentplaying());
75 pl->setCurrentPlaying(p);
76 //pl->beginDownload(p);
83 if(pl->currentplaying() != -1)
84 pl->markPlayed(pl->currentplaying());
85 pl->setCurrentPlaying(-1);
89 void sPlayer::putb(int p, qint64 b, qint64 t)
91 //qDebug() << "Download: " << b << "Total: " << t;
92 if(p == pl->currentplaying())
96 StreamIO* stream = (StreamIO*) media->currentSource().stream();
97 stream->setStreamSize(pl->getBuffer(p)->size());