diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2015-10-15 01:48:03 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2015-10-15 01:48:03 -0400 |
| commit | 6c3355b26f1075863b294fb2049f62b3293558c4 (patch) | |
| tree | 3bbe08142752f314b83a02b7abdf190ff135c4fd /MediaBrowser.Server.Implementations | |
| parent | b830f5f1cf5cf0737c639768ca2ff079f0ab6065 (diff) | |
support drag and drop for playlist items
Diffstat (limited to 'MediaBrowser.Server.Implementations')
| -rw-r--r-- | MediaBrowser.Server.Implementations/Playlists/PlaylistManager.cs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/MediaBrowser.Server.Implementations/Playlists/PlaylistManager.cs b/MediaBrowser.Server.Implementations/Playlists/PlaylistManager.cs index a0d80598a7..e43978fa0a 100644 --- a/MediaBrowser.Server.Implementations/Playlists/PlaylistManager.cs +++ b/MediaBrowser.Server.Implementations/Playlists/PlaylistManager.cs @@ -230,6 +230,27 @@ namespace MediaBrowser.Server.Implementations.Playlists }); } + public async Task MoveItem(string playlistId, string entryId, int newIndex) + { + var playlist = _libraryManager.GetItemById(playlistId) as Playlist; + + if (playlist == null) + { + throw new ArgumentException("No Playlist exists with the supplied Id"); + } + + var children = playlist.GetManageableItems().ToList(); + + var oldIndex = children.FindIndex(i => string.Equals(entryId, i.Item1.Id, StringComparison.OrdinalIgnoreCase)); + + var item = playlist.LinkedChildren[oldIndex]; + + playlist.LinkedChildren.Remove(item); + playlist.LinkedChildren.Insert(newIndex, item); + + await playlist.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false); + } + public Folder GetPlaylistsFolder(string userId) { return _libraryManager.RootFolder.Children.OfType<PlaylistsFolder>() |
