Player controls
This commit is contained in:
parent
e9b63f5727
commit
53a2e60d87
@ -147,7 +147,7 @@ struct song_metadata dbusGetSong( DBusConnection *conn, const char *player ) {
|
||||
dbus_message_iter_recurse( &variant, &artists );
|
||||
dbus_message_iter_get_basic( &artists, &meta_val );
|
||||
ret.artist = strdup( meta_val );
|
||||
} else {
|
||||
} else if ( dbus_message_iter_get_arg_type( &variant ) == DBUS_TYPE_STRING ) {
|
||||
dbus_message_iter_get_basic( &variant, &meta_val );
|
||||
if ( !strcmp( meta_name, "xesam:title" ) )
|
||||
ret.title = strdup( meta_val );
|
||||
|
37
main.c
37
main.c
@ -10,6 +10,9 @@
|
||||
#define SONG_FLAG 0x0001
|
||||
#define META_FLAG 0x0002
|
||||
#define RUNNING_FLAG 0x0004
|
||||
#define NEXT_FLAG 0x0008
|
||||
#define PREV_FLAG 0x0010
|
||||
#define PLAY_FLAG 0x0020
|
||||
|
||||
#define MPD_FLAG 0x0001
|
||||
#define DBUS_FLAG 0x0002
|
||||
@ -23,6 +26,12 @@ void parseCommandLine( int argc, char **argv, size_t *requests,
|
||||
*requests |= META_FLAG;
|
||||
else if ( !strcmp( argv[i], "status" ) )
|
||||
*requests |= RUNNING_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], "mpd" ) )
|
||||
*sources |= MPD_FLAG;
|
||||
else if ( !strcmp( argv[i], "dbus" ) )
|
||||
@ -82,6 +91,34 @@ int main( int argc, char **argv ) {
|
||||
}
|
||||
}
|
||||
|
||||
if( requests & NEXT_FLAG ) {
|
||||
if( sources & MPD_FLAG )
|
||||
mpdNext( mpd_connection );
|
||||
if( sources & DBUS_FLAG ) {
|
||||
for( char **player = dbus_players; *player; ++player ) {
|
||||
dbusNext( dbus_connection, *player );
|
||||
}
|
||||
}
|
||||
}
|
||||
if( requests & PREV_FLAG ) {
|
||||
if( sources & MPD_FLAG )
|
||||
mpdPrev( mpd_connection );
|
||||
if( sources & DBUS_FLAG ) {
|
||||
for( char **player = dbus_players; *player; ++player ) {
|
||||
dbusPrev( dbus_connection, *player );
|
||||
}
|
||||
}
|
||||
}
|
||||
if( requests & PLAY_FLAG ) {
|
||||
if( sources & MPD_FLAG )
|
||||
mpdPlayPause( mpd_connection );
|
||||
if( sources & DBUS_FLAG ) {
|
||||
for( char **player = dbus_players; *player; ++player ) {
|
||||
dbusPlayPause( dbus_connection, *player );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free( dbus_players );
|
||||
dbusDisconnect( dbus_connection );
|
||||
mpdDisconnect( mpd_connection );
|
||||
|
Loading…
Reference in New Issue
Block a user