summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLars-Dominik Braun <PromyLOPh@gmail.com>2008-06-19 15:49:23 +0200
committerLars-Dominik Braun <PromyLOPh@gmail.com>2008-06-19 15:49:23 +0200
commit880a0446c465d22ea3e36db838b8df1e594fa4da (patch)
tree150d66a02b7f99b193b6dda816896d15a190cd5a /src
parent3e76f37c014f867f3b99e482ecb071884322f5d3 (diff)
downloadpianobar-windows-880a0446c465d22ea3e36db838b8df1e594fa4da.tar.gz
pianobar-windows-880a0446c465d22ea3e36db838b8df1e594fa4da.tar.bz2
pianobar-windows-880a0446c465d22ea3e36db838b8df1e594fa4da.zip
"Add more music" implemented
This can add more track/artist seeds to the currently played station
Diffstat (limited to 'src')
-rw-r--r--src/main.c95
1 files changed, 58 insertions, 37 deletions
diff --git a/src/main.c b/src/main.c
index ba6e7b3..89f25b2 100644
--- a/src/main.c
+++ b/src/main.c
@@ -265,6 +265,50 @@ PianoArtist_t *selectArtist (PianoArtist_t *startArtist) {
return tmpArtist;
}
+char *selectMusicId (PianoHandle_t *ph) {
+ char *musicId = NULL, *lineBuf;
+ char yesnoBuf;
+ PianoSearchResult_t searchResult;
+ PianoArtist_t *tmpArtist;
+ PianoSong_t *tmpSong;
+
+ lineBuf = readline ("Search for artist/title\n");
+ if (lineBuf != NULL && strlen (lineBuf) > 0) {
+ PianoSearchMusic (ph, lineBuf, &searchResult);
+ if (searchResult.songs != NULL && searchResult.artists != NULL) {
+ printf ("Is this an [a]rtist or [t]rack name?\n");
+ read (fileno (stdin), &yesnoBuf, sizeof (yesnoBuf));
+ if (yesnoBuf == 'a') {
+ tmpArtist = selectArtist (searchResult.artists);
+ musicId = strdup (tmpArtist->musicId);
+ printf ("Ok.\n");
+ } else if (yesnoBuf == 't') {
+ tmpSong = selectSong (searchResult.songs);
+ musicId = strdup (tmpSong->musicId);
+ printf ("Ok.\n");
+ }
+ } else if (searchResult.songs != NULL) {
+ printf ("Select song\n");
+ tmpSong = selectSong (searchResult.songs);
+ musicId = strdup (tmpSong->musicId);
+ printf ("Ok.\n");
+ } else if (searchResult.artists != NULL) {
+ printf ("Select artist\n");
+ tmpArtist = selectArtist (searchResult.artists);
+ musicId = strdup (tmpArtist->musicId);
+ printf ("Ok.\n");
+ } else {
+ printf ("Nothing found...\n");
+ }
+ PianoDestroySearchResult (&searchResult);
+ }
+ if (lineBuf != NULL) {
+ free (lineBuf);
+ }
+
+ return musicId;
+}
+
int main (int argc, char **argv) {
PianoHandle_t ph;
struct aacPlayer player;
@@ -333,10 +377,7 @@ int main (int argc, char **argv) {
while (!player.finishedPlayback) {
struct pollfd polls = {fileno (stdin), POLLIN, POLLIN};
char buf, yesnoBuf;
- char *lineBuf;
- PianoSearchResult_t searchResult;
- PianoArtist_t *tmpArtist;
- PianoSong_t *tmpSong;
+ char *lineBuf, *musicId;
if (poll (&polls, 1, 1000) > 0) {
read (fileno (stdin), &buf, sizeof (buf));
@@ -345,6 +386,16 @@ int main (int argc, char **argv) {
printf ("n\tnext track\nq\tquit\ns\tchange station\n");
break;
+ case 'a':
+ musicId = selectMusicId (&ph);
+ if (PianoStationAddMusic (&ph, curStation, musicId) == PIANO_RET_OK) {
+ printf ("Added music to station.\n");
+ } else {
+ printf ("Error while adding music to station.\n");
+ }
+ free (musicId);
+ break;
+
case 'b':
player.doQuit = 1;
if (PianoRateTrack (&ph, curStation, curSong,
@@ -359,39 +410,9 @@ int main (int argc, char **argv) {
break;
case 'c':
- lineBuf = readline ("Search for artist/title\n");
- if (lineBuf != NULL && strlen (lineBuf) > 0) {
- PianoSearchMusic (&ph, lineBuf, &searchResult);
- if (searchResult.songs != NULL && searchResult.artists != NULL) {
- printf ("Is this an [a]rtist or [t]rack name?\n");
- read (fileno (stdin), &yesnoBuf, sizeof (yesnoBuf));
- if (yesnoBuf == 'a') {
- tmpArtist = selectArtist (searchResult.artists);
- PianoCreateStation (&ph, tmpArtist->musicId);
- printf ("Ok.\n");
- } else if (yesnoBuf == 't') {
- tmpSong = selectSong (searchResult.songs);
- PianoCreateStation (&ph, tmpSong->musicId);
- printf ("Ok.\n");
- }
- } else if (searchResult.songs != NULL) {
- printf ("Select song\n");
- tmpSong = selectSong (searchResult.songs);
- PianoCreateStation (&ph, tmpSong->musicId);
- printf ("Ok.\n");
- } else if (searchResult.artists != NULL) {
- printf ("Select artist\n");
- tmpArtist = selectArtist (searchResult.artists);
- PianoCreateStation (&ph, tmpArtist->musicId);
- printf ("Ok.\n");
- } else {
- printf ("Nothing found...\n");
- }
- PianoDestroySearchResult (&searchResult);
- }
- if (lineBuf != NULL) {
- free (lineBuf);
- }
+ musicId = selectMusicId (&ph);
+ PianoCreateStation (&ph, musicId);
+ free (musicId);
break;
case 'd':