43
41
this.controller = controller;
44
42
this.mpris_player = this.connection.get_object ("org.mpris.".concat(name.down()) , "/Player", mpris_interface);
45
43
this.mpris_player.TrackChange += onTrackChange;
46
this.mpris_player.StatusChange += onStatusChange;
47
this.controller.update_playing_info(get_track_data());
50
public HashMap<string, string> get_track_data()
52
return format_metadata(this.mpris_player.GetMetadata());
44
this.mpris_player.StatusChange += onStatusChange;
46
status st = this.mpris_player.GetStatus();
47
int play_state = st.playback;
48
debug("GetStatusChange - play state %i", play_state);
49
(this.controller.custom_items[this.controller.TRANSPORT] as TransportMenuitem).change_play_state(play_state);
50
this.controller.custom_items[this.controller.METADATA].update(this.mpris_player.GetMetadata(),
51
MetadataMenuitem.attributes_format());
55
56
private void onTrackChange(dynamic DBus.Object mpris_client, HashTable<string,Value?> ht)
57
this.controller.update_playing_info(format_metadata(ht));
58
debug("onTrackChange");
59
this.controller.custom_items[this.controller.METADATA].update(ht,
60
MetadataMenuitem.attributes_format());
76
79
private void onStatusChange(dynamic DBus.Object mpris_client, status st)
78
81
debug("onStatusChange - signal received");
79
//ValueArray a = new ValueArray(4);
80
//Value v = new Value(typeof(int32));
81
//v.set_int(st.playback);
83
//debug("onStatusChange - play %i", a.get_nth(0).get_int());
84
//int playback = (ValueArray)st.get_nth(0).get_int();
85
//int shuffle = ar.get_nth(1).get_int();
86
//int repeat = ar.get_nth(2).get_int();
87
//int endless = ar.get_nth(3).get_int();
83
unowned ValueArray ar = (ValueArray)status;
84
int play_state = ar.get_nth(0).get_int();
85
debug("onStatusChange - play state %i", play_state);
86
HashTable<string, Value?> ht = new HashTable<string, Value?>(str_hash, str_equal);
87
Value v = Value(typeof(int));
88
v.set_int(play_state);
89
ht.insert("state", v);
90
this.controller.custom_items[this.controller.TRANSPORT].update(ht, TransportMenuitem.attributes_format());
90
private static HashMap<string, string> format_metadata(HashTable<string,Value?> data)
92
HashMap<string,string> results = new HashMap<string, string>();
93
debug("format_metadata - title = %s", (string)data.lookup("title"));
94
results.set("title", (string)data.lookup("title"));
95
results.set("artist", (string)data.lookup("artist"));
96
results.set("album", (string)data.lookup("album"));
97
results.set("arturl", (string)data.lookup("arturl"));