Пример #1
0
void gui_input_playlist(int c) {
    int j;

    switch (c) {
    case '-':
        // Move selected forward in playlist
        if (playlist->selected != playlist->head) {
            controller_playlist_move_up();
            gui_update_playlist();
        }
        break;

    case '+':
    case '=':
        // Move selected backwards in playlist
        if (playlist->selected != playlist->tail) {
            controller_playlist_move_down();
            gui_update_playlist();
        }
        break;
    case KEY_ENTER:
    case '\n':
    case '\r':
        if (playlist->playing) {
            playlist->selected = songdata_next_valid(playlist, playlist->head, KEY_HOME);
            playlist->where = 1;
            playlist->wheretop = 0;

            for (j = 0; playlist->selected->next && playlist->selected != playlist->playing; j++) {
                playlist->selected = songdata_next_valid(playlist, playlist->selected->next, KEY_DOWN);
                playlist->where++;
            }
            gui_update_playlist();
        }
        break;
    case KEY_DC:
        // remove selected from playlist
        if (playlist->selected) {
            if (playlist->playing == playlist->selected && playlist->playing->next != NULL) {
                controller_next(playlist);
            } else if (playlist->playing == playlist->selected && playlist->playing->next == NULL) {
                controller_stop();
            }
            songdata_del(playlist, playlist->selected);
            gui_update_playlist();
            gui_update_info();
        }
        break;
    default:
        window_input(playlist_window, c);
        break;
    }
}
Пример #2
0
void
add_to_playlist_recursive ( songdata *list, songdata_song *position, songdata_song *file )
{
	char *prevpwd = NULL;
	songdata *templist = NULL;
	if ( ! ( file->flags & F_DIR ) )
		return;

	templist = malloc( sizeof ( songdata ) );
    memset(templist, 0, sizeof(songdata));
	prevpwd = getcwd ( NULL, 0 );

	songdata_read_mp3_list ( templist, file->fullpath, L_NEW );
	if (templist->selected && !strncmp ( templist->selected->filename, "../", 3 ) )
		templist->selected = templist->head->next; // skip ../ entry

	while ( templist->selected )
	{
		if ( templist->selected->flags & F_DIR )
			add_to_playlist_recursive ( list, list->tail, templist->selected );
		else if ( ! ( templist->selected->flags & F_PLAYLIST ) )
			add_to_playlist ( list, list->tail, templist->selected );

		templist->selected = songdata_next_valid ( templist, templist->selected->next, KEY_DOWN );
	}

	songdata_clear ( templist );
	free ( templist );
	if(chdir ( prevpwd ) != 0){
		//TODO Log this error
	}
	free ( prevpwd );
}
Пример #3
0
void controller_play_pause(void)
{
  if(engine_is_paused()){
    playlist->playing->flags &= ~F_PAUSED;
    engine_resume_playback();
  }else if(engine_is_playing()){
    playlist->playing->flags |= F_PAUSED;
    engine_pause_playback();
  }else{
    if ( !playlist->selected ){
      playlist->selected = songdata_next_valid ( playlist, playlist->top, KEY_DOWN );
    }
    controller_jump_to_song ( playlist->selected ); // Play
  }
  /* GUI stuff */
  gui_update_playlist();
  gui_update_info();
  gui_update_playback();
}