jonniek / mpv-playlistmanager

Mpv lua script to create and manage playlists
The Unlicense
551 stars 42 forks source link

Question about the "loadfiles" behavior #76

Closed xiakele closed 2 years ago

xiakele commented 2 years ago

I've been using this script for a period of time, and I discovered that if loadfiles_on_start option is enabled or shift+p is pressed during playback, the current file will end up being the last item on the playlist, making loading files to playlist meaningless. If sortplaylist_on_start and sortplaylist_on_file_add is enabled, the items will end up being in an alphabetical order. Is that working as intended? Shouldn't the current file be at the top of the list if sorting is disabled?

jonniek commented 2 years ago

It should load the files in a natural order that they are visible in a directory. In your case the file you were playing was the last file in the directory, so all files went before it. If you opened the first file and loaded more files then rest of files would go behind it. If you think it didn't work like this, maybe there is a bug and I would need some more details to investigate it.

The reason it works like this is that this is the most natural order for a playlist and in most cases wouldn't require any manual modifications. There could still be value in loading the files even if you are on the last file if you have playlist looping on, then it will start over from the beginning. Or obviously if you wanted to jump to some specific item in the middle and continue from there the order would already be correct.

Anyway I added a setting loadfiles_always_append that should change it to work as you described. Let me know if you have any issues with it.

If you are able to reproduce it never appending files no matter which file you open feel free to provide more details and re-open the issue.

xiakele commented 2 years ago

Well, I'm using mpv in Archlinux, and my desktop enviroment is KDE Plasma.

I did some more testing, and it turns out that with the latest script and config file downloaded from master branch, I was still able to reproduce the problem mentioned above. p.s. I only modified the loadfiles_on_start option and left everything else as default.


videoFiles I put four videos in a folder and opened 3.mp4 . videoResults 3.mp4 was at the bottom of the list.


audioFiles Then I tried some audio files. audioFiles Same result.


newOption The new loadfiles_always_append option is working as expected.


I would be happy to provide more details if needed.

jonniek commented 2 years ago

I was able to reproduce it now, thanks!

I'm surprised it didn't affect the keybind for me. The issue was that the logic to skip items that were already in playlist applied to the currently playing file, which caused the flag to start appending instead of prepending to never be set.