linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ 05/14] client/bluetooth-player: Add play command
Date: Fri, 31 May 2013 13:55:40 +0300	[thread overview]
Message-ID: <1369997749-8663-5-git-send-email-luiz.dentz@gmail.com> (raw)
In-Reply-To: <1369997749-8663-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

Add support for play command which can be used to resume the playback
---
 client/bluetooth-player.c | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/client/bluetooth-player.c b/client/bluetooth-player.c
index e954be0..312adb7 100644
--- a/client/bluetooth-player.c
+++ b/client/bluetooth-player.c
@@ -26,6 +26,7 @@
 #endif
 
 #include <stdio.h>
+#include <stdbool.h>
 #include <errno.h>
 #include <unistd.h>
 #include <stdlib.h>
@@ -75,12 +76,52 @@ static void cmd_quit(int argc, char *argv[])
 	g_main_loop_quit(main_loop);
 }
 
+static bool check_default_player(void)
+{
+	if (!default_player) {
+		rl_printf("No default player available\n");
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
+static void play_reply(DBusMessage *message, void *user_data)
+{
+	DBusError error;
+
+	dbus_error_init(&error);
+
+	if (dbus_set_error_from_message(&error, message) == TRUE) {
+		rl_printf("Failed to play: %s\n", error.name);
+		dbus_error_free(&error);
+		return;
+	}
+
+	rl_printf("Play successful\n");
+}
+
+static void cmd_play(int argc, char *argv[])
+{
+	if (!check_default_player())
+		return;
+
+	if (g_dbus_proxy_method_call(default_player, "Play", NULL, play_reply,
+							NULL, NULL) == FALSE) {
+		rl_printf("Failed to play\n");
+		return;
+	}
+
+	rl_printf("Attempting to play\n");
+}
+
 static const struct {
 	const char *cmd;
 	const char *arg;
 	void (*func) (int argc, char *argv[]);
 	const char *desc;
 } cmd_table[] = {
+	{ "play",         NULL,       cmd_play, "Start playback" },
 	{ "quit",         NULL,       cmd_quit, "Quit program" },
 	{ "exit",         NULL,       cmd_quit },
 	{ "help" },
-- 
1.8.1.4


  parent reply	other threads:[~2013-05-31 10:55 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-31 10:55 [PATCH BlueZ 01/14] build: Add bluetooth-player command line client Luiz Augusto von Dentz
2013-05-31 10:55 ` [PATCH BlueZ 02/14] client/bluetooth-player: Add initial code Luiz Augusto von Dentz
2013-05-31 10:55 ` [PATCH BlueZ 03/14] client/bluetooth-player: Add proxy handling for org.bluez.MediaPlayer1 Luiz Augusto von Dentz
2013-05-31 10:55 ` [PATCH BlueZ 04/14] client/bluetooth-player: Add support for container types to print_iter Luiz Augusto von Dentz
2013-05-31 10:55 ` Luiz Augusto von Dentz [this message]
2013-05-31 10:55 ` [PATCH BlueZ 06/14] client/bluetooth-player: Add pause command Luiz Augusto von Dentz
2013-05-31 10:55 ` [PATCH BlueZ 07/14] client/bluetooth-player: Add stop command Luiz Augusto von Dentz
2013-05-31 10:55 ` [PATCH BlueZ 08/14] client/bluetooth-player: Add next command Luiz Augusto von Dentz
2013-05-31 10:55 ` [PATCH BlueZ 09/14] client/bluetooth-player: Add previous command Luiz Augusto von Dentz
2013-05-31 10:55 ` [PATCH BlueZ 10/14] client/bluetooth-player: Add fast_forward command Luiz Augusto von Dentz
2013-05-31 10:55 ` [PATCH BlueZ 11/14] client/bluetooth-player: Add rewind command Luiz Augusto von Dentz
2013-05-31 10:55 ` [PATCH BlueZ 12/14] client/bluetooth-player: Add list command Luiz Augusto von Dentz
2013-05-31 10:55 ` [PATCH BlueZ 13/14] client/bluetooth-player: Add show command Luiz Augusto von Dentz
2013-05-31 10:55 ` [PATCH BlueZ 14/14] client/bluetooth-player: Add select command Luiz Augusto von Dentz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1369997749-8663-5-git-send-email-luiz.dentz@gmail.com \
    --to=luiz.dentz@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).