elementary / music

Music player and library designed for elementary OS
https://elementary.io
GNU General Public License v3.0
145 stars 49 forks source link

Open entire folder from Files #709

Closed Oowoosh0 closed 1 year ago

Oowoosh0 commented 2 years ago

Problem

Currently it is not possible to right click on a folder in Files and open it in Music, so that all audio files in that folder get put into the playlist. You have to enter the folder, select all files and then open them in with Music which seem like an overcomplicated way of doing that.

Proposal

Make it possible to just open an entire folder with Music and have all audio files in that folder appear in the queue.

Prior Art (Optional)

No response

jeremypw commented 1 year ago

Need to amend the .descktop for this app to indicate that it accepts a folder as a commandline argument (and add the code so that it does!)

ghost commented 1 year ago

As a workaround, select all files in that folder, right click, and use "open with music".

Can I work on this? Would it be just modify the .desktop file? If so, in what way? Any code changes needed? I would say so but it should be as simple if the selected file is a folder, and if it is, open all files from it.

jeremypw commented 1 year ago

Would it be just modify the .desktop file? If so, in what way? Any code changes needed? I would say so but it should be as simple if the selected file is a folder, and if it is, open all files from it.

Essentially yes, that is the approach. You would have to deal with the cases that the folder contains no music files or a ridiculously large number of files though.

jeremypw commented 1 year ago

I guess you would have to amend the "MimeTypes" key. See https://specifications.freedesktop.org/desktop-entry-spec/latest/ar01s06.html. The mimetype of a folder is inode/directory

ghost commented 1 year ago

I see we need to support many scenarios, like opening a folder from file explorer, dragging a folder onto the app, and m3u8 files. Isn't there a way to abstract the code so it can support more formats in the future?

jeremypw commented 1 year ago

I'll try and review your PR in the near future. I imagine that some functions can be abstracted into a utility class that can be easily accessed from different parts of the program. That is what e.g. Files does for various process on files.

ghost commented 1 year ago

I think the same. The main Application class shouldn't have this much responsibilities. But I didn't know how to do it in a more structured way when I started writing the PR.

Open to suggestions! Besides, the code works and I can now open folders from Music, but obviously we shouldn't deliver unstable code.

jeremypw commented 1 year ago

Opening from Files and drag-drop now works in the current PR. I think we can revisit the code structure if necessary when we look at m3u8 files in a separate PR. The code will not be released to users yet anyway.