From bf4f73249f5b6bf4c9196f251382c5a6cec9634f Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 14 Jul 2010 18:03:32 +0100 Subject: scrub bar almost working - vala Glib value bugs again are biting me --- src/mpris-controller.vala | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/mpris-controller.vala') diff --git a/src/mpris-controller.vala b/src/mpris-controller.vala index c3f21d8..afe9190 100644 --- a/src/mpris-controller.vala +++ b/src/mpris-controller.vala @@ -71,10 +71,6 @@ public class MprisController : GLib.Object MetadataMenuitem.attributes_format()); } - /** - * TRUE => Playing - * FALSE => Paused - **/ public void transport_event(TransportMenuitem.action command) { debug("transport_event input = %i", (int)command); @@ -101,6 +97,21 @@ public class MprisController : GLib.Object } } + public void set_position(double position) + { + debug("Set position with pos (0-100) %f", position); + HashTable data = this.mpris_player.GetMetadata(); + Value? time_value = data.lookup("time"); + if(time_value == null){ + warning("Can't fetch the duration of the track therefore cant set the position"); + return; + } + uint32 total_time = time_value.get_uint32(); + debug("total time of track = %i", (int)total_time); + double new_time_position = total_time * position/100.0; + this.mpris_player.SetPosition((int)(new_time_position * 1000)); + } + public bool connected() { return (this.mpris_player != null); -- cgit v1.2.3