Add playlists menu
authorHugo Villeneuve <hugo@hugovil.com>
Thu, 5 Jan 2023 21:44:56 +0000 (16:44 -0500)
committerHugo Villeneuve <hugo@hugovil.com>
Sat, 7 Jan 2023 00:33:26 +0000 (19:33 -0500)
htdocs/index.html
htdocs/js/mpd.js
src/mpd_client.c

index 57ca034..9ec53b4 100644 (file)
@@ -45,6 +45,7 @@
         </div>
         <div class="collapse navbar-collapse">
           <ul id="nav_links" class="nav navbar-nav">
+           <li id="playlists"><a href="#/playlists/0/">Playlists</a></li>
             <li id="queue"><a href="#/">Queue</a></li>
             <li id="browse"><a href="#/browse/0/">Browse</a></li>
             <li>
index 708aaa9..8b571e2 100644 (file)
@@ -62,6 +62,27 @@ var app = $.sammy(function () {
         runBrowse();
     });
 
+    this.get(/\#\/playlists\/(\d+)\/(.*)/, function () {
+        prepare();
+       browsepath = this.params['splat'][1];
+        pagination = parseInt(this.params['splat'][0]);
+       current_app = 'browse';
+        $('#breadcrump').addClass('hide');
+        $('#salamisandwich').removeClass('hide').find('tr:gt(0)').remove();
+        $('#filter').addClass('hide');
+        $('#filter').empty();
+        socket.send(
+            'MPD_API_GET_BROWSE,' +
+                pagination +
+                ',' +
+                (browsepath ? browsepath : '/')
+        );
+
+        $('#panel-heading').text('Playlists');
+        $('#panel-heading-info').empty();
+        $('#playlists').addClass('active');
+    });
+
     this.get(/\#\/browse\/(\d+)\/(.*)/, function () {
         prepare();
         browsepath = this.params['splat'][1];
index ac594bc..c3601ee 100644 (file)
@@ -232,12 +232,13 @@ int callback_mpd(struct mg_connection *c) {
             if (strcmp(strtok(p_charbuf, ","), "MPD_API_ADD_PLAYLIST"))
                 goto out_playlist;
 
+            uint_buf = strtoul(strtok(NULL, ","), NULL, 10);
             if ((token = strtok(NULL, ",")) == NULL)
                 goto out_playlist;
 
             free(p_charbuf);
             p_charbuf = strdup(c->content);
-            mpd_run_load(mpd.conn, get_arg1(p_charbuf));
+            n = mpd_put_playlist(mpd.buf, get_arg2(p_charbuf), uint_buf);
         out_playlist:
             free(p_charbuf);
             break;