static gboolean
gimmix_update_song_info (gpointer data)
{
	GimmixStatus status;
	
	if (mpd_status_db_is_updating (gmo))
		return TRUE;
	else
		return FALSE;
	
	/* Set the new song info */
	status = gimmix_get_status (gmo);
	if (status == PLAY || status == PAUSE)
		gimmix_set_song_info ();

	return FALSE;
}
Beispiel #2
0
void status_changed(MpdObj *mi, ChangedStatusType what,  thread_data *my_data)
{
    if(what&MPD_CST_SONGID)
    {
        mpd_Song *song = mpd_playlist_get_current_song(mi);
        if(song)
        {
            printf( "Song:"" %s - %s\n", song->artist, song->title);
        }
    }

    if(what&MPD_CST_REPEAT){
        printf("Repeat:"" %s\n", mpd_player_get_repeat(mi)? "On":"Off");
    }
    if(what&MPD_CST_RANDOM){
        printf("Random:"" %s\n", mpd_player_get_random(mi)? "On":"Off");
    }
    if(what&MPD_CST_VOLUME){
        printf("Volume:"" %03i%%\n",
               mpd_status_get_volume(mi));

        my_data->mainLCD->printVolume(mpd_status_get_volume(mi));
        try
        {
            my_data->ptr_MPD_info->volume= mpd_status_get_volume(mi);
        }
        catch (...)
        {
            log_file_mutex.mutex_lock();
            log_file_cout << ERROR << "problem z wpisaniem volume "<<   std::endl;
            log_file_mutex.mutex_unlock();
        }
    }
    if(what&MPD_CST_CROSSFADE){
        printf("X-Fade:"" %i sec.\n",
               mpd_status_get_crossfade(mi));
    }
    if(what&MPD_CST_UPDATING)
    {
        if(mpd_status_db_is_updating(mi))
        {
            printf("Started updating DB""\n");
        }
        else
        {
            printf("Updating DB finished""\n");
        }
    }
    if(what&MPD_CST_DATABASE)
    {
        printf("Databased changed""\n");
    }
    if(what&MPD_CST_PLAYLIST)
    {
        printf("Playlist changed2""\n");
        if (check_title_song_to==true)
        {
            mpd_Song *song = mpd_playlist_get_current_song(mi);
            // std::cout <<" SONG: " << song->artist<<" "<< song->title << std::endl;
            printf("aktualnie gramy:"" %s - %s\n", song->artist, song->title);

            try
            {
                my_data->ptr_MPD_info->title = std::string( song->title);
            }
            catch (...)
            {
                my_data->myEventHandler.run("mpd")->addEvent("wrong title");
                my_data->ptr_MPD_info->title = "no data";
            }
            try
            {
                my_data->ptr_MPD_info->artist = std::string( song->artist);
            }
            catch (...)
            {
                my_data->myEventHandler.run("mpd")->addEvent("wrong artist");
                my_data->ptr_MPD_info->artist = "no data";
            }

            if (song->name != NULL){
                _msg =  song->name;

                try
                {
                    my_data->ptr_MPD_info->radio = _msg;
                }
                catch (...)
                {
                    my_data->myEventHandler.run("mpd")->addEvent("wrong radio station name");
                }
                my_data->mainLCD->printRadioName(true,0,0,_msg);
                my_data->mainLCD->set_lcd_STATE(5);
                std::string temp_str="";
                temp_str = send_to_arduino(my_data,"temperature:2;");
                temp_str.erase(temp_str.size()-2,temp_str.size());
                my_data->mainLCD->printString(false,0,1,"temp:"+temp_str+" c");

                updatePlayList(mi,my_data);
            }

            if (song->title != NULL ){
                _msg =  song->title;
                if (_msg.size() < 7 )
                {
                    _msg =  song->name;
                    _msg += " -     brak nazwy                ";
                }
            }
            else if (song->artist != NULL){
                _msg = song->artist;
            }
            else
            {
                _msg += " -     brak nazwy      ";
            }
            // my_data->ptr_MPD_info->title = _msg;
            my_data->mainLCD->printSongName(_msg);
        }
    }
    if(what&MPD_CST_STATE)
    {
        printf("State:");
        switch(mpd_player_get_state(mi))
        {
        case MPD_PLAYER_PLAY:
            printf("Playing\n");
            check_title_song_to=true;
            my_data->mainLCD->play_Y_N=true;
            my_data->ptr_MPD_info->isPlay=true;
            digitalWrite(GPIO_SPIK, LOW);
            my_data->mainLCD->set_lcd_STATE(1);
            my_data->mainLCD->song_printstr();
            updatePlayList(mi,my_data);
            my_data->myEventHandler.run("mpd")->addEvent("MPD playing");
            break;
        case MPD_PLAYER_PAUSE:
            printf("Paused\n");
            my_data->mainLCD->set_lcd_STATE( -1);
            my_data->mainLCD->printString(true ,0,1,"    PAUSE");
            my_data->myEventHandler.run("mpd")->addEvent("MPD pause");
            break;
        case MPD_PLAYER_STOP:
            printf("Stopped\n");
            if (my_data->ptr_MPD_info->isPlay ==true){
                send_to_arduino(my_data,"LED_CLEAR:44;");
            }
            check_title_song_to=false;
            my_data->mainLCD->play_Y_N=false;
            my_data->ptr_MPD_info->isPlay=false;
            my_data->ptr_MPD_info->title="* * * *";
            digitalWrite(GPIO_SPIK,HIGH);
            my_data->mainLCD->noBacklight();
            sleep(1);
            my_data->myEventHandler.run("mpd")->addEvent("MPD stopped");
            break;
        default:
            break;
        }
    }
    /* not yet implemented signals */
    if(what&MPD_CST_AUDIO){
        printf("Audio Changed""\n");
    }
    if(what&MPD_CST_TOTAL_TIME){
        printf("Total song time changed:"" %02i:%02i\n",
               mpd_status_get_total_song_time(mi)/60,
               mpd_status_get_total_song_time(mi)%60);
    }
    if(what&MPD_CST_ELAPSED_TIME){
        /*  printf(GREEN"Time elapsed changed:"RESET" %02i:%02i\n",
mpd_status_get_elapsed_song_time(mi)/60,
mpd_status_get_elapsed_song_time(mi)%60);
*/  }
    if(what&MPD_CST_PERMISSION){
        printf( "Permission:"" Changed\n");
    }
}