Exemplo n.º 1
0
/*
 * Shuffles the playlist.
 */
bool
Control::shuffle()
{
	EXIT_IDLE;

	pms->log(MSG_DEBUG, 0, "Shuffling playlist.\n");

	return mpd_run_shuffle(conn->h());
}
Exemplo n.º 2
0
bool
handle_player_command(struct mpdclient *c, command_t cmd)
{
	struct mpd_connection *connection;

	if (!mpdclient_is_connected(c) || c->status == NULL)
		return false;

	cancel_seek_timer();

	switch(cmd) {
		/*
	case CMD_PLAY:
		mpdclient_cmd_play(c, MPD_PLAY_AT_BEGINNING);
		break;
		*/
	case CMD_PAUSE:
		connection = mpdclient_get_connection(c);
		if (connection == NULL)
			break;

		if (!mpd_run_pause(connection,
				   mpd_status_get_state(c->status) != MPD_STATE_PAUSE))
			mpdclient_handle_error(c);
		break;
	case CMD_STOP:
		connection = mpdclient_get_connection(c);
		if (connection == NULL)
			break;

		if (!mpd_run_stop(connection))
			mpdclient_handle_error(c);
		break;
	case CMD_CROP:
		mpdclient_cmd_crop(c);
		break;
	case CMD_SEEK_FORWARD:
		if (!setup_seek(c))
			break;

		seek_target_time += options.seek_time;
		if (seek_target_time > (int)mpd_status_get_total_time(c->status))
			seek_target_time = mpd_status_get_total_time(c->status);
		break;

	case CMD_TRACK_NEXT:
		connection = mpdclient_get_connection(c);
		if (connection == NULL)
			break;

		if (!mpd_run_next(connection))
			mpdclient_handle_error(c);
		break;
	case CMD_SEEK_BACKWARD:
		if (!setup_seek(c))
			break;

		seek_target_time -= options.seek_time;
		if (seek_target_time < 0)
			seek_target_time = 0;
		break;

	case CMD_TRACK_PREVIOUS:
		connection = mpdclient_get_connection(c);
		if (connection == NULL)
			break;

		if (!mpd_run_previous(connection))
			mpdclient_handle_error(c);
		break;
	case CMD_SHUFFLE:
		connection = mpdclient_get_connection(c);
		if (connection == NULL)
			break;

		if (mpd_run_shuffle(connection))
			screen_status_message(_("Shuffled playlist"));
		else
			mpdclient_handle_error(c);
		break;
	case CMD_CLEAR:
		connection = mpdclient_get_connection(c);
		if (connection == NULL)
			break;

		if (mpdclient_cmd_clear(c))
			screen_status_message(_("Cleared playlist"));
		break;
	case CMD_REPEAT:
		connection = mpdclient_get_connection(c);
		if (connection == NULL)
			break;

		if (!mpd_run_repeat(connection,
				    !mpd_status_get_repeat(c->status)))
			mpdclient_handle_error(c);
		break;
	case CMD_RANDOM:
		connection = mpdclient_get_connection(c);
		if (connection == NULL)
			break;

		if (!mpd_run_random(connection,
				    !mpd_status_get_random(c->status)))
			mpdclient_handle_error(c);
		break;
	case CMD_SINGLE:
		connection = mpdclient_get_connection(c);
		if (connection == NULL)
			break;

		if (!mpd_run_single(connection,
				    !mpd_status_get_single(c->status)))
			mpdclient_handle_error(c);
		break;
	case CMD_CONSUME:
		connection = mpdclient_get_connection(c);
		if (connection == NULL)
			break;

		if (!mpd_run_consume(connection,
				     !mpd_status_get_consume(c->status)))
			mpdclient_handle_error(c);
		break;
	case CMD_CROSSFADE:
		connection = mpdclient_get_connection(c);
		if (connection == NULL)
			break;

		if (!mpd_run_crossfade(connection,
				       mpd_status_get_crossfade(c->status) > 0
				       ? 0 : options.crossfade_time))
			mpdclient_handle_error(c);
		break;
	case CMD_DB_UPDATE:
		screen_database_update(c, NULL);
		break;
	case CMD_VOLUME_UP:
		mpdclient_cmd_volume_up(c);
		break;
	case CMD_VOLUME_DOWN:
		mpdclient_cmd_volume_down(c);
		break;

	default:
		return false;
	}

	return true;
}
Exemplo n.º 3
0
void Connection::Shuffle()
{
	prechecksNoCommandsList();
	mpd_run_shuffle(m_connection.get());
	checkErrors();
}