banshee r4010 - in trunk/banshee: . src/Clients/Halie/Halie
- From: abock svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r4010 - in trunk/banshee: . src/Clients/Halie/Halie
- Date: Wed, 28 May 2008 18:34:45 +0000 (UTC)
Author: abock
Date: Wed May 28 18:34:45 2008
New Revision: 4010
URL: http://svn.gnome.org/viewvc/banshee?rev=4010&view=rev
Log:
2008-05-28 Aaron Bockover <abock gnome org>
* src/Clients/Halie/Halie/Client.cs: Added command line support for
mostly fully controlling the engine and the playback controller
Modified:
trunk/banshee/ChangeLog
trunk/banshee/src/Clients/Halie/Halie/Client.cs
Modified: trunk/banshee/src/Clients/Halie/Halie/Client.cs
==============================================================================
--- trunk/banshee/src/Clients/Halie/Halie/Client.cs (original)
+++ trunk/banshee/src/Clients/Halie/Halie/Client.cs Wed May 28 18:34:45 2008
@@ -60,6 +60,7 @@
{
IPlayerEngineService player = DBusServiceManager.FindInstance<IPlayerEngineService> ("/PlayerEngine");
IPlaybackControllerService controller = DBusServiceManager.FindInstance<IPlaybackControllerService> ("/PlaybackController");
+ IDictionary<string, object> track = null;
foreach (KeyValuePair<string, string> arg in ApplicationContext.CommandLine.Arguments) {
switch (arg.Key) {
@@ -76,10 +77,80 @@
case "stop-when-finished":
controller.StopWhenFinished = !ParseBool (arg.Value);
break;
+ default:
+ if (arg.Key.StartsWith ("query-")) {
+ if (track == null) {
+ track = player.CurrentTrack;
+ }
+ HandleQuery (player, track, arg.Key.Substring (6));
+ }
+ break;
}
}
}
+ private static void HandleQuery (IPlayerEngineService player, IDictionary<string, object> track, string query)
+ {
+ // Translate legacy query arguments into new ones
+ switch (query) {
+ case "title": query = "name"; break;
+ case "duration": query = "length"; break;
+ case "uri": query = "URI"; break;
+ }
+
+ switch (query) {
+ case "all":
+ foreach (KeyValuePair<string, object> field in track) {
+ DisplayTrackField (field.Key, field.Value);
+ }
+
+ HandleQuery (player, track, "position");
+ HandleQuery (player, track, "volume");
+ HandleQuery (player, track, "current-state");
+ HandleQuery (player, track, "last-state");
+ HandleQuery (player, track, "can-pause");
+ HandleQuery (player, track, "can-seek");
+ break;
+ case "position":
+ DisplayTrackField ("position", TimeSpan.FromMilliseconds (player.Position).TotalSeconds);
+ break;
+ case "volume":
+ DisplayTrackField ("volume", player.Volume);
+ break;
+ case "current-state":
+ DisplayTrackField ("current-state", player.CurrentState);
+ break;
+ case "last-state":
+ DisplayTrackField ("last-state", player.LastState);
+ break;
+ case "can-pause":
+ DisplayTrackField ("can-pause", player.CanPause);
+ break;
+ case "can-seek":
+ DisplayTrackField ("can-seek", player.CanSeek);
+ break;
+ default:
+ if (track.ContainsKey (query)) {
+ DisplayTrackField (query, track[query]);
+ } else {
+ Error ("'{0}' field unknown", query);
+ }
+ break;
+ }
+ }
+
+ private static void DisplayTrackField (string field, object value)
+ {
+ string result = null;
+ if (value is bool) {
+ result = (bool)value ? "true" : "false";
+ } else {
+ result = value.ToString ();
+ }
+
+ Console.WriteLine ("{0}: {1}", field, result);
+ }
+
private static bool ParseBool (string value)
{
return ParseBool (value, "true", "yes");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]