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 pl->setCurrentPlaying(-1);
33 manager->~QNetworkAccessManager();
34 //reply->~QIODevice();
37 void sPlayer::abortDownload()
43 void sPlayer::start(int p)
45 qDebug() << "got start play";
46 if(p == pl->currentplaying())
49 media->setCurrentSource(Phonon::MediaSource(pl->getBuffer(p)));
51 qDebug() << "Playing";
57 if(pl->currentplaying() != -1)
59 //pl->setCurrentPlaying(pl->findFirstNotPlayed());
64 void sPlayer::play(int p)
66 if(pl->currentplaying() != -1)
67 pl->freeMemory(pl->currentplaying());
68 pl->setCurrentPlaying(p);
69 //pl->beginDownload(p);
76 if(pl->currentplaying() != -1)
77 pl->markPlayed(pl->currentplaying());
78 pl->setCurrentPlaying(-1);
82 void sPlayer::putb(int p, qint64 b, qint64 t)
84 //qDebug() << "Download: " << b << "Total: " << t;
85 if(p == pl->currentplaying())
89 StreamIO* stream = (StreamIO*) media->currentSource().stream();
90 stream->setStreamSize(pl->getBuffer(p)->size());