git.gnu.io has moved to IP address 209.51.188.249 -- please double check where you are logging in.

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

Add support for pausing and resuming tracks

parent 7c8f3e25
...@@ -112,11 +112,13 @@ Page { ...@@ -112,11 +112,13 @@ Page {
onClicked: { onClicked: {
if (imgPlay.visible) { if (imgPlay.visible) {
imgPlay.visible = false rootWin.play();
imgPause.visible = true imgPlay.visible = false;
imgPause.visible = true;
} else { } else {
imgPlay.visible = true rootWin.pause();
imgPause.visible = false imgPlay.visible = true;
imgPause.visible = false;
} }
} }
......
...@@ -10,6 +10,8 @@ PageStackWindow { ...@@ -10,6 +10,8 @@ PageStackWindow {
signal tuneStation(string station) signal tuneStation(string station)
signal next() signal next()
signal prev() signal prev()
signal play()
signal pause()
function openFile(file) { function openFile(file) {
var component = Qt.createComponent(file) var component = Qt.createComponent(file)
......
...@@ -31,6 +31,8 @@ int main(int argc, char *argv[]) ...@@ -31,6 +31,8 @@ int main(int argc, char *argv[])
QObject::connect(root, SIGNAL(tuneStation(QString)), &sc, SLOT(tuneStation(QString))); QObject::connect(root, SIGNAL(tuneStation(QString)), &sc, SLOT(tuneStation(QString)));
QObject::connect(root, SIGNAL(next()), &sc, SLOT(next())); QObject::connect(root, SIGNAL(next()), &sc, SLOT(next()));
QObject::connect(root, SIGNAL(prev()), &sc, SLOT(prev())); 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())); QObject::connect((QObject*)view.engine(), SIGNAL(quit()), &app, SLOT(quit()));
view.showFullScreen(); view.showFullScreen();
......
...@@ -185,7 +185,7 @@ void ServerComm::playlistReply(QNetworkReply *reply) { ...@@ -185,7 +185,7 @@ void ServerComm::playlistReply(QNetworkReply *reply) {
} }
} }
if(currentSong == -1) { if(currentSong == -1) {
play(0); loadSong(0);
} }
} }
...@@ -211,25 +211,33 @@ void ServerComm::parseTrack(QDomNode trackNode) { ...@@ -211,25 +211,33 @@ void ServerComm::parseTrack(QDomNode trackNode) {
playlist->append(*t); playlist->append(*t);
} }
void ServerComm::play(int song) { void ServerComm::loadSong(int song) {
currentSong = song; currentSong = song;
Track t = playlist->at(song); Track t = playlist->at(song);
playing(t.artist, t.album, t.title, t.image); playing(t.artist, t.album, t.title, t.image);
QUrl url(t.location); QUrl url(t.location);
media->setCurrentSource(url); media->setCurrentSource(url);
media->play(); play();
if (song >= playlist->length() - 3) { if (song >= playlist->length() - 3) {
getPlaylist(); getPlaylist();
} }
} }
void ServerComm::play() {
media->play();
}
void ServerComm::pause() {
media->pause();
}
void ServerComm::next() { void ServerComm::next() {
play(++currentSong); loadSong(++currentSong);
} }
void ServerComm::prev() { void ServerComm::prev() {
if(currentSong > 1) { if(currentSong > 0) {
play(--currentSong); loadSong(--currentSong);
} }
} }
...@@ -45,7 +45,9 @@ public slots: ...@@ -45,7 +45,9 @@ public slots:
void login(const QString &username, const QString &password); void login(const QString &username, const QString &password);
void tuneStation(const QString &station); void tuneStation(const QString &station);
void getPlaylist(); void getPlaylist();
void play(int song); void loadSong(int song);
void play();
void pause();
void next(); void next();
void prev(); 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