Zeugma440 / atldotnet

Fully managed, portable and easy-to-use C# library to read and edit audio data and metadata (tags) from various audio formats, playlists and CUE sheets
MIT License
460 stars 61 forks source link

Playlist API simplification #233

Closed Zeugma440 closed 12 months ago

Zeugma440 commented 1 year ago

It'd also be nice if you could add a Save function to the PlaylistIO API.

Currently if we want to add or remove paths from a playlist we have to do:

var paths = _playlist.FilePaths;
paths.Remove(0);
paths.Add("Test.mp3");
paths.Add("Test2.mp3");
_playlist.FilePaths = paths;

since it is the setter of FilePaths that causes the changes to be written to the actually playlist file on disk.

It'd be nice to have a more friendly API such as the following:

_playlist.FilePaths.Remove(0);
_playlist.FilePaths.Add("Test.mp3");
_playlist.FilePaths.Add("Test2.mp3");
_playlist.Save();

I mean currently, we can do this:

_playlist.FilePaths.Remove(0);
_playlist.FilePaths.Add("Test.mp3");
_playlist.FilePaths.Add("Test2.mp3");
_playlist.FilePaths = _playlist.FilePaths;

but, as I said before, since the FilePaths setter is what writes the changes, it feels cumbersome doing it this way.

Zeugma440 commented 1 year ago

Not sure I wanna do this, as it would require my Playlist class to store and compare values, which introduces too much complexity for the sake of a slightly better API. The tradeoff looks bad to me.

Would you accept to settle for something like :

var paths = _playlist.FilePaths;
paths.Remove(0);
paths.Add("Test.mp3");
paths.Add("Test2.mp3");
_playlist.Save(paths);
nlogozzo commented 1 year ago

that works :)

Zeugma440 commented 12 months ago

Available on today's v5.09