Commit 2b23491b authored by Mike Sheldon's avatar Mike Sheldon

Add support for pausing and resuming tracks

parent 7c8f3e25
......@@ -112,11 +112,13 @@ Page {
onClicked: {
if (imgPlay.visible) {
imgPlay.visible = false
imgPause.visible = true
rootWin.play();
imgPlay.visible = false;
imgPause.visible = true;
} else {
imgPlay.visible = true
imgPause.visible = false
rootWin.pause();
imgPlay.visible = true;
imgPause.visible = false;
}
}
......
......@@ -10,6 +10,8 @@ PageStackWindow {
signal tuneStation(string station)
signal next()
signal prev()
signal play()
signal pause()
function openFile(file) {
var component = Qt.createComponent(file)
......
......@@ -31,6 +31,8 @@ int main(int argc, char *argv[])
QObject::connect(root, SIGNAL(tuneStation(QString)), &sc, SLOT(tuneStation(QString)));
QObject::connect(root, SIGNAL(next()), &sc, SLOT(next()));
QObject::connect(root, SIGNAL(prev()), &sc, SLOT(prev()));
QObject::connect(root, SIGNAL(play()), &sc, SLOT(play()));
QObject::connect(root, SIGNAL(pause()), &sc, SLOT(pause()));
QObject::connect((QObject*)view.engine(), SIGNAL(quit()), &app, SLOT(quit()));
view.showFullScreen();
......
......@@ -185,7 +185,7 @@ void ServerComm::playlistReply(QNetworkReply *reply) {
}
}
if(currentSong == -1) {
play(0);
loadSong(0);
}
}
......@@ -211,25 +211,33 @@ void ServerComm::parseTrack(QDomNode trackNode) {
playlist->append(*t);
}
void ServerComm::play(int song) {
void ServerComm::loadSong(int song) {
currentSong = song;
Track t = playlist->at(song);
playing(t.artist, t.album, t.title, t.image);
QUrl url(t.location);
media->setCurrentSource(url);
media->play();
play();
if (song >= playlist->length() - 3) {
getPlaylist();
}
}
void ServerComm::play() {
media->play();
}
void ServerComm::pause() {
media->pause();
}
void ServerComm::next() {
play(++currentSong);
loadSong(++currentSong);
}
void ServerComm::prev() {
if(currentSong > 1) {
play(--currentSong);
if(currentSong > 0) {
loadSong(--currentSong);
}
}
......@@ -45,7 +45,9 @@ public slots:
void login(const QString &username, const QString &password);
void tuneStation(const QString &station);
void getPlaylist();
void play(int song);
void loadSong(int song);
void play();
void pause();
void next();
void prev();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment