Skip to content

Commit

Permalink
fix: autoload looping a file when only a single file in directory
Browse files Browse the repository at this point in the history
closes #768
  • Loading branch information
tomasklaen committed Nov 4, 2023
1 parent 37675d0 commit c982622
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/uosc/lib/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ end
---@param current_index number
---@param delta number 1 or -1 for forward or backward
function decide_navigation_in_list(paths, current_index, delta)
if #paths < 2 then return #paths, paths[#paths] end
if #paths < 2 then return end
delta = delta < 0 and -1 or 1

-- Shuffle looks at the played files history trimmed to 80% length of the paths
Expand Down

4 comments on commit c982622

@christoph-heinrich
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When loop-playlist is on it might be desired that the same file gets played over and over again if it's the only one in the directory.

@tomasklaen
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But that's what loop-file is for. loop-playlist won't loop single file either, as there's no playlist then. I think we'd be loading loop-playlist with implicit behavior it doesn't currently have.

@christoph-heinrich
Copy link
Contributor

@christoph-heinrich christoph-heinrich commented on c982622 Nov 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loop-playlist does loop single files. The difference to loop-file in that case is that the file gets reopened (so all cache is discarded).

There has even been some discussion if mpv should optimize the case with a single playlist item to behave the same as loop-file, because it doesn't make sense to reopen the file in such a case.

@christoph-heinrich
Copy link
Contributor

@christoph-heinrich christoph-heinrich commented on c982622 Nov 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nvm, I should have tested this before writing anything (but didn't want to update because I was working on something).
It does in fact actually already loop for single directory items, no need to change anything. It's actually better this way, because then it doesn't circumvent the aforementioned optimization in case it ever gets implemented.

Please sign in to comment.