Пример #1
0
static void queue_song(ttk_menu_item *item)
{
	mpd_InfoEntity entity;

	if (mpdc_tickle() < 0)
		return;
	mpd_sendSearchCommand(mpdz, (long)item->data, item->name);

	if (mpdz->error) {
		mpdc_tickle();
		return;
	}

	while ((mpd_getNextInfoEntity_st(&entity, mpdz))) {
		int found = 1;
		mpd_Song *song = entity.info.song;
		if (entity.type != MPD_INFO_ENTITY_TYPE_SONG) {
				continue;
		}
		found &= (!current_song.artist || (song->artist &&
				strcmp(current_song.artist,song->artist)==0));
		found &= (!current_song.album || (song->album &&
				strcmp(current_song.album, song->album) == 0));
		found &= ((song->title ? (strcmp(item->name, song->title)==0) :
				0) || strcmp(item->name, song->file)==0);
		if (found && song->file) {
			mpd_finishCommand(mpdz);
			mpd_sendAddCommand(mpdz, song->file);
			break;
		}
	}
	mpd_finishCommand(mpdz);
}
Пример #2
0
int mpd_playlist_queue_commit(MpdObj *mi)
{
	if(mi->queue == NULL)
	{
		debug_printf(DEBUG_WARNING,"mi->queue is empty");
		return MPD_PLAYLIST_QUEUE_EMPTY;
	}
	if(!mpd_check_connected(mi))
	{
		debug_printf(DEBUG_WARNING,"not connected\n");
		return MPD_NOT_CONNECTED;
	}
	if(mpd_lock_conn(mi))
	{
		debug_printf(DEBUG_WARNING,"lock failed\n");
		return  MPD_LOCK_FAILED;
	}
	mpd_sendCommandListBegin(mi->connection);
	/* get first item */
	mi->queue = mi->queue->first;
	while(mi->queue != NULL)
	{
		if(mi->queue->type == MPD_QUEUE_ADD)
		{
			if(mi->queue->path != NULL)
			{
				mpd_sendAddCommand(mi->connection, mi->queue->path);
			}
		}
		else if(mi->queue->type == MPD_QUEUE_LOAD)
		{
			if(mi->queue->path != NULL)
			{
				mpd_sendLoadCommand(mi->connection, mi->queue->path);
			}
		}
		else if (mi->queue->type == MPD_QUEUE_DELETE_ID)
		{
			if(mi->queue->id >= 0)
			{
				mpd_sendDeleteIdCommand(mi->connection, mi->queue->id);
			}
		}
		else if (mi->queue->type == MPD_QUEUE_DELETE_POS)
		{                                                                      		
			if(mi->queue->id >= 0)
			{
				mpd_sendDeleteCommand(mi->connection, mi->queue->id);
			}
		}


		mpd_queue_get_next(mi);
	}
	mpd_sendCommandListEnd(mi->connection);
	mpd_finishCommand(mi->connection);
	mpd_unlock_conn(mi);
	mpd_status_update(mi);
	return MPD_OK;
}
Пример #3
0
static void queue_song(const char *path)
{
	if (mpdc_tickle() < 0)
		return;

	mpd_sendAddCommand(mpdz, path);
	mpd_finishCommand(mpdz);

	if (mpdz->error)
		mpdc_tickle();
}
Пример #4
0
int cmd_add (int argc, char ** argv, mpd_Connection * conn )
{
	int i;

	mpd_sendCommandListBegin(conn);
	printErrorAndExit(conn);

	for(i=0;i<argc;i++) {
		printf("adding: %s\n", argv[i]);
		mpd_sendAddCommand(conn, charset_to_utf8(argv[i]));
		printErrorAndExit(conn);
	}

	mpd_sendCommandListEnd(conn);
	my_finishCommand(conn);

	return 0;
}