1
public class Tutorial1 {
2
public static int main (string[] args) {
4
* The first part of this program is
5
* commented in tut1.c See that one for
8
var xc = new Xmms.Client("tutorial2");
10
var path = GLib.Environment.get_variable("XMMS_PATH");
11
if (!xc.connect(path)) {
12
GLib.stderr.printf("Could not connect: %s\n", xc.get_last_error());
17
* Now we send a command that will return
18
* a result. Let's find out which entry
19
* is currently playing.
21
* Note that this program has be run while
22
* xmms2 is playing something, otherwise
23
* Xmms.Client.playback_current_id will return 0.
25
var result = xc.playback_current_id();
28
* We are still doing sync operations, wait for the
34
* Also this time we need to check for errors.
35
* Errors can occur on all commands, but not signals
36
* and broadcasts. We will talk about these later.
38
var value = result.get_value();
40
if (value.is_error()) {
41
unowned string error = null;
42
if (value.get_error(out error)) {
43
GLib.stderr.printf("Xmms.Client.playback_current_id returned error: %s\n", error);
49
* Let's retrieve the value from the result struct.
50
* The caveat here is that you have to know what type
51
* of value is returned in response to each command.
53
* In this case we know that Xmms.Client.playback_current_id
56
* Know that all Xmms.Result.get* calls can return FALSE
57
* and that means that the value you are requesting is
58
* not in the result struct.
60
* Values are stored in the pointer passed to result_get
63
if (!value.get_int(out id)) {
64
GLib.stderr.printf("Xmms.Client.playback_current_id didn't return int as expected\n");
69
GLib.stdout.printf("Currently playing id is %d\n", id);