Differences
This shows you the differences between two versions of the page.
Next revision | Previous revisionLast revisionBoth sides next revision | ||
dbus_api [2008/10/17 22:31] – created squentin | dbus_api [2011/03/14 07:56] – satoshi | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | =====DBus API===== | ||
+ | Quick documentation of the DBus APi. | ||
+ | If you need more info, you are invited to look at the file gmusicbrowser_dbus.pm or you can of course contact me (Quentin) | ||
+ | |||
+ | More functions wil be added in the future (suggestions welcome). | ||
+ | |||
+ | These functions can be used in other programs, or through the dbus-send command-line program. | ||
+ | |||
+ | examples using dbus-send : | ||
+ | * To toggle play/pause state : | ||
+ | < | ||
+ | * To gets info for the current song : | ||
+ | < | ||
+ | * To get current song position : | ||
+ | < | ||
+ | |||
+ | The output of dbus-send is not very easy to parse, so you might want to use this small perl script instead : | ||
+ | < | ||
+ | # | ||
+ | use warnings; | ||
+ | use strict; | ||
+ | use Net::DBus; | ||
+ | |||
+ | my $bus = Net:: | ||
+ | my $service = $bus-> | ||
+ | my $object = $service-> | ||
+ | |||
+ | my $info= $object-> | ||
+ | print "$_ : $info-> | ||
+ | print " | ||
+ | </ | ||
+ | It will print the info and position of the current song, it can also easily be modified to suit your needs. | ||
+ | |||
+ | ====Functions==== | ||
+ | |||
+ | ==RunCommand== | ||
+ | Takes a string as argument, this string is the name of a command with optional arguments. | ||
+ | |||
+ | See the output of "'' | ||
+ | |||
+ | No return value | ||
+ | |||
+ | ==CurrentSong== | ||
+ | no arguments | ||
+ | |||
+ | returns a hash/ | ||
+ | |||
+ | More fields may be added in future versions. | ||
+ | |||
+ | ==GetPosition== | ||
+ | no arguments | ||
+ | |||
+ | returns the position in the current song in seconds | ||
+ | |||
+ | ==Playing== | ||
+ | no arguments | ||
+ | |||
+ | returns a boolean, true if playing, false if stopped/ | ||
+ | |||
+ | ==Set== | ||
+ | Takes 3 strings as arguments: | ||
+ | * path/ | ||
+ | * field to change | ||
+ | * new value | ||
+ | |||
+ | returns true if succeeded, false if failed (in particular if the song couldn' | ||
+ | |||
+ | Be careful with this function, the new value is not checked for validity as much as it should be. | ||
+ | |||
+ | ==Get== | ||
+ | Takes 2 strings as argument: | ||
+ | * path/ | ||
+ | * field | ||
+ | |||
+ | returns the value of the field | ||
+ | |||
+ | ==GetLibrary== | ||
+ | no arguments | ||
+ | |||
+ | returns the list of songs ID in the library | ||
+ | |||
+ | ==GetAlbumCover== | ||
+ | takes a string as argument | ||
+ | |||
+ | returns the filename of the cover if the string match an album name that has a cover | ||
+ | |||
+ | //Note that the filename of the cover may be a mp3 file with an embedded cover.// | ||
+ | |||
+ | //May change in future versions with the support of multiple albums with the same name.// | ||
+ | |||
+ | |||
+ | ====Signals==== | ||
+ | ==SongChanged== | ||
+ | Emitted when the current song changes with the song ID of the new song as argument. | ||
+ | |||
+ | |||