mpv icon indicating copy to clipboard operation
mpv copied to clipboard

play all files in directory

Open philipdexter opened this issue 13 years ago • 16 comments

For example, in vlc you can call vlc subdir and it'll play all files in that directory

philipdexter avatar Nov 24 '13 03:11 philipdexter

If you are on linux or OSX, you can use run "mpv subdir/*", which will use bash expansion to play all the individual files in the directory.

keeperofdakeys avatar Nov 24 '13 04:11 keeperofdakeys

I am aware, however what about subdirs of subdirs? In bash this will work if you turn on advanced globbing by doing mpv subdir/**/* (in zsh this will work automatically). This is just more keystrokes. I can easily type that, and this is just a suggestion. If it won't be implemented then that's fine, just wondering :)

philipdexter avatar Nov 24 '13 04:11 philipdexter

I'm not sure if mpv should have such a feature.

What order should the files even be played? (The order as returned by the OS is essentially random.)

ghost avatar Nov 24 '13 11:11 ghost

Well the actual code required for such a feature would be minimal, a simple directory transversal, checking for circular softlinks, adding each file to the playlist. As for ordering, I'd personally say add them in the order we get them, and maybe implement sorting functionality for the playlist.

Unless there are objections, I might write up some trial code for this. There aren't too many negatives to having the feature, and it won't add any complexity to the code itself. Implementing sorting for the playlist would be the harder matter, which personally I don't see as a requirement for this feature request.

keeperofdakeys avatar Nov 24 '13 13:11 keeperofdakeys

Feel free to try it.

ghost avatar Nov 24 '13 13:11 ghost

If this is done, it'd be nice if the sorting took into account things like 12, 13, 13.5, 14, ... This kind of thing can happen if there's a recap episode, or an extra released separately that fits into the middle of a show. Depending on the character following the number, these will usually end up sorted with e.g. 13.5 before 13, which would result in the episodes playing in the wrong order if mpv were to play the directory.

If this were implemented without any sorting at all, and just used the random order returned by the OS, I don't personally see it being very useful. I think you'd usually want a bunch of files in a directory to play in order (episodes of a show, tracks in an album).

qmega avatar Nov 25 '13 08:11 qmega

That might be as simple as calling a qsort on the list.

12,13,13.5,14 is the natural ordering of that sequence (assuming they come at the end of the file name). If they don't it'll require some heuristic.

philipdexter avatar Nov 25 '13 16:11 philipdexter

The numbers would not be at the end of the filename. There's the file extension, often a CRC, and sometimes other things. Or sometimes the files might be named starting with the number. So some heuristic would be required.

qmega avatar Nov 25 '13 23:11 qmega

I'm already going to throw some playlist sorting into my code, just a quick qsort. If you have 13 and 13.5, these will be sorted fine. However, if you had 9, 10, this would not be sorted correctly. Most series have 09, 10 though, so it shouldn't be an issue.

keeperofdakeys avatar Nov 25 '13 23:11 keeperofdakeys

This seems to be related to something I opened a while back.

mpv-player/mpv#132

LabMem765 avatar Nov 26 '13 04:11 LabMem765

So, mpv itself has an internal playlist (a doubly linked list). Currently my code, if passed a directory on the command line, will explore it recursively, throwing everything onto the playlist. It then sorts the playlist using the filename string. I'll probably make it use a new playlist, which I append to the current one, to handle specifying multiple directories/files on the command line correctly. I'll submit the code after I add some more error handling.

The feature referenced in #132, while similar, must use its own code. It would simply need to find the directory the current file is in, get a list of files, sort them, find where the old file is, and play the next entry. The problem with this is how it interacts with the current playlist (ie. should this only done for the last element, should it create a new playlist, should all the future elements be added). It does sound like a handy feature though, especially when launching from a file manager.

keeperofdakeys avatar Nov 26 '13 04:11 keeperofdakeys

I still think #132 could probably be implemented as a lua script. It would just have to react to a new file being played, scan the directory, and add the next file(s) to the playlist. Of course this can't be done when trying to play a directory itself.

Also, I'm still unsure whether this feature is needed at all (over mpv dir/*), but let's see.

ghost avatar Nov 26 '13 10:11 ghost

As mentioned earlier, the only advantage this code actually gives (over bash expansion) is exploring sub-directories. Whether that's good or not, I'm not sure.

keeperofdakeys avatar Nov 27 '13 02:11 keeperofdakeys

So this is still an open issue in pull request #371. I'm closing this issue, because we don't need two open issues for this.

ghost avatar Apr 08 '14 21:04 ghost

Implemented in git master.

ghost avatar Apr 17 '15 21:04 ghost

Too bad this doesn't use natural sorting for 1*, … , 9*, 10*.

adrianheine avatar May 28 '17 20:05 adrianheine