Esempio n. 1
0
int mpd_player_pause(MpdObj * mi)
{
	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;
	}

	if (mpd_player_get_state(mi) == MPD_PLAYER_PAUSE) {
		mpd_sendPauseCommand(mi->connection, 0);
		mpd_finishCommand(mi->connection);
	} else if (mpd_player_get_state(mi) == MPD_PLAYER_PLAY) {
		mpd_sendPauseCommand(mi->connection, 1);
		mpd_finishCommand(mi->connection);
	}


	mpd_unlock_conn(mi);
	if (mpd_status_update(mi)) {
		return MPD_STATUS_FAILED;
	}
	return MPD_OK;
}
Esempio n. 2
0
void mpdc_playpause()
{
	int state;
	if (mpdc_tickle() < 0)
		return;
	if ((state = mpdc_status(mpdz)) < 0)
		return;
	if (state == MPD_STATUS_STATE_PLAY)
		mpd_sendPauseCommand(mpdz, 1);
	else if (state == MPD_STATUS_STATE_PAUSE)
		mpd_sendPauseCommand(mpdz, 0);
	else
		mpd_sendPlayCommand(mpdz, -1);
	mpd_finishCommand(mpdz);
}
Esempio n. 3
0
int
cmd_pause(mpd_unused int argc, mpd_unused char **argv, mpd_Connection *conn)
{
	mpd_sendPauseCommand(conn,1);
	my_finishCommand(conn);

	return 1;
}
Esempio n. 4
0
File: mpd.c Progetto: mattx86/aprq2
/*
=================
MPD_Pause - pause playback
=================
*/
void MPD_Pause(void)
{
	if(!MP3_Status())
		return;

	mpd_sendPauseCommand(conn, 1);
	mpd_finishCommand(conn);

	MPD_Status();
}
Esempio n. 5
0
static void
_mpdule_cb_pause (void *data, Evas_Object * obj, const char *emission,
		  const char *source)
{
  Instance *inst;
  mpd_Connection *mpd;

  inst = data;
  mpd = inst->mpd;
  mpd_sendPauseCommand (mpd, 1);
}
Esempio n. 6
0
void mpdclient_pause(int state) {
	mpd_Status *status;

	if (state == 1) {
		mpd_sendPauseCommand(conn, state);
		mpd_finishCommand(conn);
		return;
	}

	/* If we are stopped, start playing */
	mpd_sendStatusCommand(conn);
	status = mpd_getStatus(conn);
	if (status->state == MPD_STATUS_STATE_STOP &&
			status->playlistLength > 0) {
		mpd_sendPlayCommand(conn, 0);
		//music_song_active(0);
		//music_playlist_autoscroll(0, 1);
	}
	else
		mpd_sendPauseCommand(conn, 0);

	mpd_finishCommand(conn);
}
Esempio n. 7
0
int main(int argc, char **argv)
{
	char *configfilename = "/etc/mpc2x.conf";
	config = config_file(configfilename);
	
	bool quit = false;

	// Init SDL
	SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_VIDEO | SDL_INIT_TIMER);
	// Prepare screen for GP2X
	screen = SDL_SetVideoMode( WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_DEPTH, SDL_SWSURFACE);
	if(!screen) {
		printf("SDL_SetVideoMode screen not initialised: %s\n",SDL_GetError());
		shutdown();
	}
	// Set window title, which we don't need on gp2x
	SDL_WM_SetCaption(WINDOW_TITLE, 0 );
	// Disable mouse cursus
	SDL_ShowCursor(SDL_DISABLE);

	// initialise the font stuff
	TTF_Init();

	// load the ttf font to be used
	char *fontpath = (char*) malloc(100);
	strcpy(fontpath,config->skin_path); // assume the font is in the skin path, should do this other way!
	strcat(fontpath,config->font_path);
	font = TTF_OpenFont(fontpath, 16);
	free(fontpath);
	// Initialize the joystick
	SDL_JoystickOpen(0);

	songname = "........Not connected or no song playing at the moment...........";
	scrollpos = 0;
	mpdConnect();
	buildGUI();
	updateGUI();
	
	#define SONGTITLEINTERVAL 10
	int interval = 0;

	while (!quit)
	{
		SDL_Delay(100);
		interval++;
		if (interval == SONGTITLEINTERVAL) {
			mpdGetSongTitle();
			interval = 0;
			}

		updateGUI();
		
		SDL_Event event;
		while( SDL_PollEvent( &event ) )
		{
			switch( event.type )
			{
				case SDL_JOYBUTTONUP:
					drawText(screen, "[ |< ]", 20, 200, 255, 255, 255);
					drawText(screen, "[>/||]", 80, 200, 255, 255, 255);
					drawText(screen, "[ >| ]", 140, 200, 255, 255, 255);
					SDL_Flip(screen);
					break;
				case SDL_JOYBUTTONDOWN:
					switch( event.jbutton.button )
					{
						case GP2X_BUTTON_VOLUP :
						// volume up
							mpd_sendSetvolCommand(conn, status->volume + 5);
							mpd_finishCommand(conn);
							break;
						case GP2X_BUTTON_VOLDOWN :
						// volume down
							mpd_sendSetvolCommand(conn, status->volume - 5);
							mpd_finishCommand(conn);
							break;
						case GP2X_BUTTON_A :
						// play/pause
							if(status->state == MPD_STATUS_STATE_PLAY)
							{
								mpd_sendPauseCommand(conn,1);
							}
							else if(status->state == MPD_STATUS_STATE_PAUSE || status->state == MPD_STATUS_STATE_STOP)
							{
								mpd_sendPauseCommand(conn,0);
							}
							mpd_finishCommand(conn);
							drawText(screen, "[>/||]", 80, 200, 255, 255, 0);
							SDL_Flip(screen);
							break;
						case GP2X_BUTTON_R :
						// next track
							mpd_sendNextCommand(conn);
							mpd_finishCommand(conn);
							drawText(screen, "[ >| ]", 140, 200, 255, 255, 0);
							SDL_Flip(screen);
							break;
						case GP2X_BUTTON_L :
						// prev track
							mpd_sendPrevCommand(conn);
							mpd_finishCommand(conn);
							drawText(screen, "[ |< ]", 20, 200, 255, 255, 0);
							SDL_Flip(screen);
							break;
						case GP2X_BUTTON_Y :
						// shuffle toggle
							if(status->random == 0)
							{
								mpd_sendRandomCommand(conn,1);
							}
							else
							{
								mpd_sendRandomCommand(conn,0);
							}
							mpd_finishCommand(conn);
							break;
						case GP2X_BUTTON_B :
						// repeat toggle
							if(status->repeat == 0)
							{
								mpd_sendRepeatCommand(conn,1);
							}
							else
							{
								mpd_sendRepeatCommand(conn,0);
							}
							mpd_finishCommand(conn);
							break;
						case GP2X_BUTTON_START :
						// quit
						 	quit=true;
							break;
						case GP2X_BUTTON_SELECT :
						// cycle other screens
							break;
						case GP2X_BUTTON_RIGHT :
						// forward in song
							mpd_sendSeekCommand(conn, status->song, status->elapsedTime + 5);
							mpd_finishCommand(conn);
							break;
						case GP2X_BUTTON_LEFT :
						// backward in song
							mpd_sendSeekCommand(conn, status->song, status->elapsedTime - 5);
							mpd_finishCommand(conn);
							break;
						default:
							break;
					}
					break;
				case SDL_KEYDOWN:
					switch( event.key.keysym.sym )
					{
						case SDLK_KP_PLUS :
						// volume up
							mpd_sendSetvolCommand(conn, status->volume + 5);
							mpd_finishCommand(conn);
							break;
						case SDLK_KP_MINUS :
						// volume down
							mpd_sendSetvolCommand(conn, status->volume - 5);
							mpd_finishCommand(conn);
							break;
						case SDLK_SPACE :
						// play/pause
							if(status->state == MPD_STATUS_STATE_PLAY)
							{
								mpd_sendPauseCommand(conn,1);
							}
							else if(status->state == MPD_STATUS_STATE_PAUSE || status->state == MPD_STATUS_STATE_STOP)
							{
								mpd_sendPauseCommand(conn,0);
							}
							mpd_finishCommand(conn);
							drawText(screen, "[>/||]", 80, 200, 255, 255, 0);
							SDL_Flip(screen);
							break;
						case SDLK_RIGHT	:
						// next track
							mpd_sendNextCommand(conn);
							mpd_finishCommand(conn);
							drawText(screen, "[ >| ]", 140, 200, 255, 255, 0);
							SDL_Flip(screen);
							break;
						case SDLK_LEFT :
						// prev track
							mpd_sendPrevCommand(conn);
							mpd_finishCommand(conn);
							drawText(screen, "[ |< ]", 20, 200, 255, 255, 0);
							SDL_Flip(screen);
							break;
						case SDLK_s :
						// shuffle toggle
							if(status->random == 0)
							{
								mpd_sendRandomCommand(conn,1);
							}
							else
							{
								mpd_sendRandomCommand(conn,0);
							}
							mpd_finishCommand(conn);
							break;
						case SDLK_r :
						// repeat toggle
							if(status->repeat == 0)
							{
								mpd_sendRepeatCommand(conn,1);
							}
							else
							{
								mpd_sendRepeatCommand(conn,0);
							}
							mpd_finishCommand(conn);
							break;
						case SDLK_ESCAPE :
						// quit
						 	quit=true;
							break;
						case SDLK_TAB :
						// cycle other screens
							break;
						case SDLK_UP :
						// forward in song
							mpd_sendSeekCommand(conn, status->song, status->elapsedTime + 5);
							mpd_finishCommand(conn);
							break;
						case SDLK_DOWN :
						// backward in song
							mpd_sendSeekCommand(conn, status->song, status->elapsedTime - 5);
							mpd_finishCommand(conn);
							break;
						default:
							break;
					}
					break;
			}
		}
	}

	shutdown();
	return 0;
}