Add check if player is currently playing
This commit is contained in:
parent
7ba31e247b
commit
d94fa07ec2
29
main.c
29
main.c
@ -13,6 +13,8 @@
|
||||
#define NEXT_FLAG 0x0008
|
||||
#define PREV_FLAG 0x0010
|
||||
#define PLAY_FLAG 0x0020
|
||||
#define STOP_FLAG 0x0040
|
||||
#define PLAYING_FLAG 0x0080
|
||||
|
||||
#define MPD_FLAG 0x0001
|
||||
#define DBUS_FLAG 0x0002
|
||||
@ -24,14 +26,19 @@ void parseCommandLine( int argc, char **argv, size_t *requests,
|
||||
*requests |= SONG_FLAG;
|
||||
else if ( !strcmp( argv[i], "info" ) )
|
||||
*requests |= META_FLAG;
|
||||
else if ( !strcmp( argv[i], "status" ) )
|
||||
else if ( !strcmp( argv[i], "status" ) ||
|
||||
!strcmp( argv[i], "running" ) )
|
||||
*requests |= RUNNING_FLAG;
|
||||
else if ( !strcmp( argv[i], "playing" ) )
|
||||
*requests |= PLAYING_FLAG;
|
||||
else if ( !strcmp( argv[i], "next" ) )
|
||||
*requests |= NEXT_FLAG;
|
||||
else if ( !strcmp( argv[i], "prev" ) || !strcmp( argv[i], "previous" ) )
|
||||
*requests |= PREV_FLAG;
|
||||
else if ( !strcmp( argv[i], "play" ) || !strcmp( argv[i], "pause" ) )
|
||||
*requests |= PLAY_FLAG;
|
||||
else if ( !strcmp( argv[i], "stop" ) )
|
||||
*requests |= STOP_FLAG;
|
||||
else if ( !strcmp( argv[i], "mpd" ) )
|
||||
*sources |= MPD_FLAG;
|
||||
else if ( !strcmp( argv[i], "dbus" ) )
|
||||
@ -93,6 +100,17 @@ int main( int argc, char **argv ) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( requests & PLAYING_FLAG ) {
|
||||
ret = EXIT_FAILURE;
|
||||
if ( sources & MPD_FLAG && mpdPlaying( mpd_connection ) )
|
||||
ret = EXIT_SUCCESS;
|
||||
if ( sources & DBUS_FLAG ) {
|
||||
for ( char **player = dbus_players; *player; ++player ) {
|
||||
if ( dbusPlaying( dbus_connection, *player ) )
|
||||
ret = EXIT_SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( requests & NEXT_FLAG ) {
|
||||
if ( sources & MPD_FLAG )
|
||||
@ -121,6 +139,15 @@ int main( int argc, char **argv ) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( requests & STOP_FLAG ) {
|
||||
if ( sources & MPD_FLAG )
|
||||
mpdStop( mpd_connection );
|
||||
if ( sources & DBUS_FLAG ) {
|
||||
for ( char **player = dbus_players; *player; ++player ) {
|
||||
dbusStop( dbus_connection, *player );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( sources & DBUS_FLAG ) {
|
||||
dbusFreePlyaers( dbus_players );
|
||||
|
Loading…
Reference in New Issue
Block a user