Commit 3ec8bf99 authored by Mike Sheldon's avatar Mike Sheldon

Display current track details and album image in Meego client

parent c33110fe
......@@ -10,6 +10,14 @@ Page {
target: serverComm
onTuned: {
lblStationName.text = stationName;
lblArtist.text = "Fetching playlist..."
}
onPlaying: {
lblArtist.text = artist;
lblSpacer.text = " - "
lblTrack.text = title;
imgCover.source = imageurl
}
}
......@@ -24,12 +32,35 @@ Page {
source: "librefm-logo.png"
anchors.horizontalCenter: parent.horizontalCenter
z: -1
visible: false
}
Label {
id: lblStationName
text: "Tuning in..."
text: " "
anchors.horizontalCenter: parent.horizontalCenter
}
Image {
id: imgCover
source: "empty-album.png"
anchors.horizontalCenter: parent.horizontalCenter
height: 200
width: 200
}
Row {
anchors.horizontalCenter: parent.horizontalCenter
Label {
id: lblArtist
text: "Tuning in..."
}
Label {
id: lblSpacer
}
Label {
id: lblTrack
}
}
ButtonRow {
......@@ -58,6 +89,9 @@ Page {
anchors.centerIn: parent
source: "image://theme/icon-m-toolbar-mediacontrol-previous" + (theme.inverted ? "-inverse" : "")
}
onClicked: {
rootWin.prev();
}
}
Button {
......@@ -95,6 +129,9 @@ Page {
anchors.centerIn: parent
source: "image://theme/icon-m-toolbar-mediacontrol-next" + (theme.inverted ? "-inverse" : "")
}
onClicked: {
rootWin.next();
}
}
Button {
......
......@@ -8,6 +8,8 @@ PageStackWindow {
signal login(string username, string password)
signal tuneStation(string station)
signal next()
signal prev()
function openFile(file) {
var component = Qt.createComponent(file)
......
......@@ -28,6 +28,8 @@ int main(int argc, char *argv[])
view.rootContext()->setContextProperty("serverComm", &sc);
QObject::connect(root, SIGNAL(login(QString, QString)), &sc, SLOT(login(QString, QString)));
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((QObject*)view.engine(), SIGNAL(quit()), &app, SLOT(quit()));
view.showFullScreen();
......
......@@ -14,6 +14,7 @@ ServerComm::ServerComm(QObject *parent) :
ws_url = "http://alpha.libre.fm/2.0/";
playlist = new QList<Track>();
settings = new QSettings("Libre.fm", "Libre.fm");
currentSong = -1;
// Check login details
qDebug() << "Checking settings...";
......@@ -112,7 +113,8 @@ void ServerComm::wsLoginReply(QNetworkReply *reply) {
void ServerComm::tuneStation(const QString &station) {
qDebug() << "Tuning to station: " << station;
// Clear the playlist
playlist = new QList<Track>();
QNetworkAccessManager *tune_netman = new QNetworkAccessManager(this);
connect(tune_netman, SIGNAL(finished(QNetworkReply*)), this, SLOT(tuneReply(QNetworkReply*)));
QUrl url = QUrl(ws_url);
......@@ -178,6 +180,9 @@ void ServerComm::playlistReply(QNetworkReply *reply) {
}
}
}
if(currentSong == -1) {
play(0);
}
}
void ServerComm::parseTrack(QDomNode trackNode) {
......@@ -185,7 +190,7 @@ void ServerComm::parseTrack(QDomNode trackNode) {
for(QDomNode n = trackNode.firstChild(); !n.isNull(); n = n.nextSibling()) {
QDomElement e = n.toElement();
if(!e.isNull()) {
if(e.tagName() == "artist") {
if(e.tagName() == "creator") {
t->artist = e.text();
} else if(e.tagName() == "album") {
t->album = e.text();
......@@ -198,9 +203,25 @@ void ServerComm::parseTrack(QDomNode trackNode) {
}
}
}
qDebug() << "Artist: " << t->artist;
playlist->append(*t);
}
void ServerComm::play(int song) {
Track t = playlist->at(song);
playing(t.artist, t.album, t.title, t.image);
if (song >= playlist->length() - 3) {
getPlaylist();
}
}
void ServerComm::next() {
play(currentSong++);
}
void ServerComm::prev() {
if(currentSong > 1) {
play(currentSong--);
}
}
......@@ -22,6 +22,7 @@ private:
QString scr_url;
QString hs_url;
QString ws_url;
int currentSong;
QSettings *settings;
QList<Track> *playlist;
void parseTrack(QDomNode trackNode);
......@@ -30,6 +31,7 @@ signals:
void loginFailed();
void loginSuccessful();
void tuned(QString stationName);
void playing(QString artist, QString album, QString title, QString imageurl);
private slots:
void wsLoginReply(QNetworkReply *reply);
......@@ -42,6 +44,8 @@ public slots:
void tuneStation(const QString &station);
void getPlaylist();
void play(int song);
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