# More ways to add tracks to existing/new playlists

**URL:** <https://discourse.indi.software/t/more-ways-to-add-tracks-to-existing-new-playlists/138>\
**Category:** Feature Request\
**Tags:** Done\
**Created:** [August 24, 2022, 8:48am UTC](https://discourse.indi.software/t/more-ways-to-add-tracks-to-existing-new-playlists/138 "2022-08-24T08:48:25Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cleric](https://discourse.indi.software/letter_avatar_proxy/v4/letter/c/c57346/32.png) [@Cleric](https://discourse.indi.software/u/Cleric)\
**Post date:** [August 24, 2022, 8:48am UTC](https://discourse.indi.software/t/more-ways-to-add-tracks-to-existing-new-playlists/138/1 "2022-08-24T08:48:25Z")

</div>

In my workflow I find myself in a need to be able to add the _whole current_ queue to an existing playlist. Usually I play a whole album by _replace-play_ the current queue and then quickly go through it by swipe-deleting the unneeded tracks. What’s left I would like to add to an existing playlist. Currently there are roundabout ways to accomplish this. For example, I can go the the `Playlists` section and add the _target_ playlist _on top_ of the current queue, then return to the queue and save it to the _same_ target playlist.

Another possibility is to work directly with the target playlist loaded in the queue and instead of replace-play the album, add it to the bottom and then remove the unneeded tracks, then save. The reason I prefer adding stuff to existing playlist through the `Add to playlist` functionality is because otherwise it’s easy to accidently replace-play something and then all changes are lost (idea for the future could be to add `Undo` inside the toast message which says that the playlist has been replaced).

A possible way to add this functionality seems by adding `Add to playlist` item in the queue context menu `⋮` (the left image below). This would append the whole current queue to the selected playlist. Possibly the `Save` item becomes unnecessary in that case because one can simply create new playlist from `Add to playlist`.

 ![image](https://discourse.indi.software/uploads/default/original/1X/4a35ab2d8e5893cb2f3494d67457b4652ed610b4.jpeg)

Another thing that may be handy would be to add shortcut for adding a single track from the queue to a playlist (the right image above).

Yet this feature is not that necessary because one can still add the track to a playlist at the price of several more clicks by going to `🛈` and then `⋮` or the track popup menu, and select `Add to playlist`, then tapping `back` to return to the queue. But it will be nice if the `Add to playlist` was accessible directly from the queued track popup.

---

<div class="post-metadata">

**Author:** ![Alex\_B](https://discourse.indi.software/letter_avatar_proxy/v4/letter/a/5f8ce5/32.png) [@Alex\_B](https://discourse.indi.software/u/Alex_B)\
**Post date:** [August 24, 2022, 2:57pm UTC](https://discourse.indi.software/t/more-ways-to-add-tracks-to-existing-new-playlists/138/2 "2022-08-24T14:57:14Z")

</div>

Hi,

Thank you for the detailed description.

Both issues will be addressed in the next MAFA version.

---

<div class="post-metadata">

**Author:** ![Cleric](https://discourse.indi.software/letter_avatar_proxy/v4/letter/c/c57346/32.png) [@Cleric](https://discourse.indi.software/u/Cleric)\
**Post date:** [August 26, 2022, 9:35pm UTC](https://discourse.indi.software/t/more-ways-to-add-tracks-to-existing-new-playlists/138/3 "2022-08-26T21:35:58Z")

</div>

> [@Cleric](#):
>
> Possibly the `Save` item becomes unnecessary in that case because one can simply create new playlist from `Add to playlist`.

On second thought the `Save` item should remain in order to be able to completely rewrite an existing playlist.

---

<div class="post-metadata">

**Author:** ![Alex\_B](https://discourse.indi.software/letter_avatar_proxy/v4/letter/a/5f8ce5/32.png) [@Alex\_B](https://discourse.indi.software/u/Alex_B)\
**Post date:** [September 11, 2022, 12:19pm UTC](https://discourse.indi.software/t/more-ways-to-add-tracks-to-existing-new-playlists/138/4 "2022-09-11T12:19:44Z")

</div>

In the the latest [Release 1.7.8](https://mafa.indi.software/news/release-1.7.8/) the option to add to a playlist was added to the actions dialog:

![image](https://discourse.indi.software/uploads/default/original/1X/aacabf3951770358035f0e9e328a22ebbbfa80a2.png)

There’s now also a warning before replacing the player queue when selecting “Play now”:

![image](https://discourse.indi.software/uploads/default/original/1X/e60d1244ef0d0189ffb250675d76e6a84aaf3af9.png)

Unfortunately, adding the player queue to a playlist (instead of replacing) is not supported by MPD.

---

<div class="post-metadata">

**Author:** ![Cleric](https://discourse.indi.software/letter_avatar_proxy/v4/letter/c/c57346/32.png) [@Cleric](https://discourse.indi.software/u/Cleric)\
**Post date:** [September 14, 2022, 8:59pm UTC](https://discourse.indi.software/t/more-ways-to-add-tracks-to-existing-new-playlists/138/5 "2022-09-14T20:59:01Z")

</div>

Thank you for all the additions in the new version!

> Unfortunately, adding the player queue to a playlist (instead of replacing) is not supported by MPD.

OK, I see. Is there any special reason to avoid simply running `for each` through the queue and adding the tracks one by one to the playlist?

---

<div class="post-metadata">

**Author:** ![Alex\_B](https://discourse.indi.software/letter_avatar_proxy/v4/letter/a/5f8ce5/32.png) [@Alex\_B](https://discourse.indi.software/u/Alex_B)\
**Post date:** [September 15, 2022, 9:14am UTC](https://discourse.indi.software/t/more-ways-to-add-tracks-to-existing-new-playlists/138/6 "2022-09-15T09:14:19Z")

</div>

> [@Cleric](#):
>
> Is there any special reason to avoid simply running `for each` through the queue and adding the tracks one by one to the playlist?

It’s possible but may become unreliable in some edge cases, for example when the queue is very long, or if, during the iteration, changes are made to the queue, or the connection is lost.

Using a command list may be a better workaround:

```shell
command_list_begin
save temp_list
clear
load target_list
load temp_list
rm target_list
save target_list
clear
load temp_list
rm temp_list
command_list_end

```

This might work, except that it will disrupt playback and the queue state will have to be preserved (current track, and player state).

---

<div class="post-metadata">

**Author:** ![Cleric](https://discourse.indi.software/letter_avatar_proxy/v4/letter/c/c57346/32.png) [@Cleric](https://discourse.indi.software/u/Cleric)\
**Post date:** [September 16, 2022, 5:26pm UTC](https://discourse.indi.software/t/more-ways-to-add-tracks-to-existing-new-playlists/138/7 "2022-09-16T17:26:13Z")

</div>

I see, thanks for the explanation. I’m only tangentially familiar with the MPD protocol but would it be possible instead of manipulating lists in the way above, to simply batch-add them in a command list? Something like:

```nohighlight
command_list_begin
playlistadd playlist.m3u "/track-uri1"
playlistadd playlist.m3u "/track-uri2"
playlistadd playlist.m3u "/track-uri3"
...
command_list_end

```

where the `track-uri`s are read from the current queue - either through a MPD command or from your app’s runtime data. Generating the commands from the runtime data may even be preferable because it ensures that the user will be adding to the playlist what they see (in case someone else changes the queue just before the command), and this is what they want to accomplish after all. I imagine that this shouldn’t disrupt playback since it doesn’t manipulate the queue.
