Functions | |
Ecore_Timer * | mpc_init (const char *hostname, int port, const char *password, void *data) |
Init a connection to the mpd daemon. | |
void | mpc_signal_connect_status_changed (void *data) |
Connect a Emphasis_Gui to mpd status signals. | |
int | mpc_update (void *data) |
Update the mpd connection. | |
void | status_changed_callback (MpdObj *mo, ChangedStatusType what, void *data) |
Global callback call when the mpd status change. | |
int | mpc_assert_status (MpdState status) |
Check the current status of the mpd daemon. | |
Evas_List * | mpc_mlib_artist_get (void) |
Get the artists list from mpd database. | |
Evas_List * | mpc_mlib_album_get (char *artist) |
Get an albums list of artist from mpd database. | |
Evas_List * | mpc_mlib_track_get (char *album, char *artist) |
Get a list of song matching artist and album. | |
void | mpc_playlist_add (Evas_List *list) |
Add to the current playlist a list of songs. | |
void | mpc_playlist_add_song (const char *file, int commit) |
Add to the current playlist a song. | |
void | mpc_playlist_delete (Evas_List *list) |
Delete the id of the mpd playlist. | |
void | mpc_playlist_clear (void) |
Clear mpd playlist. | |
void | mpc_playlist_commit (void) |
Commit new mpd playlist. | |
void | mpc_playlist_shuffle (void) |
Shuffle current mpd playlist. | |
void | mpc_play_id (int id) |
Play the song with id id. | |
void | mpc_play (void) |
Play the current song. | |
void | mpc_pause (void) |
Pause the current song. | |
void | mpc_stop (void) |
Stop the playing. | |
void | mpc_prev (void) |
Play the previous song. | |
void | mpc_next (void) |
Play the next song. | |
void | mpc_seek (double percent) |
Get mpd play the song at percent. | |
void | mpc_toggle_play_pause (void) |
Toggle play/pause status on mpd. | |
void | mpc_toggle_random (void) |
Toggle the random mode on mpd. | |
void | mpc_toggle_repeat (void) |
Toggle the repeat mode on mpd. | |
int | mpc_get_vol (void) |
Get mpd volume value. | |
void | mpc_change_vol (int value) |
Changed mpd volume level. | |
Variables | |
MpdObj * | mo |
It's the global object using the connexion to the mpd daemon. | |
MpdObj * | mo |
It's the global object using the connexion to the mpd daemon. |
int mpc_assert_status | ( | MpdState | status | ) |
Check the current status of the mpd daemon.
status | Asserted daemon status |
00290 { 00291 MpdState current_state; 00292 00293 current_state = mpd_player_get_state(mo); 00294 if (current_state == status) 00295 { 00296 return TRUE; 00297 } 00298 else 00299 { 00300 return FALSE; 00301 } 00302 }
Ecore_Timer* mpc_init | ( | const char * | hostname, | |
int | port, | |||
const char * | password, | |||
void * | data | |||
) |
Init a connection to the mpd daemon.
hostname | the mpd daemon hostname | |
port | the port it use | |
password | the password to be used, NULL if it hasn't |
00013 { 00014 Ecore_Timer *timer; 00015 00016 mo = mpd_new((char *) hostname, port, (char *) password); 00017 if (!mpd_connect(mo)) 00018 { 00019 mpd_send_password(mo); 00020 mpc_signal_connect_status_changed(data); 00021 timer = ecore_timer_add(0.2, mpc_update, NULL); 00022 } 00023 else 00024 { 00025 timer = NULL; 00026 } 00027 00028 return timer; 00029 }
Evas_List* mpc_mlib_album_get | ( | char * | artist | ) |
Get an albums list of artist from mpd database.
artist | An artist name |
00328 { 00329 MpdData *data; 00330 Evas_List *list; 00331 00332 data = mpd_database_get_albums(mo, artist); 00333 list = convert_mpd_data(data); 00334 00335 mpd_data_free(data); 00336 return list; 00337 }
Evas_List* mpc_mlib_artist_get | ( | void | ) |
Get the artists list from mpd database.
00310 { 00311 MpdData *data; 00312 Evas_List *list; 00313 00314 data = mpd_database_get_artists(mo); 00315 list = convert_mpd_data(data); 00316 00317 mpd_data_free(data); 00318 return list; 00319 }
Evas_List* mpc_mlib_track_get | ( | char * | artist, | |
char * | album | |||
) |
Get a list of song matching artist and album.
artist | An artist name | |
album | An album name |
00347 { 00348 MpdData *data; 00349 Evas_List *list; 00350 00351 if ((album != NULL) || (artist != NULL)) 00352 { 00353 data = 00354 mpd_database_find_adv(mo, 1, MPD_TAG_ITEM_ARTIST, artist, 00355 MPD_TAG_ITEM_ALBUM, album, -1); 00356 } 00357 else 00358 { 00359 data = mpd_database_get_complete(mo); 00360 } 00361 list = convert_mpd_data(data); 00362 00363 mpd_data_free(data); 00364 return list; 00365 }
void mpc_play_id | ( | int | id | ) |
Play the song with id id.
id | An id of one of the songs in the playlist |
00469 { 00470 mpd_player_play_id(mo, id); 00471 }
void mpc_playlist_add | ( | Evas_List * | list | ) |
Add to the current playlist a list of songs.
list | A list of songs |
00386 { 00387 long long id; 00388 Emphasis_Data *data; 00389 Evas_List *first; 00390 00391 first = list; 00392 id = mpd_playlist_get_playlist_id(mo); 00393 00394 while (list) 00395 { 00396 data = evas_list_data(list); 00397 mpd_playlist_queue_add(mo, data->song->file); 00398 list = evas_list_next(list); 00399 } 00400 00401 mpd_playlist_queue_commit(mo); 00402 list = first; 00403 }
void mpc_playlist_add_song | ( | const char * | file, | |
int | commit | |||
) |
Add to the current playlist a song.
file | The song file | |
commit | Set if mpd will add song now |
00412 { 00413 mpd_playlist_queue_add(mo, (char*)file); 00414 if(commit) { mpd_playlist_queue_commit(mo); } 00415 }
void mpc_playlist_delete | ( | Evas_List * | list | ) |
Delete the id of the mpd playlist.
id |
00423 { 00424 Emphasis_Data *data; 00425 00426 while (list) 00427 { 00428 data = evas_list_data(list); 00429 mpd_playlist_queue_delete_id(mo, data->song->id); 00430 list = evas_list_next(list); 00431 } 00432 mpd_playlist_queue_commit(mo); 00433 emphasis_list_free(list); 00434 }
void mpc_seek | ( | double | percent | ) |
void mpc_signal_connect_status_changed | ( | void * | data | ) |
Connect a Emphasis_Gui to mpd status signals.
data | A Emphasis_Gui |
00100 { 00101 mpd_signal_connect_status_changed(mo, 00102 (StatusChangedCallback) 00103 status_changed_callback, data); 00104 mpd_signal_connect_connection_changed(mo, 00105 (ConnectionChangedCallback) 00106 mpc_connection_changed, data); 00107 }
int mpc_update | ( | void * | data | ) |
Update the mpd connection.
data | the callback data |
00116 { 00117 UNUSED(data) 00118 00119 mpd_status_update(mo); 00120 return 1; 00121 }
void status_changed_callback | ( | MpdObj * | mo, | |
ChangedStatusType | what, | |||
void * | data | |||
) |
Global callback call when the mpd status change.
mo | The mpd connection | |
what | Type of the changed status | |
data | A Emphasis_Gui |
00131 { 00132 static int refresh_info = 1; 00133 Emphasis_Player_Gui *player; 00134 Emphasis_Song *song = NULL; 00135 MpdState state; 00136 int elapsed_time, total_time, vol_value; 00137 MpdData *playlist; 00138 00139 player = ((Emphasis_Gui *)data)->player; 00140 00141 if (what & MPD_CST_VOLUME) 00142 { 00143 vol_value = mpd_status_get_volume(mo); 00144 emphasis_player_vol_slider_set(player, vol_value); 00145 } 00146 if (what & MPD_CST_ELAPSED_TIME) 00147 { 00148 elapsed_time = mpd_status_get_elapsed_song_time(mo); 00149 total_time = mpd_status_get_total_song_time(mo); 00150 emphasis_player_progress_set(player, (float) elapsed_time, total_time); 00151 /* dirty hack */ 00152 if(!mpd_status_db_is_updating(mo) && refresh_info) 00153 { 00154 song = mpc_playlist_get_current_song(); 00155 emphasis_player_info_set(player, song, NULL); 00156 emphasis_song_free(song); 00157 refresh_info = 0; 00158 } 00159 } 00160 if (what & MPD_CST_UPDATING) 00161 { 00162 if(mpc_assert_status(MPD_STATUS_STATE_STOP)) 00163 { 00164 emphasis_player_info_set(player, NULL, "Updating"); 00165 } 00166 else 00167 { 00168 song = mpc_playlist_get_current_song(); 00169 emphasis_player_info_set(player, song, "updating"); 00170 emphasis_song_free(song); 00171 } 00172 } 00173 if (what & MPD_CST_DATABASE) 00174 { 00175 char *tree_title; 00176 Etk_Tree *tree = ETK_TREE(player->media.artist); 00177 00178 tree_title = etk_object_data_get(ETK_OBJECT(tree), "title"); 00179 emphasis_tree_mlib_init(player, EMPHASIS_ARTIST); 00180 etk_tree_col_title_set(etk_tree_nth_col_get(tree,0), tree_title); 00181 00182 song = mpc_playlist_get_current_song(); 00183 emphasis_player_info_set(player, song, NULL); 00184 emphasis_song_free(song); 00185 } 00186 if (what & MPD_CST_RANDOM) 00187 { 00188 if (mpd_player_get_random(mo)) 00189 { 00190 emphasis_player_toggle_random(player, TRUE); 00191 } 00192 else 00193 { 00194 emphasis_player_toggle_random(player, FALSE); 00195 } 00196 } 00197 if (what & MPD_CST_REPEAT) 00198 { 00199 if (mpd_player_get_repeat(mo)) 00200 { 00201 emphasis_player_toggle_repeat(player, TRUE); 00202 } 00203 else 00204 { 00205 emphasis_player_toggle_repeat(player, FALSE); 00206 } 00207 } 00208 if (what & MPD_CST_STATE) 00209 { 00210 state = mpd_player_get_state(mo); 00211 switch (state) 00212 { 00213 case MPD_STATUS_STATE_STOP: 00214 emphasis_player_info_set(player, NULL, "Music Stoped"); 00215 emphasis_player_toggle_play(player); 00216 emphasis_pls_mark_current(ETK_TREE(player->media.pls), -1); 00217 break; 00218 case MPD_STATUS_STATE_PAUSE: 00219 song = mpc_playlist_get_current_song(); 00220 emphasis_player_toggle_play(player); 00221 emphasis_player_info_set(player, song, "paused"); 00222 emphasis_song_free(song); 00223 break; 00224 case MPD_STATUS_STATE_PLAY: 00225 song = mpc_playlist_get_current_song(); 00226 emphasis_player_toggle_play(player); 00227 emphasis_player_info_set(player, song, NULL); 00228 emphasis_pls_mark_current(ETK_TREE(player->media.pls), song->id); 00229 emphasis_song_free(song); 00230 refresh_info = 1; 00231 break; 00232 case MPD_STATUS_STATE_UNKNOWN: 00233 emphasis_player_info_set(player, NULL, "wtf is that ?"); 00234 break; 00235 } 00236 } 00237 if (what & MPD_CST_PLAYLIST) 00238 { 00239 Evas_List *emphasis_playlist; 00240 00241 playlist = mpd_playlist_get_changes(mo, -1); 00242 emphasis_playlist = convert_mpd_data(playlist); 00243 emphasis_tree_pls_set(ETK_TREE(player->media.pls), emphasis_playlist); 00244 00245 // emphasis_list_free(emphasis_playlist); 00246 mpd_data_free(playlist); 00247 } 00248 if (what & MPD_CST_SONGID) 00249 { 00250 song = mpc_playlist_get_current_song(); 00251 if (song) 00252 { 00253 emphasis_player_info_set(player, song, NULL); 00254 emphasis_pls_mark_current(ETK_TREE(player->media.pls), song->id); 00255 emphasis_cover_change((Emphasis_Gui *) data, 00256 song->artist, 00257 song->album); 00258 00259 emphasis_song_free(song); 00260 } 00261 } 00262 }