void LibreFM::update(int) { static int starttime = 0; static bool listening = false; if(listening && proxy->getStatus().playing == SStatus::Stopped) { // track finished listening = false; STags t = proxy->getTags(); int len = t.tag0.length/75; submission(t.tag0.artist, t.tag0.title, starttime, t.tag0.album, len, "P", "", t.tag0.track); } if(proxy->getStatus().playing == SStatus::Playing && proxy->getStatus().pos == .0f) { // track started listening = true; starttime = QDateTime::currentDateTime().toTime_t(); STags t = proxy->getTags(); nowplaying(t.tag0.artist, t.tag0.title, t.tag0.album, t.tag0.length/75, t.tag0.track); } }
void LibreFM::doQueue() { if(stack.size() && !httpGetId && !httpPostId) { QList<QVariant> &item = *stack.begin(); if(item.size() == 0) { handshake(librefmUser, librefmPassword); stack.pop_front(); } else if(item.size() == 1) { //artistInfo(item[0].toString()); //stack.pop_front(); } else if(item.size() == 2) { //albumInfo(item[0].toString(), item[1].toString()); //stack.pop_front(); } else if(item.size() == 6) { nowplaying(item[0].toString(), item[1].toString(), item[2].toString(), item[3].toInt(), item[4].toInt(), item[5].toString()); stack.pop_front(); } else if(item.size() == 9) { submission(item[0].toString(), item[1].toString(), item[2].toInt(), item[3].toString(), item[4].toInt(), item[5].toString(), item[6].toString(), item[7].toInt(), item[8].toString()); stack.pop_front(); } } }
/* * browse_screen - browse database by various attributes */ void browse_screen(http_t *p, int dbid, long sessionid) { lv_t al; tree_t *artists; song_filter_t song_filter; unsigned int ti; /* JDH - topic index */ //tree_t *playlists; DBG_PRINTF("browse_screen\n"); clear_tab_region(); //draw_header(topics[ti].title); /* JDH - indicate the topic we're viewing */ for (ti = 1; ti < 4; ti++) { draw_inactive_tab(topics[ti].titletab); } ti = 0; draw_active_tab(topics[ti].titletab); // artists = getArtists(p, sessionid, dbid); artists = topics[ti].bfp(p, sessionid, dbid); //artists = browseGenres(p, sessionid, dbid); //playlists = getPlaylists(p, sessionid, dbid); DBG_PRINTF("listview_init\n"); listview_init(&al, 25, 50, vid.visx - 50, vid.visy - 97 - 50); DBG_PRINTF("tree_walk\n"); tree_walk(artists, topics[ti].sfp, &al); //tree_walk(playlists, walk_playlists, &al); DBG_PRINTF("tree_delete\n"); tree_delete(artists, topics[ti].dfp); //tree_delete(playlists, playlist_delete); //listview_dump(&al); listview_draw(&al); for (;;) { DBG_PRINTF("get new msg\n"); msg_t *msg = getq(&mainq); int page = 10; switch (msg->type) { case MSG_REMOTE_PREVIOUS: DBG_PRINTF("go back\n"); free(msg); goto exit; case MSG_REMOTE_UP: listview_up(&al); break; case MSG_REMOTE_DOWN: listview_down(&al); break; case MSG_REMOTE_PGUP: page = -10; /* FALLTHROUGH */ case MSG_REMOTE_PGDOWN: { int sdist, ddist; al.selected = listview_move_n(al.selected, page, &sdist); al.draw = listview_move_n(al.draw, sdist, &ddist); if (sdist != ddist) { al.distance += sdist - ddist; } listview_draw(&al); break; } case MSG_REMOTE_SELECT: { memset(&song_filter, 0, sizeof(song_filter_t)); //char *artist = listview_select(&al); //playlist_info_t *playlist = listview_select(&al); switch (ti) { case 0: { playlist_info_t *playlist = listview_select(&al); DBG_PRINTF("artist selected %s\n", playlist->name); song_filter.playlist_id = playlist->id; break; } case 1: song_filter.artist = listview_select(&al); DBG_PRINTF("artist selected %s\n", song_filter.artist); break; case 2: song_filter.album = listview_select(&al); DBG_PRINTF("album selected %s\n", song_filter.album); break; case 3: song_filter.genre = listview_select(&al); DBG_PRINTF("genre selected %s\n", song_filter.genre); break; default: DBG_PRINTF("browse_screen: something went really wrong.\n"); } clear_tab_region(); draw_header("Wait a moment..."); //song_screen(p, dbid, sessionid, 0, artist, NULL); /* JDH - 0 will need to become a plid if playlist selected */ song_screen(p, dbid, sessionid, song_filter); //song_screen(p, dbid, sessionid, playlist->id, NULL, NULL, NULL); /* JDH - 0 will need to become a plid if playlist selected */ DBG_PRINTF("back from song list\n"); /* Keep old list of artists "al"! */ /*listview_find_closest ( &al, artist );*/ //draw_header("Artists"); clear_tab_region(); draw_active_tab(topics[ti].titletab); //draw_header(topics[ti].title); listview_draw(&al); break; } case MSG_REMOTE_LEFT: draw_inactive_tab(topics[ti].titletab); ti = (ti - 1) & 0x03; listview_free(&al, NULL); //draw_header(topics[ti].title); /* JDH - indicate the topic we're viewing */ draw_active_tab(topics[ti].titletab); artists = topics[ti].bfp(p, sessionid, dbid); DBG_PRINTF("listview_init\n"); listview_init(&al, 25, 50, vid.visx - 50, vid.visy - 97 - 50); DBG_PRINTF("tree_walk\n"); tree_walk(artists, topics[ti].sfp, &al); DBG_PRINTF("tree_delete\n"); tree_delete(artists, topics[ti].dfp); listview_draw(&al); break; case MSG_REMOTE_RIGHT: draw_inactive_tab(topics[ti].titletab); ti = (ti + 1) & 0x03; listview_free(&al, NULL); //draw_header(topics[ti].title); /* JDH - indicate the topic we're viewing */ draw_active_tab(topics[ti].titletab); artists = topics[ti].bfp(p, sessionid, dbid); DBG_PRINTF("listview_init\n"); listview_init(&al, 25, 50, vid.visx - 50, vid.visy - 97 - 50); DBG_PRINTF("tree_walk\n"); tree_walk(artists, topics[ti].sfp, &al); DBG_PRINTF("tree_delete\n"); tree_delete(artists, topics[ti].dfp); listview_draw(&al); break; #if 0 { char *artist = listview_select(&al); draw_header("Wait a moment..."); album_screen(p, dbid, sessionid, artist); /* Keep old list of artists "al"! */ /*listview_find_closest ( &al, artist );*/ draw_header("Artists"); listview_draw(&al); break; } #endif case MSG_REMOTE_MUSIC: { nowplaying(); clear_tab_region(); draw_header("Artists"); listview_draw(&al); break; } } DBG_PRINTF("free msg\n"); free(msg); } exit: DBG_PRINTF("free artist list\n"); listview_free(&al, NULL); DBG_PRINTF("quit artist screen\n"); return; }