Save Queue
authorBenjamin H盲ublein <BenjaminHae@users.noreply.github.com>
Wed, 2 Sep 2015 17:24:52 +0000 (19:24 +0200)
committerBenjamin H盲ublein <BenjaminHae@users.noreply.github.com>
Wed, 2 Sep 2015 17:47:58 +0000 (19:47 +0200)
htdocs/index.html
htdocs/js/mpd.js
src/mpd_client.c
src/mpd_client.h

index 3ba6a7e..a035d4f 100644 (file)
             <button type="button" class="btn btn-default" onclick="socket.send('MPD_API_RM_ALL');">
               <span class="glyphicon glyphicon-trash"></span> Clear queue
             </button>
+            <a href="#" data-toggle="modal" data-target="#savequeue" class="btn btn-default">
+              <span class="glyphicon glyphicon-save"></span> Save queue
+            </a>
           </div>
 
              <div id="btn-responsive-block" class="btn-group-vertical btn-block btn-group-lg" data-toggle="buttons">
       </div><!-- /.modal-content -->
     </div><!-- /.modal-dialog -->
   </div><!-- /.modal -->
+  
+  <div class="modal fade" id="savequeue" tabindex="-1" role="dialog" aria-labelledby="savequeueLabel" aria-hidden="true">
+    <div class="modal-dialog">
+      <div class="modal-content">
+        <div class="modal-header">
+          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
+          <h2 class="modal-title" id="savequeueLabel"><span class="glyphicon glyphicon-wrench"></span> Save Queue</h2>
+        </div>
+        <div class="modal-body">
+          <form role="form">
+            <div class="row">
+              <div class="form-group col-md-9">
+                <label class="control-label" for="playlistname">Playlist Name</label>
+                <input type="text" class="form-control" id="playlistname" />
+              </div>
+            </div>
+          </form>
+        </div>
+        <div class="modal-footer">
+          <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
+          <button type="button" class="btn btn-default" onclick="saveQueue();">Save Queue</button>
+        </div>
+      </div><!-- /.modal-content -->
+    </div><!-- /.modal-dialog -->
+  </div><!-- /.modal -->
 
   <div class="modal fade bs-example-modal-sm" id="wait" tabindex="-1" role="dialog" data-backdrop="static" data-keyboard="false" aria-hidden="true">
     <div class="modal-dialog">
index 49a4656..9ff7a81 100644 (file)
@@ -576,6 +576,13 @@ function addStream() {
     $('#addstream').modal('hide');
 }
 
+function saveQueue() {
+    if($('#playlistname').val().length > 0) {
+       socket.send('MPD_API_SAVE_QUEUE,'+$('#playlistname').val());
+    }
+    $('#savequeue').modal('hide');
+}
+
 function confirmSettings() {
     if($('#mpd_pw').val().length + $('#mpd_pw_con').val().length > 0) {
         if ($('#mpd_pw').val() !== $('#mpd_pw_con').val())
index ee49c84..8e5454e 100644 (file)
@@ -169,6 +169,18 @@ out_play_track:
 out_playlist:
             free(p_charbuf);
             break;
+        case MPD_API_SAVE_QUEUE:
+            p_charbuf = strdup(c->content);
+            if(strcmp(strtok(p_charbuf, ","), "MPD_API_SAVE_QUEUE"))
+                goto out_save_queue;
+
+            if((token = strtok(NULL, ",")) == NULL)
+                goto out_save_queue;
+
+            mpd_run_save(mpd.conn, token);
+out_save_queue:
+            free(p_charbuf);
+            break;
         case MPD_API_SEARCH:
             p_charbuf = strdup(c->content);
             if(strcmp(strtok(p_charbuf, ","), "MPD_API_SEARCH"))
index 165bb5b..001cfdc 100644 (file)
@@ -44,6 +44,7 @@
     X(MPD_API_ADD_PLAY_TRACK) \
     X(MPD_API_ADD_PLAYLIST) \
     X(MPD_API_PLAY_TRACK) \
+    X(MPD_API_SAVE_QUEUE) \
     X(MPD_API_RM_TRACK) \
     X(MPD_API_RM_ALL) \
     X(MPD_API_SEARCH) \