chiark / gitweb /
play command
authorRichard Kettlewell <rjk@greenend.org.uk>
Sat, 5 Jun 2010 13:46:04 +0000 (14:46 +0100)
committerRichard Kettlewell <rjk@terraraq.org.uk>
Sat, 6 Aug 2011 17:19:07 +0000 (18:19 +0100)
cgi/actions.c
clients/disorder.c
lib/client-stubs.c
lib/client-stubs.h
lib/client.c
lib/client.h
scripts/protocol

index f6755b0..584da76 100644 (file)
@@ -240,16 +240,17 @@ static void act_play(void) {
   char **tracks;
   int ntracks, n;
   struct tracksort_data *tsd;
+  char *id;
   
   if(dcgi_client) {
     if((track = cgi_get("track"))) {
-      disorder_play(dcgi_client, track);
+      disorder_play(dcgi_client, track, &id);
     } else if((dir = cgi_get("dir"))) {
       if(disorder_files(dcgi_client, dir, 0, &tracks, &ntracks))
         ntracks = 0;
       tsd = tracksort_init(ntracks, tracks, "track");
       for(n = 0; n < ntracks; ++n)
-        disorder_play(dcgi_client, tsd[n].track);
+        disorder_play(dcgi_client, tsd[n].track, &id);
     }
   }
   redirect(0);
index 48745b6..6e2ec14 100644 (file)
@@ -138,8 +138,9 @@ static void cf_playing(char attribute((unused)) **argv) {
 }
 
 static void cf_play(char **argv) {
+  char *id;
   while(*argv)
-    if(disorder_play(getclient(), *argv++)) exit(EXIT_FAILURE);
+    if(disorder_play(getclient(), *argv++, &id)) exit(EXIT_FAILURE);
 }
 
 static void cf_remove(char **argv) {
index de9e6cc..3d02139 100644 (file)
@@ -110,6 +110,10 @@ int disorder_pause(disorder_client *c) {
   return disorder_simple(c, 0, "pause", (char *)0);
 }
 
+int disorder_play(disorder_client *c, const char *track, char **idp) {
+  return dequote(disorder_simple(c, idp, "play", track, (char *)0), idp);
+}
+
 int disorder_playlist_delete(disorder_client *c, const char *playlist) {
   return disorder_simple(c, 0, "playlist-delete", playlist, (char *)0);
 }
index 8182213..13f0724 100644 (file)
@@ -203,6 +203,16 @@ int disorder_part(disorder_client *c, const char *track, const char *context, co
  */
 int disorder_pause(disorder_client *c);
 
+/** @brief Play a track
+ *
+ * Requires the 'play' right.
+ *
+ * @param track Track to play
+ * @param idp Queue ID of new track
+ * @return 0 on success, non-0 on error
+ */
+int disorder_play(disorder_client *c, const char *track, char **idp);
+
 /** @brief Delete a playlist
  *
  * Requires the 'play' right and permission to modify the playlist.
index 33f1d35..1cb73a4 100644 (file)
@@ -522,15 +522,6 @@ int disorder_close(disorder_client *c) {
   return ret;
 }
 
-/** @brief Play a track
- * @param c Client
- * @param track Track to play (UTF-8)
- * @return 0 on success, non-0 on error
- */
-int disorder_play(disorder_client *c, const char *track) {
-  return disorder_simple(c, 0, "play", track, (char *)0);
-}
-
 /** @brief Move a track
  * @param c Client
  * @param track Track to move (UTF-8)
index c4b19e4..4453fc3 100644 (file)
@@ -48,7 +48,6 @@ int disorder_connect_generic(struct config *conf,
                              const char *cookie);
 int disorder_close(disorder_client *c);
 int disorder_version(disorder_client *c, char **versionp);
-int disorder_play(disorder_client *c, const char *track);
 int disorder_remove(disorder_client *c, const char *track);
 int disorder_move(disorder_client *c, const char *track, int delta);
 int disorder_enable(disorder_client *c);
index ac8c0f7..2cfa644 100755 (executable)
@@ -412,6 +412,12 @@ simple("pause",
        "Requires the 'pause' right.",
        []);
 
+string("play",
+       "Play a track",
+       "Requires the 'play' right.",
+       [["track", "Track to play"]],
+       ["id", "Queue ID of new track"]);
+
 # TODO playafter
 
 # TODO playing