X-Git-Url: http://git.maemo.org/git/?p=groove;a=blobdiff_plain;f=splayer.cpp;h=f6352c853c9aeb838ce168d051a83c65dcf1183a;hp=a2349b25c2f8580c4cf6b8d7a6cfe65856786d48;hb=21d90a736479e9eb1615db46297dca25115d5ea0;hpb=ece7001a5b569241115c0187d654b92e247c68f6 diff --git a/splayer.cpp b/splayer.cpp index a2349b2..f6352c8 100644 --- a/splayer.cpp +++ b/splayer.cpp @@ -1,4 +1,4 @@ -#include "splayer.h" +#include "mpgplayer.h" #include sPlayer::sPlayer(QObject *parent) : QObject(parent) @@ -13,6 +13,8 @@ sPlayer::sPlayer(QObject *parent) : internal = parent; //buffer->open(QIODevice::ReadWrite); connect(media,SIGNAL(finished()),this,SLOT(markComplete())); + media->setTickInterval(200); + connect(media,SIGNAL(tick(qint64)),this,SLOT(updatePlayPosition(qint64))); } void sPlayer::setPlaylist(playlist *playList) { @@ -25,7 +27,34 @@ void sPlayer::setPlaylist(playlist *playList) void sPlayer::markComplete() { pl->markPlayed(pl->currentplaying()); - pl->setCurrentPlaying(-1); + if(pl->existAt(pl->currentplaying()+1)) + { + pl->setCurrentPlaying(pl->currentplaying()+1); + if(pl->bReady(pl->currentplaying())) + this->start(pl->currentplaying()); + } + else + pl->setCurrentPlaying(-1); +} +void sPlayer::updatePlayPosition(qint64 time) +{ + //qDebug() << time << ":" << media->totalTime(); +} + +void sPlayer::pause() +{ + if(media->state() == Phonon::PausedState) + media->play(); + if(media->state() == Phonon::PlayingState) + media->pause(); +} +void sPlayer::playNext() +{ + if(pl->existAt(pl->currentplaying()+1)) + { + media->stop(); + this->markComplete(); + } } sPlayer::~sPlayer() @@ -34,6 +63,19 @@ sPlayer::~sPlayer() //reply->~QIODevice(); media->~MediaNode(); } +void sPlayer::back() +{ + media->stop(); + if(pl->existAt(pl->currentplaying()-1)) + { + pl->setCurrentPlaying(pl->currentplaying()-1); + if(pl->bReady(pl->currentplaying())) + this->start(pl->currentplaying()); + } + else + pl->setCurrentPlaying(-1); +} + void sPlayer::abortDownload() { //pd->hide(); @@ -63,14 +105,19 @@ void sPlayer::play() } void sPlayer::play(int p) { + if(pl->currentplaying() != -1) + pl->freeMemory(pl->currentplaying()); pl->setCurrentPlaying(p); //pl->beginDownload(p); } void sPlayer::stop() { - pl->setCurrentPlaying(-1); + media->stop(); + if(pl->currentplaying() != -1) + pl->markPlayed(pl->currentplaying()); + pl->setCurrentPlaying(-1); playing = false; }