void stream_encoders::update_metadata(const file_info&p_info){ metadata.remove_all(); pfc::string artist,title; for (unsigned i=0;i<p_info.meta_get_count();i++) { pfc::string name = p_info.meta_enum_name(i); for (unsigned j=0;j<p_info.meta_enum_value_count(i);j++){ pfc::string value = p_info.meta_enum_value(i,j); pfc::string buffer=name+"="+value; metadata.add_item(buffer); if(pfc::string::g_equalsCaseInsensitive(name,"artist")) artist=value; if(pfc::string::g_equalsCaseInsensitive(name,"title")) title=value; } } pfc::string meta=artist+" - "+title; for(unsigned i=0;i<enc_list.get_count();++i){ strcpy(enc_list[i]->config->gSongTitle,(char*)meta.ptr()); enc_list[i]->config->ice2songChange=true; updateSongTitle(enc_list[i]->config,0); } }
void updateGUI() { // update gui components: // + song played and total time // + song title scroll thing // + song position bar // + shuffle state // + repeat state // + volume // song title scroll thing updateSongTitle(); if (status == NULL) return; char *timeline = (char*)malloc(32); sprintf(timeline,"%02i:%02i:%02i/%02i:%02i:%02i",status->elapsedTime/3600,status->elapsedTime/60,status->elapsedTime%60,status->totalTime/3600,status->totalTime/60,status->totalTime%60); drawPicture(screen,"songtimebg.bmp",80,20); drawText(screen, timeline, 80, 20, 255, 255, 255); char *infoline = (char*)malloc(32); sprintf(infoline, "%d Kbps/%d kHz", status->bitRate, status->sampleRate); drawPicture(screen,"songinfobg.bmp",80,40); drawText(screen, infoline, 80, 40, 255, 255, 255); float perc = status->elapsedTime<status->totalTime ?100.0*status->elapsedTime/status->totalTime :100.0; drawPicture(screen,"songposbg.bmp",20,120); drawPicture(screen,"cursor.bmp",(int)(20 + (perc * 3)),120); if (status->random == 0) { drawPicture(screen,"shuffle_false.bmp",20,160); } else { drawPicture(screen,"shuffle_true.bmp",20,160); } if (status->repeat == 0) { drawPicture(screen,"repeat_false.bmp",160,160); } else { drawPicture(screen,"repeat_true.bmp",160,160); } drawPicture(screen,"volumebg.bmp",200,200); drawPicture(screen,"cursor.bmp",200 + status->volume,200); free(timeline); free(infoline); }
void mpdConnect() { char *hostname = strdup(config->mpd_hostname); int port = config->mpd_hostport; int timeout = config->mpd_timeout; conn = mpd_newConnection(hostname,port,timeout); if(conn->error) { strcpy(songname, conn->errorStr); scrollpos = 0; updateSongTitle(); mpd_closeConnection(conn); } }