Ejemplo n.º 1
0
int cmd_play ( int argc, char ** argv, mpd_Connection * conn )
{
	int song;
	int i;

	if(0==argc) song = MPD_PLAY_AT_BEGINNING;
	else {
		mpd_Status *status;

		for(i=0;i<argc-1;i++)
			printf("skipping: %s\n",argv[i]);

                if(!parse_songnum(argv[i], &song))
			DIE("error parsing song numbers from: %s\n",argv[i]);

		song--;

		/* This is necessary, otherwise mpc will output the wrong playlist number */
		status = getStatus(conn);
		i = status->playlistLength;
		mpd_freeStatus(status);
		if(song >= i)
			DIE("song number greater than playlist length.\n");
	}

	mpd_sendPlayCommand(conn,song);
	my_finishCommand(conn);

	return 1;
}
Ejemplo n.º 2
0
int cmd_play ( int argc, char ** argv, struct mpd_connection *conn )
{
	int song;
	int i;

	if(0==argc) song = -1;
	else {
		struct mpd_status *status;

		for(i=0;i<argc-1;i++)
			printf("skipping: %s\n",argv[i]);

                if(!parse_songnum(argv[i], &song))
			DIE("error parsing song numbers from: %s\n",argv[i]);

		song--;

		/* This is necessary, otherwise mpc will output the wrong playlist number */
		status = getStatus(conn);
		i = mpd_status_get_queue_length(status);
		mpd_status_free(status);
		if(song >= i)
			DIE("song number greater than playlist length.\n");
	}

	if (song >= 0)
		mpd_run_play_pos(conn, song);
	else
		mpd_run_play(conn);

	return 1;
}
Ejemplo n.º 3
0
Archivo: command.c Proyecto: daaang/mpc
int
cmd_play(int argc, char **argv, struct mpd_connection *conn)
{
	assert(argc < 2);

	bool success;
	if (argc > 0) {
		const char *string = argv[0];
		int song;
		if (!parse_songnum(string, &song))
			DIE("error parsing song numbers from: %s\n", string);

		song--;

		success = mpd_run_play_pos(conn, song);
	} else
		success = mpd_run_play(conn);

	if (!success)
		printErrorAndExit(conn);

	return 1;
}