Added ability to save Queue as local Playlist

This commit is contained in:
Davis Mosenkovs 2015-06-15 00:25:04 +03:00 committed by Nick Steel
parent 79e9581bb1
commit 2b4c670ec3
3 changed files with 28 additions and 1 deletions

View File

@ -59,6 +59,7 @@ v2.0.1 (UNRELEASED)
- Support for Mopidy-Grooveshark.
- Fixed slow to start playing from a large tracklist of browsed tracks.
- Added link to `Alarm Clock <https://pypi.python.org/pypi/Mopidy-AlarmClock/>`_ (if present).
- Added ability to save Queue as local Playlist.
v2.0.0 (26-3-2015)
------------------

View File

@ -334,7 +334,8 @@
<!--/browsepane-->
<div data-role="content" class="pane" id="currentpane">
<a style="float:right" onclick="return clearQueue();" data-role="button">Clear</a><h4>Play Queue</h4>
<a style="float:right" onclick="return clearQueue();" data-role="button">Clear</a>
<a style="float:right; margin-right: 0.5em" onclick="return saveQueue();" data-role="button">Save</a><h4>Play Queue</h4>
<!-- <ul data-role="listview" data-icon="false" data-theme="d" data-inset="true" id="currenttable"></ul>
<ul data-role="listview" data-icon="false" data-theme="d" data-inset="true" id="currenttable"></ul> -->
<ul class="table" id="currenttable"></ul>

View File

@ -227,6 +227,31 @@ function clearQueue() {
return false;
}
function saveQueue() {
mopidy.tracklist.getTracks().then(function(tracks) {
if (tracks.length > 0) {
var plname = window.prompt("Playlist name:", "");
if (plname != null && plname.trim() != "") {
plname = plname.trim();
mopidy.playlists.filter({"name": plname}).then(function(existing) {
var exists = false;
for (var i = 0; i < existing.length; i++) {
exists = exists || existing[i].uri.indexOf("m3u:") == 0 || existing[i].uri.indexOf("local:") == 0;
}
if (!exists || window.confirm("Overwrite existing playlist \"" + plname + "\"?")) {
mopidy.playlists.create(plname, "local").then(function(playlist) {
playlist.tracks = tracks;
mopidy.playlists.save(playlist).then();
getPlaylists();
});
}
});
}
}
});
return false;
}
/**********************
* Buttons
*/