diff options
author | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2013-06-03 22:57:36 +0700 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2013-06-10 11:06:45 +0300 |
commit | d8d4f1699de79bef232c1280fd0738bb4c3363a3 (patch) | |
tree | 8b37e0ffb00dd7651b33da23a25272d2bbd39328 /tools/bluetooth-player.c | |
parent | e742b25652574607b1952652918f13f868554d3e (diff) | |
download | bluez-d8d4f1699de79bef232c1280fd0738bb4c3363a3.tar.gz |
tools/bluetooth-player: Add item argument to play command
Add item argument to play command so it can be used to e.g. jump to
different item in the playlist.
Diffstat (limited to 'tools/bluetooth-player.c')
-rw-r--r-- | tools/bluetooth-player.c | 52 |
1 files changed, 37 insertions, 15 deletions
diff --git a/tools/bluetooth-player.c b/tools/bluetooth-player.c index e17d49c96..91e3ea598 100644 --- a/tools/bluetooth-player.c +++ b/tools/bluetooth-player.c @@ -105,8 +105,44 @@ static void play_reply(DBusMessage *message, void *user_data) rl_printf("Play successful\n"); } +static GDBusProxy *find_item(const char *path) +{ + GSList *l; + + for (l = items; l; l = g_slist_next(l)) { + GDBusProxy *proxy = l->data; + + if (strcmp(path, g_dbus_proxy_get_path(proxy)) == 0) + return proxy; + } + + return NULL; +} + +static void cmd_play_item(int argc, char *argv[]) +{ + GDBusProxy *proxy; + + proxy = find_item(argv[1]); + if (proxy == NULL) { + rl_printf("Item %s not available\n", argv[1]); + return; + } + + if (g_dbus_proxy_method_call(proxy, "Play", NULL, play_reply, + NULL, NULL) == FALSE) { + rl_printf("Failed to play\n"); + return; + } + + rl_printf("Attempting to play %s\n", argv[1]); +} + static void cmd_play(int argc, char *argv[]) { + if (argc > 1) + return cmd_play_item(argc, argv); + if (!check_default_player()) return; @@ -431,20 +467,6 @@ static GDBusProxy *find_folder(const char *path) return NULL; } -static GDBusProxy *find_item(const char *path) -{ - GSList *l; - - for (l = items; l; l = g_slist_next(l)) { - GDBusProxy *proxy = l->data; - - if (strcmp(path, g_dbus_proxy_get_path(proxy)) == 0) - return proxy; - } - - return NULL; -} - static void cmd_show(int argc, char *argv[]) { GDBusProxy *proxy; @@ -710,7 +732,7 @@ static const struct { { "list", NULL, cmd_list, "List available players" }, { "show", "[player]", cmd_show, "Player information" }, { "select", "<player>", cmd_select, "Select default player" }, - { "play", NULL, cmd_play, "Start playback" }, + { "play", "[item]", cmd_play, "Start playback" }, { "pause", NULL, cmd_pause, "Pause playback" }, { "stop", NULL, cmd_stop, "Stop playback" }, { "next", NULL, cmd_next, "Jump to next item" }, |